Skip to content

Because you've googled for the same stackoverflow site 257 times.

Notifications You must be signed in to change notification settings

joloppo/snippets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 

Repository files navigation

snippets

Remove github deployment environment (requires jq installed) env is environment name

env=
token=
repo=
user=

for id in $(curl -u $user:$token https://api.github.com/repos/$user/$repo/deployments\?environment\=$env | jq ".[].id"); do
    curl -X POST -u $user:$token -d '{"state":"inactive"}' -H 'accept: application/vnd.github.ant-man-preview+json' https://api.github.com/repos/$user/$repo/deployments/$id/statuses
    curl -X DELETE -u $user:$token https://api.github.com/repos/$user/$repo/deployments/$id
done

MacOS Remove all DS_Store (useful for enforcing list view)

sudo find / -name ".DS_Store"  -exec rm {} \;

Discard git changes

git stash save --keep-index --include-untracked && git stash drop

Kill postgres connections

SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'mydb' -- ← change this to your DB
  AND pid <> pg_backend_pid();

Print all of a dataframe

with pd.option_context('display.max_rows', None, 'display.max_columns', None):
    print(df)

Get DBeaver credentials

openssl aes-128-cbc -d -K babb4a9f774ab853c96c2d653dfe544a -iv 00000000000000000000000000000000 -in "${HOME}/Library/DBeaverData/workspace6/General/.dbeaver/.credentials-config.json.bak" | dd bs=1 skip=16 2>/dev/null

Git delete tracking branches not on remote

git remote prune origin

Git delete local branches not on remote

git fetch -p && git branch -vv | grep ': gone]' | awk '{print $1}' | xargs git branch -D

Installing pytables Macos github1 --- stackoverflow

export HDF5_DIR=/opt/homebrew/opt/hdf5

Kill process running or port 8000 MacOS

kill -9 $(lsof -ti:8000)

When psycopg wont install python stuff. install some libpq shit or psycopg binary idk

sudo apt install libpq-dev

Pyzmq on M1 - use this version (needed for jupyter notebook (?))

'pyzmq==25.1.0'

Print entire pandas df dataframe

with pd.option_context('display.max_rows', None, 'display.max_columns', None, 'display.precision', 3,):

Get current dir subdir/file sizes, sorted

du -h -d 1 | sort -h

Postgres stuffs

SELECT relname, n_live_tup FROM pg_stat_user_tables; -- Table & counts

SELECT
   relname  as table_name,
   pg_size_pretty(pg_total_relation_size(relid)) As "Total Size",
   pg_size_pretty(pg_indexes_size(relid)) as "Index Size",
   pg_size_pretty(pg_relation_size(relid)) as "Actual Size"
   FROM pg_catalog.pg_statio_user_tables 
ORDER BY pg_total_relation_size(relid) DESC;



SELECT 
    attname AS column_name,
    avg_width AS average_size_in_bytes
FROM 
    pg_stats
WHERE 
    schemaname = 'public'
    AND tablename = 'my_table';

select pg_size_pretty(pg_database_size('my_db'));

About

Because you've googled for the same stackoverflow site 257 times.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages