Skip to content

Instantly share code, notes, and snippets.

Miquel Torres tobami

Block or report user

Report or block tobami

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
tobami /
Created Dec 2, 2015
Upgrade all packages in a virtualenv
pip3 freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip3 install -U
tobami /
Created Oct 21, 2015
Displays the largest objects in a git repo
#set -x
# Shows you the largest objects in your repo's pack file.
# Written for osx.
# @see
# @author Antony Stubbs
# set the internal field spereator to line break, so that we can iterate easily over the verify-pack output
View Docker
export DOCKER_HOST=tcp://:2375
# Make a volume container (only need to do this once)
$ docker run -v /data --name my-data busybox true
# Share it using Samba (Windows file sharing)
$ docker run --rm -v /usr/local/bin/docker:/docker -v /var/run/docker.sock:/docker.sock svendowideit/samba my-data
# then find out the IP address of your Boot2Docker host
$ boot2docker ip
tobami / docker.txt
Created Jul 23, 2014
Docker experiments
View docker.txt
docker pull debian(:wheezy)
docker run -i -t debian:wheezy /bin/bash
docker commit <container_id> <some_name>
docker run -i -t -p -d wheezy-mysql:butler2 "/usr/bin/mysqld_safe"
tobami /
Created Apr 15, 2013
Demonstration of the ability to switchable flask server, from the blocking dev server to the async gevent server. Instructions to test in the comment below
#!/usr/bin/env python
import time
import argparse
import gevent
import gevent.monkey
from gevent.pywsgi import WSGIServer
from flask import Flask, request, Response, render_template
tobami /
Created Apr 24, 2011
Migrate PyPy's Codespeed data to branches
pypy = Project.objects.get(name="pypy")
pypy_trunk = Branch.objects.create(name="trunk", project=pypy)
for rev in Revision.objects.filter(project=pypy):
rev.branch = pypy_trunk
tobami / catching urlopen exceptions
Created Mar 15, 2011
codespeed/tools/ with exception catching
View catching urlopen exceptions
f = urllib2.urlopen(SPEEDURL + 'result/add/', params)
response =
except urllib2.URLError, e:
if hasattr(e, 'reason'):
response = '\n We failed to reach a server\n'
response += ' Reason: ' + str(e.reason)
elif hasattr(e, 'code'):
response = '\n The server couldn\'t fulfill the request\n'
View chef-roles-to-json-task.rb
# ADD this to Rakefile and run it by issuing rake roles.to_json
ROLE_DIR = File.expand_path(File.join(TOPDIR, "roles"))
namespace :roles do
desc "Convert ruby roles from ruby to json, creating/overwriting json files."
task :to_json do
Dir.glob(File.join(ROLE_DIR, '*.rb')) do |rb_file|
role =
json_file = rb_file.sub(/\.rb$/,'.json')
tobami /
Created Feb 18, 2011
Pure pymongo data saving for cross-benchmarking
def save_data(self, rows):
# Mark all as 'old'
{'$set': {'old': True}}, multi=True, safe=True)
# Upsert
for row in rows:
# Add productlist key and mark as 'not old'
row['productlist'] =
tobami /
Created Feb 17, 2011
MongoEngine models for cross-benchmarks
from mongoengine import *
class ProductList(Document):
name = StringField(required=True, unique=True)
def import_offers(self, offers):
for o in Offer.objects.filter(
You can’t perform that action at this time.