Skip to content

Instantly share code, notes, and snippets.

@rpietro
rpietro / legenda_Cine_Holliudy.srt
Created January 20, 2014 05:44
legenda cine holliudy
1
00:03:59,000 --> 00:04:01,037
ÉÉÉgua, pai!
Essa história é muito joiada!
2
00:04:01,302 --> 00:04:03,707
E os ninjas eram mais invocados
do que corrida de pato!
@rpietro
rpietro / grep_hack.md
Created January 17, 2014 19:06
useful grep commands

to recursively find a string in multiple files under a directory

grep -R 'string' directory

to recursively find a string in multiple files under a directory and then replace the string with something else

grep -R 'string1' directory | xargs sed -i 's/string1/string2/g'

@rpietro
rpietro / eem_bayesian_cat.md
Created January 14, 2014 07:42
encapsulated experimental math for Bayesian CAT
@rpietro
rpietro / django_mako_hack.md
Created January 7, 2014 09:28
django mako hack

cd /Users/rpietro/anaconda/lib/python2.7/site-packages/django/bin python django-admin.py startproject website python manage.py startapp homepage rm views.py mkdir views touch views/init.py mkdir templates subl templates/test.html

@rpietro
rpietro / crafting_quality_code.md
Last active January 1, 2016 21:18
Crafting Quality Code

Crafting Quality Code

A few notes from Jennifer Campbell & Paul Gries' outstanding Coursera MOOC Crafting Quality Code

Recipe for designing functions

  1. examples
  2. type contract
  3. header
@rpietro
rpietro / latex_test.md
Created December 31, 2013 08:38
texting latex

\[a \in {x|P(x)} \]

\[\mathbb{Z} \]

@rpietro
rpietro / sage_algebra_calculus.py
Created December 29, 2013 19:00
algebra and calculus with sage
# script from http://goo.gl/7m0GGp
# Solving Equations Exactly
x = var('x')
solve(x^2 + 3*x + 2, x)
x, b, c = var('x b c')
solve([x^2 + b*x + c == 0],x)
x, y = var('x, y')
@rpietro
rpietro / sage_calculus.py
Created December 29, 2013 04:23
sage for calculus I, II and III
# source http://goo.gl/1zB4ee
# Calculus I
f(x)=x^3+1
f(2)
show(f)
lim(f,x=1)
lim((x^2-1)/(x-1),x=1)
lim(f,x=1,dir='-'); lim(f,x=1,dir='right'); f(1)
@rpietro
rpietro / nltk_hack_ch3.py
Created December 24, 2013 05:19
source code for chapter 3 of http://nltk.org/book
# code from http://nltk.org/book
from __future__ import division
import nltk, re, pprint
from urllib import urlopen
url = "http://www.gutenberg.org/files/2554/2554.txt" # crime and punishment
raw = urlopen(url).read()
type(raw)
len(raw)
@rpietro
rpietro / nltk_hack_ch1.py
Created December 23, 2013 20:57
source code for chapter 1 of http://nltk.org/book
# code from http://nltk.org/book
import nltk
# nltk.download() # just go ahead and download everything if you have space
from nltk.book import *
from __future__ import division
text1
text2
text1.concordance("monstrous")