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
[IPKernelApp] ERROR | Exception in message handler: | |
Traceback (most recent call last): | |
File "/home/dean/.home/opt/jupyter/local/lib/python2.7/site-packages/IPython/kernel/zmq/kernelbase.py", line 213, in dispatch_shell | |
handler(stream, idents, msg) | |
File "/home/dean/.home/opt/jupyter/local/lib/python2.7/site-packages/IPython/kernel/zmq/kernelbase.py", line 362, in execute_request | |
user_expressions, allow_stdin) | |
File "/home/dean/.home/opt/jupyter/local/lib/python2.7/site-packages/metakernel/_metakernel.py", line 312, in do_execute | |
retval = self.do_execute_direct(code) | |
File "/home/dean/.home/opt/jupyter/lib/python2.7/site-packages/octave_kernel.py", line 76, in do_execute_direct | |
self._make_figs(plot_dir) |
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
import random | |
def noReplacementSimulation(numTrials): | |
''' | |
Runs numTrials trials of a Monte Carlo simulation | |
of drawing 3 balls out of a bucket containing | |
3 red and 3 green balls. Balls are not replaced once | |
drawn. Returns the a decimal - the fraction of times 3 | |
balls of the same color were drawn. | |
''' |
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
[Matrix] | |
definition-foreground = #d301ff | |
definition-fontStyle = bold | |
error-foreground = #000000 | |
string-background = #000000 | |
keyword-foreground = #ffbf00 | |
keyword-fontStyle = bold | |
normal-foreground = #00ff00 | |
comment-background = #000000 | |
hit-foreground = #ffffff |
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
import pythoncom, pyHook | |
def OnKeyboardEvent(event): | |
print 'MessageName:',event.MessageName | |
print 'Message:',event.Message | |
print 'Time:',event.Time | |
print 'Window:',event.Window | |
print 'WindowName:',event.WindowName | |
print 'Ascii:', event.Ascii, chr(event.Ascii) | |
print 'Key:', event.Key |
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 this in the .bashrc | |
cs () { | |
cd $1 | |
ls | |
} |
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
""" | |
HexByteConversion | |
Convert a byte string to it's hex representation for output or visa versa. | |
ByteToHex converts byte string "\xFF\xFE\x00\x01" to the string "FF FE 00 01" | |
HexToByte converts string "FF FE 00 01" to the byte string "\xFF\xFE\x00\x01" | |
""" | |
#------------------------------------------------------------------------------- |
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
def single_space(fileName): | |
""" | |
remove multiple spaces from a file | |
""" | |
input = open(fileName, 'r') | |
output = open('tmp.txt', 'w') | |
output.write(string.join(input.read().split())) | |
input.close() | |
output.close() | |
os.remove(fileName) |
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
def count(fileName, count_string): | |
""" | |
Count the occurrences of a string in a file | |
""" | |
count = 0 | |
input = open(fileName, 'r') | |
line = input.readline() | |
while line <> '': | |
if count_string in line: | |
count = count + 1 |
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
import os | |
def replace(fileName, sstr, rstr): | |
""" | |
replace sstr for rstr in a file | |
""" | |
input = open(fileName, 'r') | |
output = open('tmp.txt', 'w') | |
output.write(input.read().replace(sstr, rstr)) | |
input.close() |
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
import os, fnmatch | |
import os.path | |
def all_files(root, patterns='*', single_level=False, yield_folders=False): | |
""" | |
Examine a directroy, or an entire directroy tree rooted in a certain | |
directory. | |
""" | |
# Expande patterns from semicolon-seperated string to list | |
patterns = patterns.split(';') |
NewerOlder