This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys, string | |
from xml.sax import saxutils, handler, make_parser | |
class ContentGenerator(handler.ContentHandler): | |
def __init__(self, out = sys.stdout): | |
handler.ContentHandler.__init__(self) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A brute force way to find the Kember Identity. | |
# By Mac, @veryhappythings, on a boring afternoon. | |
# If you want, you can run it with the last attempt as an argument and it'll start there. | |
import hashlib | |
import sys | |
def iterative(): | |
last_attempt = len(sys.argv) > 1 and int(sys.argv[1]) or 0 | |
try: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import sys | |
try: | |
sys.stdout.write('%.2f' % ((float(os.environ.get('TM_SELECTED_TEXT')) / 1.175) * 1.15)) | |
except: | |
sys.stdout.write(os.environ.get('TM_SELECTED_TEXT')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RED="\[\033[0;31m\]" | |
YELLOW="\[\033[0;33m\]" | |
GREEN="\[\033[0;32m\]" | |
BLUE="\[\033[0;34m\]" | |
LIGHT_RED="\[\033[1;31m\]" | |
LIGHT_GREEN="\[\033[1;32m\]" | |
WHITE="\[\033[1;37m\]" | |
LIGHT_GRAY="\[\033[0;37m\]" | |
COLOR_NONE="\[\e[0m\]" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ruby search_twitter.rb <username> <search string> | |
require 'rubygems' | |
require 'twitter' | |
Twitter::Search.new(ARGV[1]).from(ARGV[0]).each { |r| puts '--------------------------------', r.text } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://www.pomodorotechnique.com/ | |
Shoes.app :width => 200, :height => 150, :resizable => false, :title => 'Pomo!' do | |
def update_time! | |
@timer_display.text = '%02d:%02d' % [@seconds / 60, @seconds % 60] | |
end | |
background whitesmoke | |
paused = true | |
@seconds = 0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from operator import itemgetter | |
files = { | |
'first' : {'filename': 'first.xml', 'priority': 0}, | |
'second': {'filename': 'second.xml', 'priority': 4}, | |
'third' : {'filename': 'third.xml', 'priority': 0}, | |
'fourth': {'filename': 'fourth.xml', 'priority': 3}, | |
'fifth' : {'filename': 'fifth.xml', 'priority': 6}, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'twitter' | |
HEALTHII_TAG_REGEX = /#healthii\((\d{4}):?(.*)?\)/ | |
BUSYNESS, STRESS, HEALTH, ENGAGEMENT = 0, 1, 2, 3 | |
def mean(numbers) | |
numbers.inject {|sum, n| sum + n } / numbers.length.to_f | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import json | |
import os | |
import pprint | |
import sys | |
input = os.environ.get('TM_SELECTED_TEXT') | |
input = input.replace("'", '"') | |
sys.stdout.write(pprint.pformat(json.loads(input))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Maybe I'm missing the point, but coming from a bit of | |
# rails experience I find that it's a pain that views | |
# have to be told which template to render to. | |
# This method is a way, but probably not the right way, | |
# to derive a template name from an object. | |
# It expects to be called from a view, by the way. | |
import inspect | |
def template_for(obj, content_type='html'): | |
return '{app}/{obj}_{func_name}.{content_type}'.format(app=obj._meta.app_label, |
OlderNewer