Skip to content

Instantly share code, notes, and snippets.

View deontologician's full-sized avatar
🦀
🌎

Josh Kuhn deontologician

🦀
🌎
View GitHub Profile
@deontologician
deontologician / PKGBUILD
Created May 3, 2011 04:47
PKGBUILD for mathpartir tex library
pkgname=mathpartir
pkgver=1.2
pkgrel=2
pkgdesc="Latex package for typesetting type inference rules"
arch=(any)
url="http://cristal.inria.fr/~remy/latex/"
license=('GPL')
install=install
source=('http://cristal.inria.fr/~remy/latex/mathpartir.dvi'
'http://cristal.inria.fr/~remy/latex/mathpartir.sty'
@deontologician
deontologician / gtklpbuild.txt
Created June 6, 2011 22:04
Failed compilation of gtklp
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
@deontologician
deontologician / gist:1285974
Created October 14, 2011 00:58
Closure example
function hailIfCargoMatches(lookingFor, specialHail)
function closure(event, data)
local cargoname,_,_ = unpack(data)
if cargoname:find(lookingFor, 1, true) then
sendChat(specialHail,"PRIVATE",currentTarget)
end
end
return closure
end
@deontologician
deontologician / gist:1378914
Created November 19, 2011 14:53
Enumerate example
my_list = ['a','b','c']
for index, value in enumerate(my_list):
print index, value
# This will print:
# 0 a
# 1 b
# 2 c
@deontologician
deontologician / tagify.py
Created July 3, 2012 14:05
Python function to create hash tags from various inputs.
import re
import string as s
def tagify(*args, **kwargs):
r'''Turns the argument strings into tags. so 'my tag' becomes '#MyTag'
Any keyword arguments become tags with values.
>>> tagify('hi there')
['#HiThere']
def dispatch_hook(key, hooks, hook_data):
"""Dispatches a hook dictionary on a given piece of data."""
hooks = hooks or dict()
if key in hooks:
hooks = hooks.get(key)
if hasattr(hooks, '__call__'):
hooks = [hooks]
@deontologician
deontologician / reltime.py
Created August 28, 2012 20:34
Relative datetimes in python
def reltime(date, compare_to=None, at='@'):
r'''Takes a datetime and returns a relative representation of the
time.
:param date: The date to render relatively
:param compare_to: what to compare the date to. Defaults to datetime.now()
:param at: date/time separator. defaults to "@". "at" is also reasonable.
>>> from datetime import datetime, timedelta
>>> today = datetime(2050, 9, 2, 15, 00)
>>> earlier = datetime(2050, 9, 2, 12)
@deontologician
deontologician / PKGBUILD
Created September 7, 2012 18:55
PKGBUILD for openconnect-git
# Contributor: dschauer, Dwight Schauer <[email protected]>
pkgname=openconnect-git
pkgver=20120907
pkgrel=1
pkgdesc="VPN client (intended to be) compatible with Cisco AnyConnect"
arch=(i686 x86_64)
url="http://git.infradead.org/users/dwmw2/openconnect.git"
license=('LGPL')
groups=()
depends=()
@deontologician
deontologician / test_parse_link_headers.py
Created December 2, 2012 23:42
E2E test for link header parsing in requests
@deontologician
deontologician / fetch_iana_link_relations.py
Created May 24, 2013 22:46
Grabs currently registered link relations from iana.org