Skip to content

Instantly share code, notes, and snippets.

View adamharder's full-sized avatar

Adam Harder adamharder

View GitHub Profile
@adamharder
adamharder / python_environemnt_ubuntu_20.md
Last active May 7, 2021 15:26
Python setup for Ubuntu 20
@adamharder
adamharder / redis_multiprocessing.py
Created May 31, 2019 15:41
Multiprocessing queue backed by Redis
from multiprocessing import Process
import redis
_REDIS_KEY = "MY_GREAT_QUEUE"
_REDIS = redis.Redis()
_PROCESS_COUNT = 15
# clear the queue (may not be necessary)
_REDIS.expire(_REDIS_KEY, 0)
import lmdb
from pathlib import Path
LMDB_FILE_NAME = Path("some_lmdb_file.lmdb").absolute()
# max db size 100 GB
with lmdb.open(str(LMDB_FILE_NAME.absolute()), map_size=100*1000*1000*1000, readonly=False) as env:
print(env.stat()) # This forces the database into existence
def get_env(readonly=False):
@adamharder
adamharder / stupid_ubuntu_tricks.md
Created March 5, 2019 15:48
Stupid Ubuntu things I hate having to lookup

To disable entering the sleep edit the /etc/systemd/logind.conf file and modify the line:

#HandleLidSwitch=suspend to HandleLidSwitch=ignore

Then sudo service systemd-logind restart

git ls-tree -r tag:some/path.file
git show tag:some/path.file
@adamharder
adamharder / tmux-cheatsheet.markdown
Created February 25, 2018 19:49 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@adamharder
adamharder / holidays.json
Last active June 14, 2017 19:37
Federal Holidays
{
"2017-01-02":"HOL",
"2017-01-16":"HOL",
"2017-02-20":"HOL",
"2017-05-29":"HOL",
"2017-07-04":"HOL",
"2017-09-04":"HOL",
"2017-10-09":"HOL",
"2017-11-10":"HOL",
"2017-11-23":"HOL",
## Show size of all tables
select t1.datname AS db_name,
pg_size_pretty(pg_database_size(t1.datname)) as db_size
from pg_database t1
order by pg_database_size(t1.datname) desc;

Append an array

// initialize array
var arr = [
    "Hi",
    "Hello",
    "Bonjour"
];