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 / rhc-chk output
Created November 18, 2011 12:30
Issues with my openshift account
$ rhc-chk -l massimo.santini@gmail.com
Password:
Ruby Version: 1.8.7
host_alias:
Proxy being used: none
TEST1: Confirming connection to OpenShift
Code: 200
Message: OK
{"debug":"","data":"{\"carts\":[\"raw-0.1\",\"jenkins-1.4\",\"jbossas-7.0\",\"perl-5.10\",\"rack-1.1\",\"wsgi-3.2\",\"php-5.3\"]}","api_c":["placeholder"],"result":null,"messages":"","broker":"1.1.1","broker_c":["namespace","rhlogin","ssh","app_uuid","debug","alter","cartridge","cart_type","action","app_name","api"],"exit_code":0,"api":"1.1.1"}
@mapio
mapio / gist:1474444
Created December 13, 2011 23:24
Rebase for Formatting
from datetime import datetime
from pytz import utc, timezone
# My local time in Italy is now midnight
local_time = datetime.now()
print local_time.strftime( '%H' ), local_time.hour # outputs "00 0"
# Following http://lucumr.pocoo.org/2011/7/15/eppur-si-muove/
# take that UTC datetime object
@mapio
mapio / gist:2263346
Created March 31, 2012 12:24
Curlish error
$ curlish -i https://graph.facebook.com/me
Traceback (most recent call last):
File "/Users/santini/.virtualenvs/948ddccbe548751e/bin/curlish", line 9, in <module>
load_entry_point('curlish==1.2', 'console_scripts', 'curlish')()
File "/Users/santini/.virtualenvs/948ddccbe548751e/lib/python2.7/site-packages/curlish.py", line 648, in main
site = get_site(args.site, extra_args[url_arg])
File "/Users/santini/.virtualenvs/948ddccbe548751e/lib/python2.7/site-packages/curlish.py", line 363, in get_site
base_url = site.get('base_url')
AttributeError: 'str' object has no attribute 'get'
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 / set_path.sh
Created October 21, 2012 23:30
Setup the DI LabProg path
if [ -z $BASH ]; then exit; fi;
if ! grep -q 'export PATH=/users/ms000123/dbin:' 2>/dev/null ~/.bash_profile; then
( echo;
echo '# Definizione del PATH per il laboratorio di programmazione...';
echo 'export PATH=/users/ms000123/dbin:$PATH';
echo '# non rimuovere questa e le due righe precedenti!';
echo ) >> ~/.bash_profile;
export PATH=/users/ms000123/dbin:$PATH;
fi
@mapio
mapio / codici.txt
Created November 8, 2012 15:06
Mail merge in Python per mandare username e password
PASSWORD user@foo.bar
@mapio
mapio / stupidario.md
Last active October 12, 2015 22:58
La stupidità degli studenti…

Come si fa a stampare il p-esimo valore di un vettore v (diciamo di N interi)?

for ( i = 0; i < N; i++ ) 
    if ( i == p ) printf( "%d", v[ i ] );
    else printf( "non trovato" );

E si stupiva pure che stampasse N-1 volte "non trovato"!

La giustificazione: "credevo che l'unico modo per accedere ai valori del vettore fosse usare l'espressione v[ i ]"… detto altrimenti: pensava che tra le quadre ci si potesse mettere solo i!

@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 / 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 / HTML5 SpeechSynthesis voices sampler.markdown
Created November 28, 2015 20:36
HTML5 SpeechSynthesis voices sampler