Skip to content

Instantly share code, notes, and snippets.

View shawnohare's full-sized avatar

Shawn O'Hare shawnohare

View GitHub Profile
@shawnohare
shawnohare / huge-gist-example.go
Last active November 20, 2015 06:32
Hugo theme example for embedding a Gist
package main
import (
"log"
)
func main() {
log.Println("Hello world!")
}
@shawnohare
shawnohare / foxyproxy.json
Created January 6, 2018 01:24
AWS EMR FoxyProxy 6 Settings
{
"mode": "patterns",
"proxySettings": [
{
"title": "EMR SOCKS Proxy",
"type": 3,
"color": "#cc8c2a",
"address": "localhost",
"port": 8157,
"proxyDNS": true,
@shawnohare
shawnohare / get_modules.py
Last active August 1, 2018 22:56
Get all modules from a package.
import inspect
import pkgutil
from importlib import import_module
def get_package_modules(package):
"""Recursively get all modules of a package, including modules of any
subpackages.
"""
modules = []
for _, name, ispkg in pkgutil.iter_modules(package.__path__):
@shawnohare
shawnohare / README
Created July 11, 2022 02:46 — forked from jmatsushita/README
Setup nix, nix-darwin and home-manager from scratch on an M1 Macbook Pro
# I found some good resources but they seem to do a bit too much (maybe from a time when there were more bugs).
# So here's a minimal Gist which worked for me as an install on a new M1 Pro.
# Inspired by https://github.com/malob/nixpkgs I highly recommend looking at malob's repo for a more thorough configuration
#
# Let's get started
#
# Let's install nix (at the time of writing this is version 2.5.1
curl -L https://nixos.org/nix/install | sh
# I might not have needed to, but I rebooted
@shawnohare
shawnohare / README.md
Created November 23, 2022 19:49
asyncio socket client / server example

A basic example of using the higher level asyncio constructs such as streams in a server and client where both pass messages with regular cadence.

@shawnohare
shawnohare / dictmerge.py
Created July 7, 2023 18:42
Python recursive dict merge
def merge(d1: dict, d2: dict) -> dict:
"""Return a new dict instance containing the recursive
merge of d2 into d1. Neither input is mutated.
"""
d1 = deepcopy(d1)
d2 = deepcopy(d2)
for k2, v2 in d2.items():
if isinstance(v2, dict) and isinstance(v1 := d1.get(k2), dict):
v2 = merge(v1, v2)
d1[k2] = v2