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
tobami / upgrade-packages.sh
Created Dec 2, 2015
Upgrade all packages in a virtualenv
View upgrade-packages.sh
pip3 freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip3 install -U
@tobami
tobami / detect-large-objects.sh
Created Oct 21, 2015
Displays the largest objects in a git repo
View detect-large-objects.sh
#!/bin/bash
#set -x
# Shows you the largest objects in your repo's pack file.
# Written for osx.
#
# @see http://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/
# @author Antony Stubbs
# set the internal field spereator to line break, so that we can iterate easily over the verify-pack output
View Docker
Boot2docker
Install: http://boot2docker.io/
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
192.168.59.103
@tobami
tobami / docker.txt
Created Jul 23, 2014
Docker experiments
View docker.txt
docker pull debian(:wheezy)
docker run -i -t debian:wheezy /bin/bash
--
install
--
docker commit <container_id> <some_name>
--
docker run -i -t -p 127.0.0.1:3306:3306 -d wheezy-mysql:butler2 "/usr/bin/mysqld_safe"
@tobami
tobami / flask_async.py
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
View flask_async.py
#!/usr/bin/env python
import time
import argparse
import gevent
import gevent.monkey
from gevent.pywsgi import WSGIServer
gevent.monkey.patch_all()
from flask import Flask, request, Response, render_template
@tobami
tobami / pypy_branches_migration_script.py
Created Apr 24, 2011
Migrate PyPy's Codespeed data to branches
View pypy_branches_migration_script.py
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
tobami / catching urlopen exceptions
Created Mar 15, 2011
codespeed/tools/save_single_result.py with exception catching
View catching urlopen exceptions
try:
f = urllib2.urlopen(SPEEDURL + 'result/add/', params)
response = f.read()
f.close()
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 = Chef::Role.new
role.from_file(rb_file)
json_file = rb_file.sub(/\.rb$/,'.json')
@tobami
tobami / pymongo_update.py
Created Feb 18, 2011
Pure pymongo data saving for cross-benchmarking
View pymongo_update.py
def save_data(self, rows):
# Mark all as 'old'
self.db.offers.update(
{'productlist': self.productlist.name},
{'$set': {'old': True}}, multi=True, safe=True)
# Upsert
for row in rows:
# Add productlist key and mark as 'not old'
row['productlist'] = self.productlist.name
@tobami
tobami / mongoengine_models.py
Created Feb 17, 2011
MongoEngine models for cross-benchmarks
View mongoengine_models.py
from mongoengine import *
class ProductList(Document):
name = StringField(required=True, unique=True)
def import_offers(self, offers):
for o in Offer.objects.filter(productlist=self.name):
o.old=True
o.save()
You can’t perform that action at this time.