Skip to content

Instantly share code, notes, and snippets.

View JT5D's full-sized avatar
💭
Multiversing...

JT5D JT5D

💭
Multiversing...
View GitHub Profile
#!/usr/bin/env python
# encoding: utf-8
from __future__ import division, with_statement
import sys
class Foo(object):
def bar(self, counter=[0]):
counter[0] += 1
print("Counter is %i" % counter[0])
@jeremyBanks
jeremyBanks / numberwords.py
Created November 23, 2008 06:52
[2010-01] i meant to code golf numbers to words but failed
#!/usr/bin/env python
# encoding: utf-8
from __future__ import division, with_statement
import sys
# http://stackoverflow.com/questions/309884/code-golf-number-to-words
# http://en.wikipedia.org/wiki/Long_and_short_scales
"""Converts numbers to words using the English short scale."""
/*
=skin=
@name Default
@author Yatrik Solanki
@homepage http://www.yatriksolanki.com
@email [email protected]
@license MPL/LGPL/GPL
=/skin=
*/
@blech
blech / fetch-vox-post-xml.pl
Last active August 29, 2015 20:44
Fetch a Vox post as XML
#!/usr/bin/perl
use strict;
use warnings;
no warnings 'redefine';
use XML::Atom::Client;
use XML::XPath;
my $username = 'email-address-here';
size(520, 500)
from math import pi
data = [
#Pattern,expedia.com,hotel-guides.us,travel.yahoo.com,travelocity.com,tripadvisor.com
['[x] hotel',0.02154,0.00903,0.35186,0.16603,0.45155],
['[x] hotel [x]',0.00000,0.00000,0.14872,0.26750,0.58378],
['[x] inn [x]',0.03185,0.00000,0.00000,0.24957,0.71859],
['hotel [x]',0.01385,0.02769,0.31154,0.23692,0.41000],
['hotel in [x]',0.03216,0.00000,0.53631,0.19191,0.23963],
size(520, 500)
from math import pi
data = [
#Pattern,expedia.com,hotel-guides.us,travel.yahoo.com,travelocity.com,tripadvisor.com
['[x] hotel',0.02154,0.00903,0.35186,0.16603,0.45155],
['[x] hotel [x]',0.00000,0.00000,0.14872,0.26750,0.58378],
['[x] inn [x]',0.03185,0.00000,0.00000,0.24957,0.71859],
['hotel [x]',0.01385,0.02769,0.31154,0.23692,0.41000],
['hotel in [x]',0.03216,0.00000,0.53631,0.19191,0.23963],
var Expr = Sizzle.selectors = {
order: [ "ID", "NAME", "TAG" ],
match: {
ID: /#((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,
CLASS: /\.((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,
NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF_-]|\\.)+)['"]*\]/,
ATTR: /\[\s*((?:[\w\u00c0-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,
TAG: /^((?:[\w\u00c0-\uFFFF\*_-]|\\.)+)/,
CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,
POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,
@jeremyBanks
jeremyBanks / somesort.py
Created February 5, 2009 16:07
[2010-01] some shitty sort? don't remember what this was for.
#!/usr/bin/env python
# encoding: utf-8
from __future__ import division, with_statement
import sys
import random
def somesort(data):
"""A dumb n**2 sort."""
data = list(data)
result = list()
@jeremyBanks
jeremyBanks / mptesting.py
Created February 10, 2009 23:41
[2010-01] i was testing out the multiprocessing module
#!/usr/bin/env python3.0
import sys
import multiprocessing
def process(function, name=None):
"""Decorates a into spawning a new process. Yay clarity."""
def decorated(*args, *kwargs):
p = multiprocessing.Process(target=function, name=name, args=args, kwargs=kwargs)
p.start()
@blech
blech / music-tunnel
Created February 13, 2009 13:41
SSH tunnel w/Rendezvous
# posted partly as an aide-memoire, but more usefully, as a prompt
# for me to make this into a proper stop-start daemon
# hopefully, one that won't have hardcoded machine names...
IPADDR=`ifconfig en0 | grep 'inet ' | awk '{print $2}' | sed 's/addr://'`
ssh house.husk.org -N -f -L *:3698:foil:3689
dns-sd -P "foil" _daap._tcp. local 3698 foil.local. $IPADDR txtvers=1 "Database ID=BC2C8AD5" "Machine ID=BC2C8AD5" &