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 / HTML5 SpeechSynthesis voices sampler.markdown
Created November 28, 2015 20:36
HTML5 SpeechSynthesis voices sampler
@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 / consegna
Last active November 6, 2015 10:03
#!/bin/bash
export LANG=en_EN.UTF-8
UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
find . -name \*.java -print0 | tar -T- --null -cf /tmp/${UUID}.tar >/dev/null 2>&1
curl \
--form sessione=1144 \
--form fileToUpload=@/tmp/${UUID}.tar \
https://upload.di.unimi.it/doajaxfileupload.php >/dev/null 2>&1
@mapio
mapio / install_jdk_osx.sh
Last active March 27, 2018 06:44
A couple of scripts for unattended install of Oracle JDK 8 on Ubuntu and OS X
#!/bin/bash
echocol() { echo -e "\033[32m*** $@...\033[0m"; }
echocol "Attempting to download the JDK installer disk image"
attempts=5
while ! curl -H "Cookie: oraclelicense=accept-securebackup-cookie" -C - -#LO http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-macosx-x64.dmg; do
if [[ $attempts == 0 ]]; then break; fi
echo "[restarting an interruped download]"
sleep 1;
from flask import Flask, request, session
from flask_sqlalchemy import SQLAlchemy
import flask_admin as admin
from flask_babelex import Babel
from flask_admin.contrib import sqla
# Create application
app = Flask(__name__)
@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 / tabellina_del
Last active October 17, 2015 09:33
Tabelline
#!/bin/bash
t=$1
voci=(Alice Federica Luca Paola)
while true; do
n=$(($RANDOM%11))
voce="${voci[$(($RANDOM%4))]}"
say -v "$voce" "$t per $n"
@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 / bookmarklet.js
Last active June 19, 2021 13:31
A bookmarklet to go from Java 7 APIs documentation to Java 8 APIs documentation
javascript:window.location.assign(window.location.href.replace( /javase\/7\//, 'javase/8/' ));
@mapio
mapio / ArgMax.java
Created February 23, 2015 23:32
An implementation of an argmax collector using the Java 8 stream APIs
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collector;
class ArgMaxCollector<T> {
private T max = null;
private ArrayList<T> argMax = new ArrayList<T>();