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
In [112]: def find_prisms(): | |
...: found = set() | |
...: for a in range(1,10000): | |
...: for b in range(1,10000): | |
...: numerator = 2*a*b | |
...: denominator = a*b - 2*a - 2*b | |
...: if denominator > 0: | |
...: c = numerator/denominator | |
...: if c.is_integer(): | |
...: found.add(tuple(sorted((a,b,int(c))))) |
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 mechanize | |
import cookielib | |
from BeautifulSoup import BeautifulSoup | |
URL = 'http://leginfo.legislature.ca.gov/faces/codes.xhtml' | |
class Browser(object): | |
def __init__(self, section, code): | |
br = mechanize.Browser() | |
cj = cookielib.LWPCookieJar() |
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 ephem | |
def human_moon(observer): | |
target_date_utc = observer.date | |
target_date_local = ephem.localtime( target_date_utc ).date() | |
next_full = ephem.localtime( ephem.next_full_moon(target_date_utc) ).date() | |
next_new = ephem.localtime( ephem.next_new_moon(target_date_utc) ).date() | |
next_last_quarter = ephem.localtime( ephem.next_last_quarter_moon(target_date_utc) ).date() | |
next_first_quarter = ephem.localtime( ephem.next_first_quarter_moon(target_date_utc) ).date() | |
previous_full = ephem.localtime( ephem.previous_full_moon(target_date_utc) ).date() |
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 facebook | |
import webbrowser | |
import time | |
import sys | |
import os | |
FACEBOOK_TOKEN = '<YOUR-FACEBOOK-TOKEN>' | |
OBJECT_ID = '<YOUR-OBJECT-ID>' | |
api = facebook.GraphAPI(FACEBOOK_TOKEN) |
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
In [62]: run ncjulator | |
NUMBER OF VOTES = 308 | |
=============== | |
9.1 ---> 28 | |
34.4 ---> 106 | |
3.2 ---> 10 | |
6.8 ---> 21 |
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 __future__ import division | |
from decimal import Decimal | |
import time | |
TARGETS = set([ | |
float(34.4), | |
float(9.1), | |
float(6.8), | |
float(3.2), | |
]) |
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
# Great circle distance calculations between selected Asian ports and selected ports on the West Coast of | |
# the Americas. | |
# | |
# Using GeoDjango ORM to interact with PostGIS geography columns. | |
# | |
# https://docs.djangoproject.com/en/dev/ref/contrib/gis/ | |
# http://postgis.refractions.net/docs/ch04.html#PostGIS_Geography |
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
class Foo(models.Model): | |
bar = models.CharField(max_length=50) | |
def __init__(self, *args, **kwargs): | |
self.bar_initial = self.bar | |
super(Foo, self).__init__(*args, **kwargs) | |
def save(self, *args, **kwargs): | |
if self.bar == self.bar_initial: | |
do_stuff() |
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 standalone Python script to utterly refute some wide-circulation bullshit that is currently softening many minds. | |
""" | |
import datetime | |
i = 1900 | |
j = 2100 | |
valid = [] |
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
var redis = require("redis"), | |
client1 = redis.createClient(), | |
client2 = redis.createClient(), | |
client3 = redis.createClient(), | |
client4 = redis.createClient(), | |
msg_count = 0; | |
redis.debug_mode = false; | |
client1.on("psubscribe", function (pattern, count) { |
NewerOlder