Skip to content

Instantly share code, notes, and snippets.

View jrabbit's full-sized avatar
🍡

J Laxson jrabbit

🍡
View GitHub Profile
from urllib2 import urlopen
import simplejson as json
class Reddit:
def __init__(self):
self.url = 'http://www.reddit.com/user/%s/about.json'
def karma(self, phrase):
user = sys.argv[1]
raw = urlopen(self.url % phrase).read()
data = json.loads(raw)['data']
# Total of aliases known #
num_aliases = 0
# If True, Pyborg don't saves the dictionary and configuration on disk #
no_save = 'False'
# Total word contexts #
num_contexts = 22
# Words that can be ignored for the answer #
ignore_list = ['!.', '?.', "'", ',', ';']
# max limits in the number of words known #
max_words = 6000
@jrabbit
jrabbit / gist:468298
Created July 8, 2010 16:56
Keith Olbermann's closing simulator
import time
daynum=int(time.strftime('%j'))
year=int(time.strftime('%y'))
composite=(year*365)+daynum
def ordinal(n):
if 10 <= n % 100 < 20:
return str(n) + 'th'
else:
return str(n) + {1 : 'st', 2 : 'nd', 3 : 'rd'}.get(n % 10, "th")
#thanks http://stackoverflow.com/questions/739241/python-date-ordinal-output/739301#739301
import time
daynum=int(time.strftime('%j'))
year=int(time.strftime('%y'))
composite=(year*365)+daynum
# def ordinal(num):
# ldig = num % 10
# l2dig = ldig % 10
# if l2dig == 1:
# suffix = 'th'
# elif ldig == 1:
if e.eventtype() == "pubmsg":
for x in self.channels[target].users():
body = body.replace(x, "#nick")
print body
from pygooglechart import Chart
from pygooglechart import SimpleLineChart
from pygooglechart import Axis
from subprocess import *
import platform
max_y = 2000
# Chart size of 200x125 pixels and specifying the range for the Y axis
chart = SimpleLineChart(200, 125, y_range=[0, max_y])
# grep khash ~/.bitcoin/debug.log
@jrabbit
jrabbit / s
Created July 19, 2010 14:34
create a graph of your khash/s
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from pygooglechart import Chart
from pygooglechart import SimpleLineChart
from pygooglechart import Axis
from subprocess import *
import platform
import os
max_y = 2000
from BeautifulSoup import BeautifulSoup
import re
import urllib2
import urllib
import cookielib
def grab(user, passwd):
values = {'user' : user, 'passwd' : passwd}
url = 'http://www.reddit.com/login?dest=/prefs/friends/'
data = urllib.urlencode(values)
req = urllib2.Request(url, data)
from BeautifulSoup import BeautifulSoup
import re
import urllib2
import urllib
import cookielib
def grab(user, passwd):
values = {'user' : user, 'passwd' : passwd, 'dest' : "/prefs/friends/"}
url = 'http://www.reddit.com/post/login'
data = urllib.urlencode(values)
req = urllib2.Request(url, data)
#!/bin/bash
#
# azilink for OS X
# based on http://pastie.org/405289 but works with Tunnelblick only
# (no need to install a separate copy of OpenVPN2 from macports
# or building from source by hand, thankfully)
# Requires:
# - azilink running on android phone (http://code.google.com/p/azilink/)
# (run the app and check the box to start the service).
# - adb on system path (comes with the Android SDK;