Skip to content

Instantly share code, notes, and snippets.

@dunhamsteve
dunhamsteve / makeuml.py
Last active December 15, 2015 14:29
A little utility to convert a textual description of classes to a UML diagram (in dot format).
#!/usr/bin/python
# This code is public domain, share and enjoy.
import sys, re
rEdge = re.compile(r'(\w+)\s+([\w.*]*)\s*(--|->|<-|<->)\s*([\w.*]*)\s+(\w+)\s*')
rName = re.compile(r'\w+')
arrows = {
@dunhamsteve
dunhamsteve / repositories.py
Last active December 15, 2015 14:28
A little utility to enumerate all of the svn, hg, and git repositories on the current machine. Requires a locate database. Outputs the type, remote url, and local path.
#!/usr/bin/python
# This code is public domain, share and enjoy.
"""Enumerates svn, git, and mercurial repositories in locate database
"""
from subprocess import Popen,PIPE, check_output
import re, os.path
@dunhamsteve
dunhamsteve / tabla_recta.py
Last active October 8, 2015 01:49
A python script to generate a wallet-sized "table recta" for passwords
#!/usr/bin/python
# This code is public domain, share and enjoy.
import random, re, sys, os
seed = None
if len(sys.argv) > 1:
seed = int(sys.argv[1])
@dunhamsteve
dunhamsteve / scroller.js
Last active June 28, 2020 16:10
decorator for iPad scrollable areas
// This code is public domain, share and enjoy.
window.ui = window.ui || {};
/** @constructor */
ui.ListView = function(element, collection) {
this.el = element;
this.cellHeight = 30;
this.collection = collection;
@dunhamsteve
dunhamsteve / table.html
Last active July 26, 2025 03:34
Example of a scrollable table that only renders visible rows
<!-- This code is public domain, share and enjoy. -->
<html>
<style type="text/css" media="screen">
#table {
position: absolute;
top: 30px;
bottom: 0;
left: 10px;
right: 10px;
}
@dunhamsteve
dunhamsteve / wherefroms.py
Last active October 20, 2019 03:53
Code to get and set kMDItemWhereFroms in python
# This code is public domain, share and enjoy.
from Foundation import NSPropertyListSerialization
from xattr import setxattr, getxattr
kMDItemWhereFroms = "com.apple.metadata:kMDItemWhereFroms"
def set(path, *data):
"""Set kMDItemWhereFroms on a file. Pass in an array of strings."""
plist, err = NSPropertyListSerialization.dataWithPropertyList_format_options_error_(data, 200, 0, None)
if err or not plist: