Skip to content

Instantly share code, notes, and snippets.

View songpon's full-sized avatar

Songpon Phusing songpon

View GitHub Profile
# Reference
# https://www.linuxcloudvps.com/blog/how-to-install-odoo-10-on-ubuntu-16-04-with-nginx-as-a-reverse-proxy/
# https://linuxize.com/post/configure-odoo-with-nginx-as-a-reverse-proxy/
upstream odoo {
server 127.0.0.1:8069;
}
upstream odoo-chat {
server 127.0.0.1:8072;
import os
import datetime
import glob
def modification_date(filename):
t = os.path.getmtime(filename)
return datetime.datetime.fromtimestamp(t)
files = glob.glob('*')
@songpon
songpon / install-mongodb-ubuntu-16.04.sh
Created March 29, 2018 03:12
ubuntu 16.04 install mongodb
sudo apt install apt-transport-https
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
sudo apt-get update
sudo apt-get install -y mongodb-org
@songpon
songpon / do-dns.sh
Last active February 10, 2018 14:56
Digital Ocean update my dns record
#!/bin/bash
domain=example.com
token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
#get record_id from this command
#curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $api" "https://api.digitalocean.com/v2/domains/$domain/records"
record_id=88888888
current_ip="$(\
@songpon
songpon / csv2xlsx.py
Last active January 15, 2018 15:38
convert csv to xlsx
#!/usr/bin/env python3
import sys
import csv
import xlsxwriter
"""
requirements:
pip install xlsxwriter
pip install progressbar2
usage:
## OpenERP backend ##
upstream openerp {
server 127.0.0.1:8080;
}
server {
listen 443 default;
server_name e-system.afrims.org;
client_max_body_size 2G;
# set up locale for terminal prevent unknow locale
echo export LC_CTYPE=en_US.UTF-8 >> .profile
echo export LC_ALL=en_US.UTF-8 >> .profile
source ~/.profile
wget https://salsa.debian.org/postgresql/postgresql-common/raw/master/pgdg/apt.postgresql.org.sh
bash apt.postgresql.org.sh
MASTER_IP=
SLAVE_IP=
# service postgresql stop
su - postgres
psql -c "CREATE ROLE replica WITH PASSWORD 'myreplpassword' LOGIN REPLICATION;"
#Security for master allow standby access
echo "host replication replica $SLAVE_IP/32 md5" >> /etc/postgresql/9.6/main/pg_hba.conf
CREATE USER readonlyuser WITH ENCRYPTED PASSWORD 'secret';
GRANT USAGE ON SCHEMA public to readonlyuser;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readonlyuser;
-- repeat code below for each database:
GRANT CONNECT ON DATABASE mydbname to readonlyuser;
\c mydbname
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO readonlyuser; --- this grants privileges on new tables generated in new database "foo"
# https://stackoverflow.com/questions/37771434/mac-pip-install-pymssql-error
# install freetds
brew unlink freetds;
brew install freetds@0.91;
brew link --force freetds@0.91
echo 'export PATH="/usr/local/opt/freetds@0.91/bin:$PATH"' >> ~/.bash_profile
pip install pymssql