Skip to content

Instantly share code, notes, and snippets.

View qoda's full-sized avatar

Jonathan Bydendyk qoda

View GitHub Profile
@qoda
qoda / managed_multiprocessing.py
Last active November 2, 2023 17:29
Managed Multiprocessing
import logging
import multiprocessing
import sys
import time
logger = logging.getLogger(__name__)
multiprocessing.set_start_method('fork')
@qoda
qoda / day8.py
Last active December 8, 2022 12:02
AoC Day 8
from functools import reduce
from itertools import chain
def determine_visibility(input):
matrix = [[int(x) for x in b] for b in input]
def look_up(current_position):
x, y = current_position
return [matrix[i][x] for i in reversed(range(y))]
@qoda
qoda / day7.py
Created December 7, 2022 15:54
Day 7
MAX_DIR_SIZE = 100_000
REQUIRED_SPACE = 0
def calculate_deletable(file_system):
total = 0
for v in file_system.values():
if isinstance(v, int):
total += v if v <= MAX_DIR_SIZE else 0
if isinstance(v, dict):
import csv
import sys
def fix_case(name):
splitname = name.split()
return " ".join([n.lower().capitalize() for n in splitname])
def extract(file_path):
# add homebrew executables to bash
export PATH=/usr/local/bin:$PATH
# bash prettify
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
# git bash completion via brew
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
@qoda
qoda / attrdict.py
Last active August 29, 2015 13:56
Convert Dict to Object
class AttrDict(dict):
"""
Convert a dict to an object.
"""
def __init__(self, new_dict):
self.__dict__.update(new_dict)
for key, val in new_dict.items():
if isinstance(val, dict):
self.__dict__[key] = AttrDict(val)
@qoda
qoda / simple_twitter_manager.py
Created December 17, 2013 08:55
Simple Twitter Manager
#!/usr/bin/env python
import twitter
TWITTER_CONSUMER_KEY = 'XXX'
TWITTER_CONSUMER_SECRET = 'XXX'
TWITTER_ACCESS_TOKEN_KEY = 'XXX'
TWITTER_ACCESS_TOKEN_SECRET = 'XXX'
@qoda
qoda / secret_key.py
Last active March 16, 2023 13:39
Secret Key Generator
import random
import string
print("".join([random.choice(string.ascii_letters + string.digits + string.punctuation) for i in range(64)]))
import Image
import urllib
import StringIO
from math import log, exp, tan, atan, pi, ceil
EARTH_RADIUS = 6378137
EQUATOR_CIRCUMFERENCE = 2 * pi * EARTH_RADIUS
INITIAL_RESOLUTION = EQUATOR_CIRCUMFERENCE / 256.0
ORIGIN_SHIFT = EQUATOR_CIRCUMFERENCE / 2.0
@qoda
qoda / random_string.py
Last active December 16, 2015 01:29
Random String Generation
random_string = "".join(random.choice(string.hexdigits + string.digits) for r in [i for i in range(16)])