Skip to content

Instantly share code, notes, and snippets.

View thobbs's full-sized avatar
🎨

Tyler Hobbs thobbs

🎨
View GitHub Profile
@thobbs
thobbs / make-movie.sh
Last active April 30, 2020 02:05
Script to generate animations from progress images of work
#!/bin/bash
mkdir ./animation
# make square 1200x1200 images
for fname in $@; do
echo "Converting $fname";
newfname=$(printf "animation/%04d.jpg" "$a");
convert $fname -thumbnail '1200x1200>' -background black -gravity center -extent 1200x1200 $newfname;
let a=a+1;
@thobbs
thobbs / strip_border.py
Created August 28, 2018 05:46
Strip the border from an SVG for plotting through Inkscape
import sys
import lxml.etree as le
def main(filename):
with open(filename, 'r+b') as f:
doc = le.parse(f)
# strip border strokes
for elem in doc.xpath('//*[attribute::style]'):
if 'stroke:none' in elem.attrib['style']:
@thobbs
thobbs / reflection.clj
Created July 8, 2016 01:44
Code for partial reflections
(let [; pick random points for a "line of reflection"
reflection-start-x (random (w 0.0) (w 0.5))
reflection-start-y (random (h 0.5) (h 1.0))
reflection-end-x (random (w 0.5) (w 1.0))
reflection-end-y (random (h 0.0) (h 0.5))
x-spread (- reflection-end-x reflection-start-x)
y-spread (- reflection-end-y reflection-start-y)
max-spread (max x-spread y-spread)
@thobbs
thobbs / jiralinks.py
Last active November 20, 2015 08:34
Script to generate table of branch and test links for the Cassandra JIRA
@thobbs
thobbs / chaos.sh
Created July 22, 2014 21:11
chaos.sh
#! /bin/bash
while true; do
echo "stopping node1"
./ccm node1 stop
sleep 1
echo "starting node1"
./ccm node1 start
@thobbs
thobbs / cassandra_leaks.py
Created March 18, 2014 18:45
Memory Leak Repro
import resource
import gc
from guppy import hpy
def print_heap(hp):
h = hp.heap()
strs = []
strs.extend(str(h).split('\n')[1:-1])
for i in range(10):
#!/usr/bin/env python
import logging
log = logging.getLogger()
log.setLevel('INFO')
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter("%(asctime)s [%(levelname)s] %(name)s: %(message)s"))
log.addHandler(handler)
@thobbs
thobbs / multiproc.py
Created March 7, 2014 19:44
Multiprocess Example
#!/usr/bin/env python
import logging
log = logging.getLogger()
log.setLevel('DEBUG')
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter("%(asctime)s [%(levelname)s] %(name)s: %(message)s"))
log.addHandler(handler)
@thobbs
thobbs / example-utf8.py
Created November 26, 2013 17:02
UTF-8 version of example.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import logging
log = logging.getLogger()
log.setLevel('DEBUG')
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter("%(asctime)s [%(levelname)s] %(name)s: %(message)s"))
log.addHandler(handler)
@thobbs
thobbs / example.py
Created November 6, 2013 15:36
Demonstration of timestamp and datetime behaviors for simple and prepared statements.
#!/usr/bin/env python
import logging
log = logging.getLogger()
log.setLevel('INFO')
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter("%(asctime)s [%(levelname)s] %(name)s: %(message)s"))
log.addHandler(handler)