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
# Memoize Example | |
class Pak(object): | |
# Do not use @staticmethod here | |
def memoize(key): | |
def decfunc(f): | |
def newfunc(self): | |
if not hasattr(self, key): | |
setattr(self, key, f(self)) |
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
-nbad -bap -nbc -bbo -hnl -br -brs -c33 -cd33 -ncdb -ce -ci4 -cli0 -d0 -di1 -nfc1 -i4 -ip0 -l80 -lp -npcs -nprs -npsl -sai -saf -saw -ncs -nsc -sob -nfca -cp33 -ss -ts8000 |
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
https://bitbucket.org/etienned/sphinx-autopackage-script/src/7199e9725789/generate_modules.py | |
Example usage: | |
./generate_modules.py ~/path/to/some/package -d ~/dest/path/ |
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
# Compile and Exec test | |
# Just making sure that exec deals with scoping correctly | |
# | |
# Note that the compile statement compiles code into bytecode, but does not execute it | |
# Reference: http://lucumr.pocoo.org/2011/2/1/exec-in-python/ | |
def pakrox2(): | |
print "pakrox2 external" | |
code = "" |
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
# Using @property | |
class Pakrox(object): | |
def __init__(self): | |
self._pak = 10 | |
@property | |
def pak(self): | |
return self._pak |
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 re | |
def underscore(text): | |
def repl(m): | |
return "_" + m.group(0).lower() | |
return re.sub(r"([A-Z])", repl, text) | |
print underscore("helloWorld") |
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
javascript: var script = document.createElement("script"); script.src="http://www.example.com/random.js"; document.body.appendChild(script); void(0); |
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 multiprocessing import Pool, JoinableQueue, Manager | |
# Note that jqueue.task_done() must be called to decrement the count if jqueue.join() is to be used correctly. | |
import time, os, signal | |
def handler(signum, frame): | |
print "signal caught in %d" % os.getpid() | |
signal.signal(signal.SIGTERM, handler) |
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
# Tips from http://t2.unl.edu/documentation/graphtool/new-install | |
mkdir ~/eggs | |
export PYTHONPATH=$PYTHONPATH:~/eggs | |
export PATH=$PATH:~/eggs | |
# echo "export PYTHONPATH=$PYTHONPATH:~/eggs" >> ~/.bashrc | |
# echo "export PATH=$PATH:~/eggs" >> ~/.bashrc | |
curl -O http://peak.telecommunity.com/dist/ez_setup.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
#!/bin/sh | |
rmiregistry & | |
java EventManager & | |
echo "Started EM" | |
clean_up() | |
{ | |
pkill rmiregistry |
OlderNewer