This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hashlib | |
def check_sum(data): | |
# if type dict need to cast to string | |
if type(data)==type({}): | |
data = str(data) | |
# lib require to encode to unicode before hash | |
hash_object = hashlib.md5(data.encode()) | |
return hash_object.hexdigest() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
psql mypgdb -c "SELECT d.datname AS Name, pg_catalog.pg_get_userbyid(d.datdba) AS Owner, | |
CASE WHEN pg_catalog.has_database_privilege(d.datname, 'CONNECT') | |
THEN pg_catalog.pg_size_pretty(pg_catalog.pg_database_size(d.datname)) | |
ELSE 'No Access' | |
END AS SIZE | |
FROM pg_catalog.pg_database d | |
where d.datname='mypgdb' | |
ORDER BY |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cd /var/log/postgresql; tail -n 500000 postgresql-9.1-main.log > res2 ;grep -A 5 -ir deadlock res2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# java 7 only [https://drive.google.com/file/d/1yNCrwEajgpFnRiIUaB8GW04RCtRDI9Lp/view?usp=sharing] | |
# ireport [https://drive.google.com/a/itblabla.com/file/d/1XM5_34PxcnpIxuxkOB5Yy3llAOsjE0HE/view?usp=sharing] | |
./ireport --jdkhome /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT nspname || '.' || relname AS "relation", | |
pg_size_pretty(pg_total_relation_size(C.oid)) AS "total_size" | |
FROM pg_class C | |
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace) | |
WHERE nspname NOT IN ('pg_catalog', 'information_schema') | |
AND C.relkind <> 'i' | |
AND nspname !~ '^pg_toast' | |
ORDER BY pg_total_relation_size(C.oid) DESC | |
LIMIT 20; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://stackoverflow.com/questions/37771434/mac-pip-install-pymssql-error | |
# install freetds | |
brew unlink freetds; | |
brew install [email protected]; | |
brew link --force [email protected] | |
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.bash_profile | |
pip install pymssql |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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; |