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
function defaultdict(default) { | |
this._default = default; | |
}; | |
defaultdict.prototype = { | |
get: function(key) { | |
if (!key in this) { this[key] = this._default(key); } | |
return this[key]; | |
} | |
} | |
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 re | |
import string | |
import readline | |
import textwrap | |
from yahoo.search.web import WebSearch | |
APP_ID = "IRCTriviaHelper" | |
def bullet(lines): | |
return ["\n".join(textwrap.wrap(line, 77, initial_indent=" - ", subsequent_indent=" ")) for line in lines] |
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 | |
import os.path | |
import socket | |
import subprocess | |
from urlparse import urlparse, ParseResult | |
from optparse import OptionParser | |
BUF_SIZE = 1024 | |
DEFAULT_IMCS_PORT = 3589 | |
VERBOSE = False |
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 | |
import random | |
import re | |
import time | |
from twisted.words.protocols import irc | |
from twisted.internet import reactor, protocol, ssl | |
from twisted.python import log | |
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
from drizzle import libdrizzle as _libdrizzle | |
libdrizzle = _libdrizzle.Drizzle() | |
def connect(*args, **kwargs): | |
connection = Connection(*args, **kwargs) | |
connection._connect() | |
return connection | |
class Connection: |
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 | |
from __future__ import print_function | |
import sys | |
import os, os.path | |
import shutil | |
import optparse | |
import re | |
comment_ignore_re = re.compile(r"#!.+") |
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
def _iter_driver_output(self): | |
while self.driver_stack: | |
curdriver = self.driver | |
# Iterate over the current driver until it changes. | |
for output in curdriver.get_input(): | |
yield output | |
# If the driver has changed, stop iterating over the old one. | |
if self.driver is not curdriver: | |
break |
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
# <snip> | |
for line in f: | |
m = LOG_RE.match(line) | |
if m: | |
when = time.mktime(time.strptime(m.group("when"), "%d-%m-%Y %H:%M:%S")) | |
# Bwahahahaha. | |
_time = time.time | |
time.time = lambda: when |
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 time | |
from urllib2 import urlopen, quote | |
import json | |
def fetch_comments(after=None): | |
url = "http://reddit.com/comments.json" | |
if after: | |
url += "?after={0}".format(quote(after)) | |
#print "... Fetching {0} ...".format(url) |
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
mgood@capstone11 ~/D/c/b/boots.mgood> boots -H capstonedd -l python | |
Boots (v0.2.0) | |
capstonedd:3306 (server v2009.11.1220) | |
> from boots.api import constructors | |
> @constructors.register('reverse') | |
+ def reverse(): | |
+ from boots.api.nodes.node import SyncNode | |
+ from boots.api.api import Rows | |
+ def reverse_data(data): | |
+ return Rows((("".join(reversed(field)) if isinstance(field,basestring) else field |
OlderNewer