Skip to content

Instantly share code, notes, and snippets.

Avatar

Valentin Gologuzov evilkost

  • Czech Republic, Prague
View GitHub Profile
View Traffic control cheat sheet
tc qdisc list
tc qdisc add dev lo root netem delay 0.1ms
tc qdisc change dev lo root netem delay 0.3ms
tc qdisc change dev lo root netem delay 0.1ms
View gist:e9889e39752a41b0215a7ce53aa5ab4c
pre-commit run --files `git diff --name-only HEAD~ | tr '\r\n' ' '`
View psql drop all tables in schema
DO $$ DECLARE
tabname RECORD;
BEGIN
FOR tabname IN (SELECT tablename
FROM pg_tables
WHERE schemaname = current_schema())
LOOP
EXECUTE 'DROP TABLE IF EXISTS ' || quote_ident(tabname.tablename) || ' CASCADE';
END LOOP;
END $$;
View pg_check.sh
#!/bin/bash
set -e
while [[ `pg_isready &>/dev/null && echo "1"` -ne "1" ]]; do
sleep 1;
echo "pg is not ready";
done
echo "pg is ready";
View update all git repos
for i in */.git; do ( echo $i; cd $i/..; git pull; ); done
View get_host_from_docker.py
from subprocess import check_output
host_ip = check_output("/sbin/ip route|awk '/default/ { print $3 }'", shell=True).decode().strip()
View tmp
root@85ba14b2a8ab:/opt/pow# echo $PYTHONPATH
/opt/pow:/opt/pow/csn:/opt/pow/zozzymodels:/opt/pow/libs:
root@85ba14b2a8ab:/opt/pow# echo $DJANGO_SETTINGS_MODULE
'csn.settingsdocker'
root@85ba14b2a8ab:/opt/pow# ls -laht /opt/pow/csn/settingsdocker.py
-rw-rw-r-- 1 root root 1.2K Jun 3 13:38 /opt/pow/csn/settingsdocker.py
root@85ba14b2a8ab:/opt/pow# django-admin
Traceback (most recent call last):
File "/usr/local/bin/django-admin", line 11, in <module>
sys.exit(execute_from_command_line())
View linkage_example.txt
Root/Video Games & Consoles/Video Game Consoles [Video Game Consoles]:
-> Root/Video Games/Categories/Xbox 360/Consoles[score 52.9318181818182]
Root/Sporting Goods/Indoor Games/Billiards/Tables [Tables]:
-> Root/Sports & Outdoors/Categories/Sports & Fitness/Leisure Sports & Game Room/Billiards & Pool/Tables & Accessories/Tables[score 59.9232954545455]
-> Root/Toys & Games/Categories/Games/Game Room Games[score 26.72]
-> Root/Toys & Games/Categories/Games/Game Room Games/Billiards[score 14.58125]
-> Root/Sports & Outdoors/Categories/Sports & Fitness/Leisure Sports & Game Room/Arcade & Table Games/Tabletop Billiards & Pool[score 8.74875]
Root/Sporting Goods/Cycling/Bicycle Components & Parts/Tires [Tires]:
View pg_stat.md

Enable module:

vim /var/lib/pgsql/data/postgresql.conf

add at the end:

shared_preload_libraries = 'pg_stat_statements'
# Increase the max size of the query strings Postgres records
track_activity_query_size = 2048
View gist:cec8b14703c06e714d95
docker images -q --filter "dangling=true" | xargs docker rmi
You can’t perform that action at this time.