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 xml.sax import ContentHandler, parseString | |
from datetime import datetime | |
class Parser(ContentHandler): | |
def __init__(self, block_name, attrs=None): | |
ContentHandler.__init__(self) | |
self._block_name = block_name | |
self._name = None | |
self._blocks = list() | |
self._current_block = None |
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 matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas | |
from matplotlib.figure import Figure | |
def plot_state_history(filename): | |
fname = filename | |
# get the values | |
# values = [0, 1, 0, 3, 0, 5 ...] | |
values = [float(i) for i in open(fname).readlines()[0].split()] | |
data = [values.count(i) for i in range(1, 6)] |
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 python | |
import os | |
import re | |
import sys | |
temp_filename = '/tmp/hook_file' | |
def _read_test_output(): | |
total_output = {} | |
command = "nosetests --with-coverage" |
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 mock | |
def returnList(items): | |
def func(): | |
for item in items: | |
yield item | |
yield mock.DEFAULT | |
generator = func() |
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
" NOTES: | |
" ^M must be replaced with <ctrl-v><ctrl-m> | |
" ^[ must be replace with <ctl-v><esc> | |
function! BreakParameters() | |
" move the start of the line and set a mark 'a' | |
normal ^ma | |
" get break the parameters onto their own line | |
normal f(a^M^[ | |
" replace the commas with linebreaks |
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
function! WriteParams() | |
python << endpython | |
import re | |
import vim | |
# get the function definition line | |
line = vim.eval("getline(line('.'))") | |
# get the number of spaces to add to the start of the line | |
num_spaces = 4 + len(line) - len(line.lstrip()) | |
# get the line number wher to do the insertion |
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
filetype off | |
call pathogen#helptags() | |
call pathogen#runtime_append_all_bundles() | |
filetype on | |
set nocompatible | |
set hidden | |
set t_Co=256 | |
" Indenting { |
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 | |
set -e | |
CURDIR=`pwd` | |
AUTHOR=$1 | |
FORMAT="%C(yellow)%h%Creset -%C(red)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset" | |
SINCE="15 months ago" | |
UNTIL="14 months ago" | |
DIRS=`find . -type d -name ".*git" -exec dirname {} \; | egrep -v "\w+/GazaroUtilities" | sed "s/^..//"` |
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 <<EOF | |
function cleanStackOverflow() { | |
$("#sidebar, #content, #mainbar, #question, #answers, div.post-text").css('width', '100%'); | |
} | |
EOF | |
autocmd DOMLoad stackoverflow.com -js cleanStackOverflow(); | |
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 add1(lst, val, n): | |
start, stop, step = 0, len(lst), 1 | |
cond = n == 0 | |
if n < 0: | |
start, stop = stop-1, start-1 | |
step = -1 | |
n = abs(n) | |
for idx in range(start, stop, step): |
OlderNewer