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 inspect import getmembers | |
class BaseContainerElement(object): | |
""" | |
BaseContainerElement is a generic element for a container | |
Process is where the magic should take place. | |
""" | |
def process(self, **kwargs): | |
pass |
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
public static int contrast(int argb) { | |
double a = 1 - (0.299 * Color.red(argb) + 0.587 * Color.green(argb) + 0.144 * Color.blue(argb))/255; | |
int d = 0 ? a < 0.5 : 255; | |
return Color.argb(255, d, d, d); | |
} |
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 lxml.html import fromstring | |
from httplib import HTTPConnection | |
class Crawler(object): | |
max_depth = 2 | |
def __init__(self, href=None, depth=0): | |
if depth == self.max_depth: | |
return |
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
rm `find . -iname '*.coffee' | sed 's/coffee$/js/g'` |
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 fabric.api import lcd, local | |
from importlib import import_module | |
import sys | |
def makemessages(settings_module='settings'): | |
""" | |
Generates the *.po files for everything. | |
MAKE SURE YOU RUN collectstatic _BEFORE_ BUILDING THE PO FILES. |
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
# Manage | |
if [[ ! -a manage.py ]] then | |
print "Your location is bad and you should feel bad." | |
return | |
fi | |
local dir=`find . -name settings_local.py | perl -ne'/\/([A-Za-z0-9_]*)\/settings_local.py/ && print $1'` | |
if [[ -z dir ]] then | |
print "Local settings not found!" |
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
/** | |
* Generic loadData method. Any parameter that matches a column will | |
* have data loaded. | |
* @param resultSet The result set from the database query | |
* @throws IllegalAccessException The requested field couldn't be accessed | |
*/ | |
private void loadData(ResultSet resultSet) throws IllegalAccessException { | |
Field[] fields = getClass().getDeclaredFields(); | |
for (Field f : fields) { |
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
#include<stdio.h> | |
#include<stdlib.h> | |
#include<string.h> | |
#define NUL '\0' | |
struct Loop { | |
char *start; | |
char *end; | |
struct Loop *next; | |
}; |
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
class OAuth2TokenFromCredentials(OAuth2Token): | |
def __init__(self, credentials): | |
self.credentials = credentials | |
super(OAuth2TokenFromCredentials, self).__init__(None, None, None, None) | |
self.UpdateFromCredentials() | |
def UpdateFromCredentials(self): | |
self.client_id = self.credentials.client_id | |
self.client_secret = self.credentials.client_secret | |
self.user_agent = self.credentials.user_agent |
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
// Iterative with two matrix rows | |
function lev(left, right) { | |
// Degenerative Cases | |
if (left == right) return 0; | |
if (left.length == 0) return right.length; | |
if (right.length == 0) return left.length; | |
var vectorLength = right.length + 1; | |
var workVector0 = new Array(); |