Skip to content

Instantly share code, notes, and snippets.

anonymous
anonymous / bootstrap.sh
Created June 2, 2011 17:19
Django on Heroku with Celery and Sentry
virtualenv --no-site-packages .
source bin/activate
bin/pip install Django psycopg2 django-sentry
bin/pip freeze > requirements.txt
bin/django-admin.py startproject mysite
cat >.gitignore <<EOF
bin/
include/
lib/
EOF
@michaelt
michaelt / latex.template
Created June 9, 2011 21:23
Simple Pandoc default.latex with comments
%!TEX TS-program = xelatex
\documentclass[12pt]{scrartcl}
% The declaration of the document class:
% The second line here, i.e.
% \documentclass[12pt]{scrartcl}
% is a standard LaTeX document class declaration:
% we say what kind of document we are making in curly brackets,
% and specify any options in square brackets.
@sjl
sjl / markdown.vim
Created June 21, 2011 19:47 — forked from vim-voom/markdown.vim
Markdown folding for Vim
" folding for Markdown headers, both styles (atx- and setex-)
" http://daringfireball.net/projects/markdown/syntax#header
"
" this code can be placed in file
" $HOME/.vim/after/ftplugin/markdown.vim
func! Foldexpr_markdown(lnum)
let l1 = getline(a:lnum)
if l1 =~ '^\s*$'
@al3xandru
al3xandru / gist:1128606
Created August 5, 2011 21:51
nvALT Bookmarklet
javascript:(function({
var INSTAPAPER=true,w=window,d=document,pageSelectedTxt=w.getSelection?w.getSelection():(d.getSelection)?d.getSelection():(d.selection?d.selection.createRange().text:0),pageTitle=d.title,pageUri=w.location.href,tmplt="";
tmplt="From ["+pageTitle+"]("+pageUri+"):\n\n";
if(pageSelectedTxt!="") {
pageSelectedTxt=">%20"+pageSelectedTxt;
pageSelectedTxt=pageSelectedTxt.replace(/(\r\n|\n+|\r)/gm,"\n");
pageSelectedTxt=pageSelectedTxt.replace(/\n/g,"\n>%20\n>%20");
w.location.href="nvalt://make/?txt="+encodeURIComponent(tmplt+pageSelectedTxt)+"&title="+encodeURIComponent(pageTitle)
}
else {
@al3xandru
al3xandru / gist:1169583
Created August 24, 2011 23:31
OmniFocus Generalized Bookmarklet
javascript:(function(){
var enc=encodeURIComponent,
w=window,
frames=w.frames,
d=document,
tn=w.getSelection?w.getSelection():(d.getSelection)?d.getSelection():(d.selection?d.selection.createRange().text:0),
pu=w.location.href,
isGMail=w.location.host.match(/mail\.google\.com/),
tt=pt=d.title,
subjSpans=d.getElementsByClassName("hP"),i,url;
@andyfowler
andyfowler / .vimrc
Created September 5, 2011 18:08
Swap iTerm2 cursors in vim insert mode when using tmux
" tmux will only forward escape sequences to the terminal if surrounded by a DCS sequence
" http://sourceforge.net/mailarchive/forum.php?thread_name=AANLkTinkbdoZ8eNR1X2UobLTeww1jFrvfJxTMfKSq-L%2B%40mail.gmail.com&forum_name=tmux-users
if exists('$TMUX')
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
else
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
endif
curl -X GET 'http://localhost:9200/articles/_search?search_type=count&pretty=true' -d \
'{
"query" : {
"match_all" : {}
},
"facets" : {
"by_hour" : {
"range" : {
"key_script" : "doc[\"published_on\"].date.hourOfDay",
"value_script" : "1",
@karmi
karmi / publish_frequency_by_day_of_week.sh
Created September 26, 2011 16:31
Simple Publishing Frequency By Day Of The Week
HOST='http://localhost:9200'
INDEX='articles'
curl -s -X DELETE "$HOST/$INDEX" -o /dev/null
curl -s -X POST "$HOST/$INDEX/article" -d '{ "t" : "1", "published" : "2010-01-01T02:20:00" }' -o /dev/null # fri
curl -s -X POST "$HOST/$INDEX/article" -d '{ "t" : "2", "published" : "2010-01-02T02:20:00" }' -o /dev/null # sat
curl -s -X POST "$HOST/$INDEX/article" -d '{ "t" : "3", "published" : "2010-01-02T08:40:00" }' -o /dev/null # sat
curl -s -X POST "$HOST/$INDEX/article" -d '{ "t" : "4", "published" : "2010-01-03T08:10:00" }' -o /dev/null # sun
curl -s -X POST "$HOST/$INDEX/article" -d '{ "t" : "5", "published" : "2010-01-04T16:20:00" }' -o /dev/null # mon
curl -s -X POST "$HOST/$INDEX/article" -d '{ "t" : "6", "published" : "2010-01-04T16:40:00" }' -o /dev/null # mon
@mattb
mattb / gist:1244665
Created September 27, 2011 09:15
Top 100 ascii-only 2-shingles on Twitter sample for the last 6 hours. Source at https://github.com/mattb/Storm-Try/
in the: ************************************* (3765)
i love: *************************** (2781)
to be: ************************** (2637)
of the: ********************* (2150)
if you: ********************* (2150)
on the: ******************** (2081)
i just: ****************** (1838)
i was: ****************** (1829)
i don't: ****************** (1825)
i have: ****************** (1802)
@AdrienLemaire
AdrienLemaire / fab_coverage.py
Created October 19, 2011 06:04
fab coverage
""""
Required: fabric, django, coverage, django-coverage, termcolor
""""
from coverage.misc import CoverageException
from termcolor import colored
def coverage(html=1):
"""Run coverage tests with html output, or
or return only the coverage percentage::