This file contains hidden or 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 | |
""" | |
code slightly adapted from http://www.amazon.com/Programming-Collective-Intelligence-Building-Applications/dp/0596529325 | |
""" | |
import random | |
from math import sqrt |
This file contains hidden or 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
package main | |
import ( | |
"json"; | |
"fmt"; | |
"strconv"; | |
"bufio"; | |
"os"; | |
"flag"; | |
) |
This file contains hidden or 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
# https://github.com/attractivechaos/plb/blob/master/sudoku/incoming/sudoku-bb.py | |
# Boris Borcic 2006 | |
# Quick and concise Python 2.5 sudoku solver | |
# | |
w2q = [[n/9,n/81*9+n%9+81,n%81+162,n%9*9+n/243*3+n/27%3+243] for n in range(729)] | |
q2w = (z[1] for z in sorted((x,y) for y,s in enumerate(w2q) for x in s)) | |
q2w = map(set,zip(*9*[q2w])) | |
w2q2w = [set(w for q in qL for w in q2w[q]) for qL in w2q] |
This file contains hidden or 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 sys | |
from math import sqrt | |
from random import random | |
""" | |
Naive python translation of https://gist.github.com/995804 | |
Public domain. | |
""" |
This file contains hidden or 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', 'a', 1.0) | |
('a', 'u', 0.70833333333333337) | |
('a', 'n', 0.69565217391304346) | |
('a', 'e', 0.68181818181818177) | |
('a', 'z', 0.65000000000000002) | |
('a', 'o', 0.625) | |
('a', 'x', 0.61904761904761907) | |
('a', 'p', 0.6071428571428571) | |
('a', 'q', 0.55172413793103448) | |
('a', 'c', 0.54166666666666663) |
This file contains hidden or 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 random | |
import re | |
""" | |
username,following_count,followers_count,question_answered,questions_asked,registered_days_ago,spam | |
""" | |
data = [ | |
('pims',44,61,225,50,200,0), | |
('joe1234',350,1,0,200,50,1), |
This file contains hidden or 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.fsguy.com/2010-08-24_how-to-download-stock-quotes-from-google-finance-with-fsharp | |
/// Objectives: | |
/// - It should work asynchronously | |
/// - The executing thread shouldn’t be blocked during download so we could run this operation even on a UI thread without locking it | |
/// - Stock quotes should be downloaded in parallel | |
/// - But no more than 5 download streams at any particular moment in time | |
/// - Downloaded quotes should be parsed in parallel | |
/// - In order to utilize the available hardware resources efficiently | |
/// - Log actions & exceptions |
This file contains hidden or 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 : http://amix.dk/blog/post/19592 | |
""" | |
from redis_wrap import * | |
#--- Edges ---------------------------------------------- | |
def add_edge(from_node, to_node, system='default'): | |
edges = get_set( from_node, system=system ) | |
edges.add( to_node ) |
This file contains hidden or 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 : http://stackoverflow.com/questions/101742/how-do-you-access-an-authenticated-google-app-engine-service-from-a-non-web-pyt | |
""" | |
import os | |
import urllib | |
import urllib2 | |
import cookielib | |
users_email_address = "[email protected]" | |
users_password = "billybobspassword" |
This file contains hidden or 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 | |
# http://blog.notdot.net/2009/9/Efficient-model-memcaching | |
from google.appengine.api import memcache | |
from google.appengine.ext import db | |
def serialize_entities(models): | |
if models is None: | |
return None |