Skip to content

Instantly share code, notes, and snippets.

@jtratner
jtratner / portmanteau_compare
Created June 5, 2012 16:46
Comparing portmanteau
My answer:
8588 function calls in 0.015 CPU seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 0.015 0.015 <string>:1(<module>)
1 0.000 0.000 0.000 0.000 __future__.py:48(<module>)
1 0.000 0.000 0.000 0.000 __future__.py:74(_Feature)
@jtratner
jtratner / example-source.rst
Created May 16, 2012 14:49
Jekyll-rst escapes pullquote html instead of passing it through
layout post
title Testing pullquotes
date 2012-05-16 09:11
author Jeffrey Tratner
comments true

So this is me, starting out.

@jtratner
jtratner / new-post.zsh
Created May 16, 2012 09:06
Create and edit an octopress post from anywhere (and avoid zsh globbing issues)
#!/bin/zsh
# export BLOG="/path/to/your/octopress/install"
# handles globbing weirdness with zsh + use it from anywhere
# use: new-post "This is my exciting new post!!!"
# set the blog variable to your octopress directory
# TODO: fix this so it handles double-titling
function new-post () {
@jtratner
jtratner / rest_to_markdown.vim
Created May 4, 2012 06:39
Checks your vim regexp escapes -- save yourself tons of hassle!
command! -range -nargs=* CheckRegexpEscapes :call CheckRegexpEscapes(<f-args>)
" call with either no arguments or a:1 for escape character +
" an argument for each character to be escaped
" e.g. CheckRegexpEscapes('\\','(',')','_') ->
" checks that you put in '\\' behind each of '(',')','_',')'
" and prompts you to change it
" always asks to substitute
function! CheckRegexpEscapes(...)
" NonEscapedCharRegexp:
@jtratner
jtratner / ipython-error
Created May 2, 2012 05:27
ipython_gtk error - no gdk backend found
$ python --colors=Linux --pylab=gtk
WARNING: Couldn't start log: [Errno 2] No such file or directory: u'$HOME/.ipython/ipython_logs/ipython_log.py'Python 2.7.2+ (default, Oct 4 2011, 20:03:08)
Type "copyright", "credits" or "license" for more information.
IPython 0.12 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
[TerminalIPythonApp] Error in enabling GUI event loop integration:
@jtratner
jtratner / makegraphs.py
Created May 2, 2012 01:34
DefaultColor(defaultdict)
matplotcolors= ['b','g','r','c','m','y','k']
defaultcolorlist = ["#00af64","#0b61a4","#ff9200","#ff4900","#9c02a7"]
defaultcolorlist.extend(matplotcolors)
from collections import defaultdict
class DefaultColor(defaultdict):
""" defaultdict that returns sequential elements of a list(if not specified, a color) each time it is
called Note that if input list is len(1) it will always return the same
value"""
def __init__(self,colorlst = defaultcolorlist):