Skip to content

Instantly share code, notes, and snippets.

View crantok's full-sized avatar

Justin Hellings crantok

View GitHub Profile
@crantok
crantok / text2ktouch.py
Created April 15, 2012 19:18
A python script to generate a KTouch lesson from a text file
#!/usr/bin/env python
import argparse
import re
parser = argparse.ArgumentParser(description=
'Create a KTouch lesson from a text file. Most white space will be stripped.')
parser.add_argument(
'input_filename', help='Name of text file to read')
parser.add_argument(
@crantok
crantok / config.ru
Created May 22, 2013 10:29
Segfault - DataMapper MySQL Nginx Passenger
name = 'segfault'
require 'dm-core'
db = DataMapper.setup(:default, "mysql://#{name}:#{name}@localhost/#{name}")
db.select("CREATE TABLE #{name}(id INTEGER PRIMARY KEY)")
# A script to execute a system command in response to filesystem changes.
#
# After the latest filesystem change, a minimum interval is allowed to pass
# before calling the system command.
# Multiple filesystem changes in quick succession are treated as a single
# change.
#
# Pidify is used to ensure that this script can safely be called multiple
# times and only one instance will ever be running.
# The pidify ruby file is included using require_relative because I could not
@crantok
crantok / english_ordinal.rb
Created December 4, 2018 15:55
Get an english ordinal string ('1st', '2nd', '3rd', etc) from an integer
def english_ordinal n
str = n.to_s
str +
case str
when /11$/, /12$/, /13$/
'th'
when /1$/
'st'
when /2$/
'nd'