This file contains 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
# -*- coding: utf-8 -*- | |
""" | |
Snippet based on pydrive allowing to upload full folders to Google Drive, replicating the same subfolders hierarchy. | |
Settings are set in the yaml files; don't forget to generate google api credentials and to put the client_secrets.json in the folder. | |
You should get first the id of the parent folder (the gdrive folder where you want to copy your folders), which is the | |
end of its url. | |
If the destination folder does not exist, it will be created. |
This file contains 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
-- show running queries (pre 9.2) | |
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
FROM pg_stat_activity | |
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
ORDER BY query_start desc; | |
-- show running queries (9.2) | |
SELECT pid, age(clock_timestamp(), query_start), usename, query | |
FROM pg_stat_activity | |
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
This file contains 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
#### Get list of objects by size #### | |
# work over each commit and append all files in tree to $tempFile | |
tempFile=$(mktemp) | |
IFS=$'\n' | |
for commitSHA1 in $(git rev-list --all); do | |
git ls-tree -r --long "$commitSHA1" >>"$tempFile" | |
done | |
# sort files by SHA1, de-dupe list and finally re-sort by filesize |
This file contains 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
------------ Duplicates management ------------ | |
-- Show the duplicate rows in <table> | |
select * from <table> ou | |
where (select count(*) from <table> inr | |
where inr.id = ou.id) > 1 | |
order by id; | |
---- OR |
This file contains 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
#### Get all the numpy array and their size #### | |
# From https://stackoverflow.com/questions/11784329/python-memory-usage-of-numpy-arrays | |
import sys | |
import numpy | |
from humanize import naturalsize | |
for size, name in sorted( | |
(value.nbytes, name) | |
for name, value in locals().items() |