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 pretty_axes(ax): | |
"""ax is a matplotlib axis instance.""" | |
ax.spines['left'].set_position('zero') | |
ax.spines['bottom'].set_position('zero') | |
ax.spines['right'].set_visible(False) | |
ax.spines['top'].set_visible(False) | |
for tick in ax.xaxis.get_major_ticks(): | |
tick.tick2On = False | |
for tick in ax.yaxis.get_major_ticks(): | |
tick.tick2On = False |
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 pylab | |
sigma=.1 | |
pylab.figure(figsize=(12,3)) | |
r = pylab.randn(1000000)*sigma | |
pylab.hist(r,bins=200,range=[-3,3],normed=True, align='mid',histtype='stepfilled',color='gray') | |
x = pylab.linspace(-3,3,200) | |
y = (1./(2*pylab.pi*sigma**2)**.5)*pylab.exp(-x**2/(2*sigma**2)) | |
pylab.plot(x,y,'k') | |
pylab.setp(pylab.gca(), xlim=[-3,3]) |
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 | |
## | |
# Diary service startup script | |
## | |
. /etc/rc.common | |
StartService () | |
{ |
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 | |
from multiprocessing import Process, Queue, Pipe | |
import sys | |
import time #For the timestamp and sleep function | |
if sys.platform == "win32": | |
# On Windows, the best timer is time.clock() | |
default_timer = time.clock | |
else: | |
# On most other platforms, the best timer is time.time() | |
default_timer = time.time |
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
/* | |
* QFileInfo.created() on POSIX systems (like Mac OS X) returns the last modified time[1]. | |
* This is annoying because on Mac OS X you know the system (e.g. finder) has access to the actual creation time. | |
* Turns out that BSD systems (like Mac OS X) have an extension to sys/stat.h that contains the file creation time[2]. | |
[1]: http://doc.qt.nokia.com/latest/qfileinfo.html#created | |
[2]: http://developer.apple.com/library/IOS/#documentation/System/Conceptual/ManPages_iPhoneOS/man2/stat.2.html | |
The recipe, then is (shown using the QT framework) | |
*/ |
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 flickrapi, urllib, os, argparse | |
parser = argparse.ArgumentParser(description='Grab favorites from a user') | |
parser.add_argument('-f', '--folder', help='Folder', default='./') | |
parser.add_argument('-n', '--number', help='Number', default=10) | |
parser.add_argument('-k', '--apikey', help='Api Key') | |
parser.add_argument('-s', '--apisecret', help='Api Secret') | |
parser.add_argument('-u', '--userid', help='User id') | |
args = parser.parse_args() |
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
#!python | |
"""pyboy4000 - your companion to the pipboy3000 for all your hacking needs. | |
Simply fireup pyboy, enter all the choice words, then, as you try a word in the | |
terminal during hacking, enter the number of correct letters for each word tried. | |
pyboy will do the thinking for you. It will tell you if it has found a match, or | |
it will suggest the next word to try. | |
The algorithm used is as follows: | |
Keep a list of candidate words. In the beginning this is the whole list. |
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 pandas as pd, pylab | |
idx = pd.MultiIndex.from_tuples([('a','x'),('a','y'),('b','x'),('b','y')]) | |
col = pd.MultiIndex.from_tuples([('c1',0),('c1',1),('c2',0)],names=['f','s']) | |
dat = pylab.randn(len(idx),len(col)) | |
df1 = pd.DataFrame(dat, index=idx, columns=col) |
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
On production machine | |
--------------------- | |
mkdir wm.git | |
mkdir wm | |
cd wm.git | |
git init --bare | |
create a file: hooks/post-recieve |
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 subprocess import Popen, PIPE | |
import argparse, time | |
def execute(n): | |
p = Popen(['python', 'test.py', '-n', str(n)], stdin=PIPE, stdout=PIPE, stderr=PIPE) | |
p.wait() | |
return p.stdout.read().splitlines() | |
def execute_long(n): | |
with open('query.txt','w') as stdout: |
OlderNewer