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
(when (>= emacs-major-version 24) | |
(require 'package) | |
(package-initialize) | |
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/") | |
("marmalade" . "http://marmalade-repo.org/packages/") | |
("melpa" . "http://melpa.milkbox.net/packages/") | |
) | |
) | |
) |
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
# via here: http://stackoverflow.com/questions/5442910/python-multiprocessing-pool-map-for-multiple-arguments | |
from multiprocessing import Process, Pipe | |
from itertools import izip | |
def spawn(f): | |
def fun(pipe,x): | |
pipe.send(f(x)) | |
pipe.close() | |
return fun |
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
# top 5 with respect to total | |
head(df[with(df, order(-total)),]) | |
# RSiteSearch("whatever") | |
`%nin%` <- Negate(`%in%`) |
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
`%nin%` <- Negate(`%in%`) |
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 itertools import groupby, islice | |
from operator import itemgetter | |
from pprint import pprint | |
>>> gb = groupby(sorted(xrange(0,11),key=iseven),iseven) | |
>>> [','.join(map(str,k)) for g,k in gb] | |
['1,3,5,7,9', '0,2,4,6,8,10'] | |
>>> sent = "This is a long sentence where I want to group words of similar length using the python groupby function" | |
>>> gb = groupby(sorted(sent.split(),key=len),len) |
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
> db.coll.aggregate( [ { $group : {_id:0, minS : {$min: "$variabletomin"}, maxS : {$max : "$variabletomax"} } } ] ) |
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 pandas | |
import numpy as np | |
import string | |
import random | |
import matplotlib.pyplot as plt | |
from pandas import DataFrame | |
#import statsmodels.formula.api as sm | |
df = DataFrame(np.random.randn(10,3)) | |
df['3'] = random.sample(string.letters,10) |
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
# https://launchpad.net/~gezakovacs/+archive/pdfocr | |
pdfocr -i "$file" -o /tmp/tmp.pdf | |
pdftotext /tmp/tmp.pdf "`basename "$file" .pdf`.txt" |
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
lambda x: 'c({})'.format(x).replace("[","").replace("]","") |
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
mylist = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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