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 mechanize | |
import cookielib | |
# Browser | |
br = mechanize.Browser() | |
# Cookie Jar | |
cj = cookielib.LWPCookieJar() | |
br.set_cookiejar(cj) |
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 _Singleton(type): | |
_instances = {} | |
def __call__(cls, *args, **kwargs): | |
if cls not in cls._instances: | |
cls._instances[cls] = super(_Singleton, cls).__call__(*args, **kwargs) | |
return cls._instances[cls] | |
class Singleton(_Singleton('SingletonMeta', (object,), {})): pass |
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 MetaCommand(type): | |
def __new__(meta, name, bases, dct): | |
print '-----------------------------------' | |
print "Allocating memory for class", name | |
print meta | |
print bases | |
print dct | |
return super(MetaCommand, meta).__new__(meta, name, bases, dct) | |
def __init__(cls, name, bases, dct): | |
print '-----------------------------------' |
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
#!/bin/bash | |
mkdir -p /home/mshuff | |
chown mshuff:mshuff /home/mshuff | |
usermod -d /home/mshuff mshuff |
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 flattenObject = function(ob) { | |
var toReturn = {}; | |
for (var i in ob) { | |
if (!ob.hasOwnProperty(i)) continue; | |
if ((typeof ob[i]) == 'object') { | |
var flatObject = flattenObject(ob[i]); | |
for (var x in flatObject) { | |
if (!flatObject.hasOwnProperty(x)) continue; |
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
# Apache .htaccess | |
# angularjs pushstate (history) support: | |
# See http://www.josscrowcroft.com/2012/code/htaccess-for-html5-history-pushstate-url-routing/ | |
<ifModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteCond %{REQUEST_URI} !index | |
RewriteRule (.*) index.html [L] |
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
console.oldLog = console.log; | |
console.log = function(value) { | |
console.oldLog(value); | |
window.$log = value; | |
}; |
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 python2.6 | |
#http://stackoverflow.com/questions/406121/flattening-a-shallow-list-in-python/408281#408281 | |
"""Usage: %prog item_count""" | |
from __future__ import print_function | |
import collections | |
import itertools | |
import operator | |
from timeit import Timer |
NewerOlder