Sunday, December 29, 2019

aws


solution on connecting ssh 
https://unix.stackexchange.com/questions/115838/what-is-the-right-file-permission-for-a-pem-file-to-ssh-and-scp

fix the security problem in ec2
sudo yum update
before:
aws-cli/1.16.102 Python/2.7.16 Linux/4.14.138-89.102.amzn1.x86_64 botocore/1.12.92
sudo pip install --upgrade awscli
after:
aws-cli/1.16.309 Python/2.7.16 Linux/4.14.138-89.102.amzn1.x86_64 botocore/1.13.45

commands
aws iam list-users
aws iam create-user --user-name Lynard
aws iam list-policies
aws iam attach-user-policy --user-name Lynard --policy-arn arn:aws:iam::aws:policy/AdministratorAccess
aws iam list-attached-user-policies --user-name Lynard
aws iam add-user-to-group --user-name Lynard --group-name Marketing
aws iam get-group --group-name Marketing
aws iam remove-user-from-group --user-name Lynard --group-name Marketing
aws iam detach-user-policy --user-name Lynard --policy-arn arn:aws:iam::aws:policy/AdministratorAccess
aws iam delete-user --user-name Lynard

groups
aws iam create-group --group-name Accounting
aws iam attach-group-policy --policy-arn arn:aws:iam::aws:policy/AmazonDynamoDBFullAccess --group-name Accounting
aws iam list-attached-group-policies --group-name Accounting
aws iam detach-group-policy --group-name Accounting --policy-arn arn:aws:iam::aws:policy/AmazonDynamoDBFullAccess
aws iam delete-group --group-name Accounting
aws iam list-groups


Thursday, October 31, 2019

Wednesday, September 25, 2019

django commands


create new django project
$ django-admin startproject mynewproject

run the server
$ python manage.py runserver

create app
$ python manage.py startapp myapptwo

Tuesday, June 18, 2019

Odoo 9 screen is blank

Issue: 



Solution:

I have found discussion on https://github.com/odoo/odoo/issues/19627 , seems that this issue was known. I tried the workaround to delete the assets information belong in /web/content

DELETE FROM ir_attachment WHERE url LIKE '/web/content/%';

but the first try wasn't successful, so i tried restart the service and refresh my browser.

Still not okay the second, third ... etc. I can't remember how many times i tried but at last it worked.



It's weird but I'm happy as for now. Eureka!

Tuesday, May 14, 2019

Failed to start Docker Application Container Engine





https://github.com/moby/moby/issues/16137



Solution:

It seems the problem is in the cyclane protection
need to ask the IT infra team to whitelist the docker container.shim and runc as part of docker installation.


Monday, April 29, 2019

Caddy sounds like candy

I already configure my domain skyguyver.com with Caddy but I need to review again as I can't remember how I did it.

The Caddyfile was placed in /etc/caddy

skyguyver.com {
    tls lynardsalingujay@gmail.com
    internal /.git
    git https://github.com/skyguyver/caddy.git {
        hook /github_hook d937c9d4-7c48-431e-8e60-bf916186f613
    }
    gzip
    redir 301 {
        if {scheme} is http
        /  https://{host}{uri}
    }
}


Wednesday, April 24, 2019

File "/usr/lib/python2.7/dist-packages/openerp/addons/base/ir/ir_attachment.py"








Conclusion:

Was able to fix this problem with a workaround: manually going into the database and removing the entries pointing to the missing files from filestoreDELETE FROM ir_attachment WHERE store_fname LIKE '%<the ending hash>%'


reference:
https://www.odoo.com/es_ES/forum/ayuda-1/question/solved-how-to-recover-deleted-attachment-files-from-filestore-folder-local-share-odoo-filestore-128453

Friday, April 19, 2019

Running Odoo and Postgres in separate container




Odoo:

version: '2'

services:
  app:
    image: skyguyver/odoo9_latest
    container_name: develop
    ports:
      - "3033:8069"
    volumes:
      - develop-data:/var/lib/odoo
      - ./addons:/mnt/extra-addons
    environment:
      - PYTHONUNBUFFERED=1
      - HOST=172.18.0.1
      - PORT=3032
      - USER=odoo
      - PASSWORD=odoo
    #command: openerp-server -d develop -u all

volumes:
  develop-data:


Postgres:

version: '2'

services:
  db:
    image: postgres:9.6
    ports:
      - "3032:5432"
    environment:
      - POSTGRES_USER=odoo
      - POSTGRES_PASSWORD=odoo
      - PGDATA=/var/lib/postgresql/data/pgdata
    volumes:
      - dbdata:/var/lib/postgresql/data/pgdata

volumes:
  dbdata:

Saturday, April 6, 2019

devco trial


Bubbles.py

from collections import OrderedDict

def nonrepeating(orig):

input = orig.lower()

dict=OrderedDict.fromkeys(input,0)

# traverse
for ch in input:
dict[ch]+=1

# nonrepeat
nonRepeatDict = [key for (key,value) in dict.iteritems() if value==1]
print nonRepeatDict

repeatStr = []
for tx in list(orig):
if tx not in nonRepeatDict:
repeatStr.append(tx)

makeitastring = ''.join(map(str, nonRepeatDict + repeatStr))
print makeitastring

if __name__ == "__main__":
orig = "Bubble"
nonrepeating(orig)



# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(N):
    # write your code in Python 3.6
    ret = '+'
    flag = '+'
    for i in range(1, N):
        if flag == '+':
            ret += '-'
            flag = '-'
        else:
            ret += '+'
            flag = '+'
    return ret

Thursday, April 4, 2019

Packt tutorial

Docker GUI
https://www.youtube.com/watch?v=8OuqJtIpUnw

Installing Jenkins with Docker in new approach

Install Jenkins

  • Running Jenkins as a Docker container
  • Interacting with the Docker host from Jenkins

$ docker volume create jenkins

To identify docker group id
$ getent group docker
docker:x:998:vagrant

Run the container and to save the jenkins configuration into jenkins volume
$ docker run -v jenkins:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock --group-add 998 --name jenkins dockerhp/jenkins


$ docker run -v jenkins:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock --group-add 998 -d --name jenkins dockerhp/jenkins 

To figure out the ip address of jenkins
$ docker inspect -f '{{.NetworkSettings.Networks.bridge.IPAddress}}' jenkins
172.17.0.2

To view the secret password
$ docker exec jenkins cat /var/jenkins_home/secrets/initialAdminPassword


Install plugin
Git plugin

Thursday, March 28, 2019

1and1 email address issue

I had this problem with my 1and1 email address. I can't receive any email from outside. I called the customer service in 1and1 and they help me setup into my digitalocean. The problem was that I had tied up my dns records already in digitalocean and all incoming email will intercept from digitalocean, something like that. I think, hehe.

But thanks its already solved. Eureka!


digitalocean

Hostname: @





TODO:
need to call digitalocean to add SPF







Java spring framework and dependency

I just had my refresher course for Java spring framework and it's really nice to be back again with Java. I find it that it's really improved from last used in Java way back in 2014. IDE is getting more better especially when using Eclipse.

I am using Spring tool suite now and it's really nice. One thing when working or coding into IDE I really like to use vim editor style. But now, I find this nice tool called vrapper http://vrapper.sourceforge.net/home/. You just install into the eclipse marketplace and that's it, boom, you have your vim style in your editor. sweet!

Another tool I just recently discovered is to have your clean code automatically formatted. I found this site http://www.eclipseonetips.com/2009/12/13/automatically-format-and-cleanup-code-every-time-you-save/ , it gives you guide how to set up in eclipse. woohh sweet again!



Spring devtools maven
dependency on automatic restarting the application

https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-devtools.html


copy and paste in pom.xml




Tuesday, March 26, 2019

I'm back in Java after 5 years

I enrolled a free course at https://courses.edx.org with the title "Fundamentals of Java EE Development". It's really great I hope it will help me refresh my memory in Java.

first I followed the guide to install the necessary tools for this course.
https://prod-edxapp.edx-cdn.org/assets/courseware/v1/f9292ed1b6d208828257761a04df54e9/asset-v1:RedHat+JB083x+3T2018+type@asset+block/JB083x_SG_Updated.pdf


Tuesday, March 19, 2019

docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:297


docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:297: copying bootstrap data to pipe caused \"write init-p: broken pipe\"": unknown.


workaround:
use vagrant bento version instead of official ubuntu !!!


How to setup Jenkins and Docker

So I want to learn CI/CD and I want to try this in my work. The setup would be docker, jenkins and odoo as the application.

These are the steps:

1. Pull official jenkins image.
docker pull jenkins

2. Create empty folder
/var/jenkins_home

2. Run the docker, will add the volume to map our local from the container.
docker run -u root --rm -p 8080:8080 -p 50000:50000 -v /var/jenkins_home:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock jenkinsci/blueocean







reference:
https://hub.docker.com/r/jenkinsci/blueocean/

Sunday, February 17, 2019

Error starting userland proxy: listen tcp 0.0.0.0:5432: bind: address already in use

This issue happens when I installed Postgres in my vagrant (vm) and then I after a while I removed it. But the service is still running in the system causing the default 5432 port is not available to be used.





first I run this command

sudo apt-get --purge remove postgresql


but still, it didn't totally remove. so I have to run this command to list all running postgres

dpkg -l | grep postgres



then, I run again this command

sudo apt-get --purge remove postgresql postgresql-doc postgresql-common






Eureka!

Thanks for this reference
https://askubuntu.com/questions/32730/how-to-remove-postgres-from-my-installation

Wednesday, January 30, 2019

useful unix commands


to see all processes
ps -aef | more
ps -aef | sort | more
ps -aef | sort > out.txt


Monday, January 28, 2019

installing anaconda and jupyter in digitalocean

I have been frustrated lately trying to learn data science in my office (in my spare time) because of the SSL certificate issue. Every time I execute a command the error just popping up and I get a less patient and I say "Arrrrrr" and suddenly just pop in my mind, what if I will run anaconda and jupyter in my external server which my personal from digital ocean. and then the quest begins....


1. install the anaconda
https://www.digitalocean.com/community/tutorials/how-to-install-anaconda-on-ubuntu-18-04-quickstart

2. configure and run jupyter
https://www.digitalocean.com/community/tutorials/how-to-install-run-connect-to-jupyter-notebook-on-remote-server

ohhh, i'm invincible its only 2 steps.

 


Eureka!!!!!

Thursday, January 24, 2019

Error: Permission denied to access property "nodeName"

issue




https://github.com/odoo/odoo/commit/5bb7ffa2

1. copy the file from container to host
docker cp 12f4057cbf0c:/usr/lib/python2.7/dist-packages/openerp/addons/web_editor/static/src/js/summernote.js .

2. after edit the file, copy back to container
docker cp summernote.js 12f4057cbf0c:/usr/lib/python2.7/dist-packages/openerp/addons/web_editor/static/src/js






Eureka!

Wednesday, January 23, 2019

python text to speech and this is awesome

pip install pyttsx3
pip install pypiwin32

the code:

import pyttsx3;
engine = pyttsx3.init();
engine.say("My wife is Sheryl and my two son's are Kiefer and Jairus");
engine.runAndWait() ;

that's it, eureka!

Tuesday, January 22, 2019

speech recognition

its 11pm and I found something interesting, this time I tried to implement speech recognition.

actually, its very easy

1. pip install SpeechRecognition
2. conda install -c anaconda pyaudio
3. the code

import speech_recognition as sr

r = sr.Recognizer()

with sr.Microphone() as source:
print('Speak anything:')
audio = r.listen(source)

try:
text = r.recognize_google(audio)
print('you said: {}'.format(text))
except:
print('sorry could not recognize your voice...')


4. run it! so simple. Eureka!


reference:
https://www.youtube.com/watch?v=K_WbsFrPUCk
https://realpython.com/python-speech-recognition/

Thursday, January 17, 2019

check the install python modules

python

import pip
installed_packages = pip.get_installed_distributions()
installed_packages_list = sorted(["%s==%s" % (i.key, i.version)
     for i in installed_packages])
print(installed_packages_list)


Thursday, January 3, 2019

SSL error

error:





solution:

conda config --set ssl_verify False

(better approach)
conda config --set ssl_verify C:\Users\lynard\AppData\Local\Continuum\anaconda3\Library\ssl\Fortinet_CA_SSL.pem

Install and manage anaconda in windows



conda commands

list of environment
conda info --envs

create environment
conda create --name py36 python=3.6 pip numpy
activate py36
conda install matplotlib

to show packages installed
conda list --explicit
conda list --explicit > py36_reqs.txt
conda create --name py36_v2 -- file py36_reqs.txt

to remove environment
conda env remove --name pyside

to clone environment
conda create --name myclone --clone myenv


reference:
https://docs.conda.io/projects/conda/en/4.6.0/_downloads/52a95608c49671267e40c689e0bc00ca/conda-cheatsheet.pdf
https://kapeli.com/cheat_sheets/Conda.docset/Contents/Resources/Documents/index (new)
https://www.youtube.com/watch?v=9Sfs7Fbvtdk














free online comma separating tool

https://delim.co/#