Skip to content

Instantly share code, notes, and snippets.

View cgthayer's full-sized avatar
💡
coding

Charles Thayer cgthayer

💡
coding
View GitHub Profile
#!/usr/bin/env python
import hashlib
import sys
bsz = 8192
for f in sys.argv[1:]:
sha1sum = hashlib.sha1()
with open(f, 'rb') as source:
while True:
block = source.read(bsz)
@cgthayer
cgthayer / docker-n00b.md
Last active February 7, 2024 14:38
Docker Notes for n00bs

Basics

Images are read-only templates, but you can diff and push them to save many versions. Containers are instances of images, that are also directories and usually a single running process.

Images can be layered, you start from a base and make changes. Containers are versioned so that you can make changes and save the filesystem state as a new Image.

@cgthayer
cgthayer / djikstra.py
Created March 15, 2017 06:06
Djikstra in python for source to all others and source to single destination
import copy
Infinity = 1e6
class GraphU:
"""Undirected graph, with edge cost and nodes have string names.
Okay to use int or float cost, but must be positive.
Assumes only one edge between any node n1 and n2.
"""
def __init__(self, edges=()):
@cgthayer
cgthayer / tmux.cheat
Last active October 20, 2015 16:04 — forked from afair/tmux.cheat
Tmux Quick Reference & Cheat sheet - 2 column format for less scrolling!
========================================== ==========================================
TMUX COMMAND WINDOW (TAB)
========================================== ==========================================
List tmux ls List ^b w
New -s <session> Create ^b c
Attach att -t <session> Rename ^b , <name>
Rename rename-session -t <old> <new> Last ^b l (lower-L)
Kill kill-session -t <session> Close ^b &