Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View mapio's full-sized avatar
🎯
Focusing

Massimo Santini mapio

🎯
Focusing
View GitHub Profile
@mapio
mapio / Vagrantfile
Last active August 29, 2015 14:07
La configurazione di Vagrant per la macchina virtuale codebox4im
Vagrant.configure("2") do |config|
if ARGV[0] == 'up' || ARGV[0] == 'provision' || ARGV[0] == 'reload'
if File.exists?( 'provision.sh' )
$provisioning_script = File.open( 'provision.sh' ).read
$stderr.puts( "Using 'provision.sh' for provisioning...\n" )
else
require 'net/http'
$provisioning_script = Net::HTTP.get(URI('https://gist.githubusercontent.com/mapio/ef23edceb8a5709b87d0/raw/provision.sh'))
$stderr.puts( "Downloaded gist #ef23edceb8a5709b87d0 for provisioning...\n" )
@mapio
mapio / HOWTO-GUNICORN-GEVENT-OSX-YOSEMITE.md
Last active August 29, 2015 14:09
How to install gunicorn + gevent on OS X 10.10 Yosemite

Given that I've spent a few hours to get it right, here is how I did it.

First install the required dependencies using Homebrew, by this I mean at least

brew install python libevent

Then upgrade setuptools with

curl https://bootstrap.pypa.io/ez_setup.py -o - | python
@mapio
mapio / opearazioni.py
Last active August 29, 2015 14:12
Come tenere occupato un nano saccente…
# -*- coding: utf-8 -*-
import subprocess
from random import randint, choice
VOCI = "Alice", "Federica", "Luca", "Paola"
COMPIMENTI = "geniaccio", "sei un figo", "super", "che gallo"
OFFESE = "coglionazzo", "minchione", "cacchio dici"
OP = ( lambda a, b: a + b, "più"), ( lambda a, b: a - b, "meno" )
@mapio
mapio / collapse
Created January 15, 2015 00:33
A trick to collapse Mercurial revisions in steps
#!/bin/bash
dbg() {
echo WORK
hg -R work log --template '{node|short} {desc}\n'
echo PUBLIC
hg -R public log --template '{node|short} {desc}\n'
echo CLEAN
hg -R clean log --template '{node|short} {desc}\n'
}
@mapio
mapio / hg_archive.sh
Last active August 29, 2015 14:13
How to "archive" an initial segment of a Mercurial repository history.
# let's assume that we have an "original" repo and that we want to
# create a new "archvied" repo with a first release corresponding to what
# happened in the original repo in revisions O:ARCHIVE, plus all the
# releases (ARCHIVE+1):tip in the original repo.
# first remove the cruft from the previous run
rm -rf original archived
# now create the "original" repository that will contain a
@mapio
mapio / digitalocean.txt
Created January 18, 2015 00:50
Linode vs. Digitalocean
========================================================================
BYTE UNIX Benchmarks (Version 5.1.3)
System: digitalocean: GNU/Linux
OS: GNU/Linux -- 3.8.0-38-generic -- #56~precise1-Ubuntu SMP Thu Mar 13 16:22:48 UTC 2014
Machine: x86_64 (x86_64)
Language: en_US.utf8 (charmap="UTF-8", collate="UTF-8")
CPU 0: QEMU Virtual CPU version 1.0 (4800.0 bogomips)
x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET
19:06:58 up 4 days, 15:52, 1 user, load average: 0.62, 0.58, 0.31; runlevel 2
@mapio
mapio / IGDesktopOSXClient.md
Last active August 29, 2015 14:14
How to install a kind of desktop client for Instagram on OSX

You just need two steps:

Invoking `instagram' from the shell will then do the trick.

@mapio
mapio / serve.sh
Created April 17, 2015 07:46
A small script to serve a local directory via HTTP
#!/bin/bash
# see http://veithen.github.io/2014/11/16/sigterm-propagation.html
trap 'kill -TERM $PID' TERM INT
python -m SimpleHTTPServer & PID=$!
python -m webbrowser -t "http://127.0.0.1:8000/"
wait $PID
@mapio
mapio / app.py
Created May 11, 2015 20:08
A flask-admin bug report concerning FileUploadField
from functools import partial
from os import remove
from os.path import join
from flask import Flask
from flask.ext.admin import Admin, form
from flask.ext.admin.contrib.sqla import ModelView
from flask.ext.sqlalchemy import SQLAlchemy
from sqlalchemy.event import listens_for
@mapio
mapio / gist:1082301
Created July 14, 2011 11:36
Trasposizione tabella LaTeX
# -*- coding: utf-8 -*-
# salva questo in un file "pippo.py" ed eseguilo da riga di comando con "python pippo.py"
# metti la tua tabella tra le triple virgolette
table = r"""
a & b & c & d \\
e & f & g & h \\
i & j & k & l