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
$('.delete-item-link').click(function(event) { | |
event.preventDefault(); | |
var a = this; | |
$('#delete-dialog-confirm').dialog({resizable: false, | |
height:220, | |
modal: true, | |
buttons: { | |
"Delete": function() { | |
$.post(window.location.pathname+a.id+'/delete/', {csrfmiddlewaretoken:csrf}, function(data) { | |
$('#row-'+a.id).hide(); |
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 hashlib | |
class DHT(object): | |
def __init__(self): | |
self.hashes = set() | |
def nodes(self,hash): | |
hash_int = long(hash,16) | |
closeness = {} | |
for v in self.hashes: |
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 os.path | |
import random | |
class RandomLines(object): | |
def __init__(self, input_file, cache_index=True): | |
if isinstance(input_file, basestring): | |
self.source_file = open(input_file,'rb') | |
filename = input_file | |
else: | |
self.source_file = input_file |
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 functools import partial | |
import time | |
def coroutine(func): | |
def start(*args,**kwargs): | |
cr = func(*args,**kwargs) | |
cr.next() | |
return cr | |
return start |
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 web | |
import time | |
seen = set() | |
while True: | |
page = web.grab('http://www.reddit.com') | |
if page: | |
threads = set(page.xpath('//p[@class="title"]/a/@href||//p[@class="title"]/a/text()')) | |
new_threads = threads - seen |
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
try: | |
date, job_id = open('job_counter.txt').read().split(',') | |
job_id = int(job_id) + 1 | |
if date != str(datetime.date.today()): | |
job_id = 1 | |
except: | |
job_id = 1 | |
open('job_counter.txt', 'w').write('{date},{job_id}'.format(date=datetime.date.today(), job_id=job_id)) |
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 flask import Flask | |
from flask.ext.classy import FlaskView | |
# we'll make a list to hold some quotes for our app | |
quotes = [ | |
"A noble spirit embiggens the smallest man! ~ Jebediah Springfield", | |
"If there is a way to do it better... find it. ~ Thomas Edison", | |
"No one knows what he can do till he tries. ~ Publilius Syrus" | |
] |
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 flask import Flask, url_for | |
from flask.ext.classy import FlaskView | |
# we'll make a list to hold some quotes for our app | |
quotes = [ | |
"A noble spirit embiggens the smallest man! ~ Jebediah Springfield", | |
"If there is a way to do it better... find it. ~ Thomas Edison", | |
"No one knows what he can do till he tries. ~ Publilius Syrus" | |
] |
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 urlparse | |
import collections | |
def tree(): | |
return collections.defaultdict(tree) | |
urls = (l.strip() for l in open('urls.txt') if len(l.strip())) | |
data = tree() | |
for url in urls: |
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 urlparse | |
import collections | |
urls = (l.strip() for l in open('urls.txt') if len(l.strip())) | |
data = collections.defaultdict(set) | |
for url in urls: | |
domain = urlparse.urlparse(url).netloc | |
data[domain].add(url) |
OlderNewer