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 DeclarativeFieldsMetaclass(type): | |
""" | |
Metaclass that converts Field attributes to a dictionary called | |
'base_fields', taking into account parent class 'base_fields' as well. | |
""" | |
def __new__(cls, name, bases, attrs): | |
attrs['base_fields'] = get_declared_fields(bases, attrs) | |
new_class = super(DeclarativeFieldsMetaclass, | |
cls).__new__(cls, name, bases, attrs) | |
if 'media' not in attrs: |
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 | |
import urllib, simplejson | |
def is_github_project(href): | |
"Quick and dirty way to find if a link is a github project" | |
if href.startswith("http://github.com") and len(href.split("/")) == 5: | |
return True | |
return False | |
def get_popular_projects(): |
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
shabda@jazzy ~> python repopular_project.py | |
set(['http://github.com/Sutto/barista', 'http://github.com/alunny/sleight', 'http://github.com/pypy/pypy', 'http://github.com/jacksonh/manos-spark', 'http://github.com/dysinger/apparatus', 'http://github.com/Yelp/mrjob', 'http://github.com/videlalvaro/Thumper']) | |
shabda@jazzy ~> |
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
// Reusable extension for jQuery so that we can hide jQuery objects | |
// and hide them. We will show an arrow at the top-right corner which | |
// will toggle the display of these. | |
// Examples: | |
// | |
// For github.com.js: | |
// $("#header").toggleStuff(); | |
// | |
// Some random site: | |
// $("#report_attachment").parent().next().toggleStuff() |
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
$.fn.toggleStuff = -> | |
$this = $(this) | |
anchorCss = | |
position: 'fixed' | |
top: '30px' | |
right: '10px' | |
'z-index': '999' | |
'font-size': '30px' | |
'font-weight': 'bold' | |
'text-decoration': 'none' |
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
DATABASES = { | |
'default': { | |
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. | |
'NAME': 'bpcle.db', # Or path to database file if using sqlite3. | |
'USER': '', # Not used with sqlite3. | |
'PASSWORD': '', # Not used with sqlite3. | |
'HOST': '', # Set to empty string for localhost. Not used with sqlite3. | |
'PORT': '', # Set to empty string for default. Not used with sqlite3. | |
'TEST NAME':'test_database.sqlite', | |
} |
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
not_found = -1 | |
import unittest | |
class TestBinS(unittest.TestCase): | |
def test_empty(self): | |
lst = [] | |
key = 0 | |
self.assertEquals(binsearch(lst, 0,), -1) | |
def test_equal(self): | |
lst = [10, 10, 10, 10] |
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
{ | |
"metadata": { | |
"name": "Versioning" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ |
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 random | |
import string | |
def random_word_from_seed(seed, len): | |
random.seed(seed) | |
letters = string.ascii_lowercase | |
return ''.join([random.choice(letters) for i in range(len)]) | |
print random_word_from_seed(1944062, 5) +" "+random_word_from_seed(2068527, 5) |
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
path = "./" #Override this | |
dropbox_dirs = set([el[:10] for el in os.listdir(".") | |
if os.path.join(path, el) and not el.startswith(".")]) | |
for el in dropbox_dirs: | |
if not os.path.exists(os.path.join(path, el)): | |
os.mkdir(os.path.join(path, el)) | |
os.system("mv %s*.* %s"%(os.path.join(path, el), os.path.join(path, el))) |
OlderNewer