Skip to content

Instantly share code, notes, and snippets.

@jassinm
jassinm / pdf decrypt
Created March 15, 2012 14:52
decrypt pdf
qpdf --decrypt <encrypted.pdf> <output.pdf>
@jassinm
jassinm / pyprofling
Created March 21, 2012 19:29
python profiling
python -m cProfile -o rep.prof <script.py>
python -c 'import pstats; p=pstats.Stats('rep.prof'); p.sort_stats('cumulative').print stats(10)'
import os
import pymongo
import gridfs
from test import sanitize, size_chunks, CsvChunkReader
import multiprocessing as mp
import csv
mongo_conn = pymongo.Connection()
mongo_db = mongo_conn['test']
docs = mongo_db['docs']
(defn send_multipart [socket iter]
(map mq/send-more (repeat socket) (pop iter))
(mq/send socket (last iter)))
@jassinm
jassinm / helpers.py
Created June 6, 2012 21:01
dumps a json including dates
dthandler = lambda obj: obj.isoformat() if isinstance(obj, datetime.datetime) else None
def jsonify(data):
return Response(json.dumps(data, default=dthandler))
@jassinm
jassinm / mongocleanup.py
Created June 15, 2012 14:53
Clean's up a nested structure for mongo
import re
def mongo_cleanup(item, replacement=''):
"""clean's a nested structure keys to adapt to mongodb's
legal keys
see http://www.mongodb.org/display/DOCS/Legal+Key+Names """
if hasattr(item, 'items'):
newdict = {}
for key, value in item.items():
nkey = key
@jassinm
jassinm / gist:3200136
Created July 29, 2012 16:44
scipy , numpy , matplotlib on clean install mac osx 10.8 mountain lion
brew install python
easy_install pip
#install scipy use temp branch
pip install git+https://github.com/minrk/scipy-1.git@accelerate
#ft2build.h not found ==>
pip install git+git://github.com/matplotlib/matplotlib.git
xen-create-image --hostname ubuntu.dev --size=30G --swap=1G --dhcp --memory=8192Mb --mirror=http://archive.ubuntu.com/ubuntu/ --lvm server --dist=precise --passwd --force
std::vector<std::string> split(const std::string &s, const std::string &tosplit){
const std::regex rsplit(tosplit + "+");
auto rit = std::sregex_token_iterator(s.begin(), s.end(), rsplit, -1);
auto rend = std::sregex_token_iterator();
auto res = std::vector<std::string>(rit, rend);
return res;
}
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
config.vm.define :ejabberdbox do |ejabberdbox_config|
ejabberdbox_config.vm.box = 'precise64'
ejabberdbox_config.vm.box_url = "http://dl.dropbox.com/u/1537815/precise64.box"