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
""" | |
This code aims to override the username's regex of the Django admin panel to be | |
able to allow unicode usernames. | |
Just add this code to an app as admin.py and everything will be done. | |
""" | |
import re | |
from django import forms | |
from django.contrib import admin |
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
''' Partition a list into sublists whose sums don't exceed a maximum | |
using a First Fit Decreasing algorithm. | |
''' | |
class Bin(object): | |
''' Container for items that keeps a running sum ''' | |
def __init__(self): | |
self.items = [] | |
self.sum = 0 |
This file has been truncated, but you can view the full 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
#!/usr/bin/env python | |
# | |
# Hi There! | |
# You may be wondering what this giant blob of binary data here is, you might | |
# even be worried that we're up to something nefarious (good for you for being | |
# paranoid!). This is a base85 encoding of a zip file, this zip file contains | |
# an entire copy of pip. | |
# | |
# Pip is a thing that installs packages, pip itself is a package that someone | |
# might want to install, especially if they're looking to run this get-pip.py |
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 Node : | |
def __init__( self, data ) : | |
self.data = data | |
self.next = None | |
self.prev = None | |
class LinkedList : | |
def __init__( self ) : | |
self.head = 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
var myApp = angular.module('myApp', []); | |
myApp.directive('googleplace', function() { | |
return { | |
require: 'ngModel', | |
link: function(scope, element, attrs, model) { | |
var options = { | |
types: [], | |
componentRestrictions: {} | |
}; |
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
def traverse(o, tree_types=(list, tuple)): | |
if isinstance(o, tree_types): | |
for value in o: | |
for subvalue in traverse(value, tree_types): | |
yield subvalue | |
else: | |
yield o | |
data = [(1,1,(1,1,(1,"1"))),(1,1,1),(1,),1,(1,(1,("1",)))] | |
print list(traverse(data)) |
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 logging | |
import time | |
from celery import shared_task as orig_shared_task | |
def timeit(func): | |
"""A decorator used to log the function execution time.""" | |
logger = logging.getLogger('tasks') |
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
/* Useful celery config. | |
app = Celery('tasks', | |
broker='redis://localhost:6379', | |
backend='redis://localhost:6379') | |
app.conf.update( | |
CELERY_TASK_RESULT_EXPIRES=3600, | |
CELERY_QUEUES=( | |
Queue('default', routing_key='tasks.#'), |
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
""" | |
To run the script | |
s3_meta.py --access-key=AWS_ACCESS_KEY_ID | |
--secret-key=AWS_SECRET_ACCESS_KEY | |
--bucket-name=BUCKET_NAME | |
-d=METADATA | |
e.g. | |
python s3_meta.py --access_key=AKIAIOSFODNN7EXAMPLE --secret-key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY --bucket-name=test-bucket -d '{"Cache-Control": "max-age=3600"}' | |
""" |
OlderNewer