Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Massimo Santini mapio

🎯
Focusing
Block or report user

Report or block mapio

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
@mapio
mapio / gist:1082301
Created Jul 14, 2011
Trasposizione tabella LaTeX
View gist:1082301
# -*- 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
@mapio
mapio / rhc-chk output
Created Nov 18, 2011
Issues with my openshift account
View rhc-chk output
$ 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 Dec 13, 2011
Rebase for Formatting
View gist:1474444
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
View gist:2263346
$ 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'
View app.py
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 Oct 21, 2012
Setup the DI LabProg path
View set_path.sh
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 Nov 8, 2012
Mail merge in Python per mandare username e password
View codici.txt
PASSWORD user@foo.bar
@mapio
mapio / stupidario.md
Last active Oct 12, 2015
La stupidità degli studenti…
View stupidario.md

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!

View tabellina_del
#!/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"
View consegna
#!/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
You can’t perform that action at this time.