Skip to content

Instantly share code, notes, and snippets.

View mapio's full-sized avatar
🎯
Focusing

Massimo Santini mapio

🎯
Focusing
View GitHub Profile
from json import loads, dumps
from base64 import b64decode, b64encode
def relocate( conf_data, old_path, new_path ):
def rdt( dct ):
for k, v in dct.items():
if isinstance( v, dict ):
rdt( v )
else:
@mapio
mapio / AnHttpServer.java
Last active May 11, 2016 21:46
Putting together ElementalHttpServer and LifecycleWebServer
import java.io.File;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.URLDecoder;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@mapio
mapio / LexicographicListComparator.java
Last active May 3, 2016 14:10
A List Comparator implementing Lexicographic order
import static org.junit.Assert.assertEquals;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import org.junit.Test;
public class LexicographicListComparator {
@mapio
mapio / 30.svg
Last active January 20, 2016 16:12
The Hasse diagram of the divisibility graph
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mapio
mapio / Sudoku.ipynb
Last active December 30, 2015 13:16
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mapio
mapio / gist:1050635
Created June 28, 2011 06:53
A test comparing defaultdict and groupby for grouping
from timeit import Timer
from operator import attrgetter
from random import randint
def timeit( stmt, setup ):
t = Timer(stmt=stmt, setup=setup)
print "%.2f usec/pass" % (100000 * t.timeit(number=10000)/10000)
class Person(object):
def __init__(self, age):
@mapio
mapio / Vagrantfile
Last active December 17, 2015 14:39
A simple script to update/install the SDT vagrant box (for more details see https://github.com/mapio/sdt/).
$functions = <<FUNCTIONS
function _fixperms {
echo "*** Fixing /home/vagrant permissions and ownership" 1>&2
chown -R vagrant:vagrant /home/vagrant
chmod -R go= /home/vagrant
}
function _github {
if ! [ -d /home/vagrant/sdt ]; then
echo "*** Cloning 'sdt' from GitHub" 1>&2
su - vagrant -c 'hg clone git://github.com/mapio/sdt.git'
@mapio
mapio / errata.c
Created January 31, 2013 14:19
Non si può insegnare C al primo anno!
#include <stdio.h>
int main( int argc, char *argv[] )
{
printf( "Salve, %s!\n" );
return 0;
}
@mapio
mapio / b2
Last active December 6, 2015 02:47
A bash_completion file for b2
have b2 &&
_b2 () {
local _b2_subcommands=(
'authorize_account'
'clear_account'
'create_bucket'
'delete_bucket'
'delete_file_version'
'download_file_by_id'
'download_file_by_name'
@mapio
mapio / HTML5 SpeechSynthesis voices sampler.markdown
Created November 28, 2015 20:36
HTML5 SpeechSynthesis voices sampler