Skip to content

Instantly share code, notes, and snippets.

Avatar

Avishay Zarad avshyz

  • Singular Labs Inc.
  • Tel Aviv
View GitHub Profile
@avshyz
avshyz / snippet.sql
Last active Jun 30, 2020
[Postgres Delete Locks] delete all hang queries #postgres #db
View snippet.sql
SELECT pg_terminate_backend(b.pid)
from (SELECT pid,
now() - pg_stat_activity.query_start AS duration,
query,
state
FROM pg_stat_activity
WHERE (now() - pg_stat_activity.query_start) > interval '5 minutes') as b
where pid <> pg_backend_pid();
@avshyz
avshyz / snippet.zsh
Created Jun 24, 2020
[Install Psycopg2] #troubleshoot
View snippet.zsh
`LDFLAGS='-L/usr/local/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib' pip install psycopg2`
@avshyz
avshyz / snippet.zsh
Created Jun 24, 2020
[Docker Postgres] creates a container with postgres sql #postgres #docker
View snippet.zsh
docker stop localdb
docker rm localdb
# Init
docker run -p 5432:5432 --name localdb -e POSTGRES_PASSWORD=1 -d postgres
docker exec -it localdb createdb deepchecks -U postgres
# Check
psql postgresql://postgres:1@0.0.0.0/deepchecks
@avshyz
avshyz / snippet.py
Created Jun 24, 2020
[Jupyter Autoreload] #python #jupyter
View snippet.py
%load_ext autoreload
%autoreload 2
@avshyz
avshyz / snippet.zsh
Created Jun 24, 2020
[Alembic Version Control]
View snippet.zsh
alembic upgrade +2
alembic downgrade -1
alembic downgrade HASH+2
@avshyz
avshyz / snippet.zsh
Created Jun 24, 2020
[Alembic DB Upgrade] #migration
View snippet.zsh
alembic revision -m "REVISIONNAME" --autogenerate
alembic upgrade head
@avshyz
avshyz / snippet.zsh
Created Jun 24, 2020
[K8s Copy Secrets Over Namespaces] #kube
View snippet.zsh
kubectl get secret gcr-json-key --namespace=OLD -ojson | jq '.metadata.namespace =“NEW”’ | kubectl create -f -
@avshyz
avshyz / snippet.zsh
Created Jun 24, 2020
[K8s Job Restart] #kube
View snippet.zsh
kubectl get job JOBNAME -o json | jq 'del(.spec.selector)' | jq 'del(.spec.template.metadata.labels)' | kubectl replace --force -f -
@avshyz
avshyz / snippet.zsh
Created Jun 24, 2020
[Delete Dangling Dockers] #docker
View snippet.zsh
docker rmi $(docker images -f "dangling=true" -q)
@avshyz
avshyz / snippet.zsh
Created Jun 24, 2020
[Ephemeral Docker] #docker
View snippet.zsh
docker run -it --rm nginx:1.16.0-alpine /bin/sh
You can’t perform that action at this time.