Skip to content

Instantly share code, notes, and snippets.

View grimmo's full-sized avatar

Luigi grimmo

View GitHub Profile
@grimmo
grimmo / gist:677046aba9ca50e1388e
Last active August 29, 2015 14:26 — forked from atomotic/gist:e0e3536b8bc14737685f
quote @virnatwit

"Al fondo, vedo (non certo nei curatori del progetto, ma come sottofondo ancora presente nella mente di alcuni bibliotecari italiani), l'idea che le opere conservate in una biblioteca siano in qualche modo "possedute" dalla biblioteca. Conservare (che è la mission delle biblioteche per le opere storiche) non implica acquisire diritti, quanto piuttosto, semmai, doveri, come appunto quello della massima valorizzazione delle opere. Al giorno d'oggi questo non può che significare rilasciare anche le digitalizzazioni in pubblico dominio (o CC0)."

@grimmo
grimmo / web2py_scheduler
Created March 24, 2015 08:39
web2py_scheduler debian init script for eztool app
#!/bin/bash
### BEGIN INIT INFO
# Provides: web2py_scheduler
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Should-Start: $mysql $nginx $uwsgi
# Should-Stop: $mysql $nginx $uwsgi
@grimmo
grimmo / web2py_update_multiple_tables.py
Last active August 29, 2015 14:15
Example snippet to illustrate how to "hack" SQLFORM to update multiple tables in a single form
# Occorre una query per ottenere il record in tabella2 correlato al record in tabella1 che stiamo aggiornando
# questa qui sotto è solo un esempio
record_tabella2 = db(db.tabella2.id == id_del_record_in_tabella2)
# Creiamo il form principale tramite SQLFORM della tabella1
form = SQLFORM(db.tabella1,record_id,deletable=True,showid=True,compute=True)
# Costruiamo manualmente l'html del campo da aggiungere nella form
mio_campo_aggiuntivo = TR(LABEL('Campo aggiuntivo:'),TEXTAREA(_name='campo',value=tabella2.campo))
# Inseriamo il campo in posizione -1, ovvero sotto tutti gli altri campi
# attenzione che in questo modo il campo finira' sotto la spunta per l'eventuale cancellazione
form[0].insert(-1,mio_campo_aggiuntivo)
IERI=`TZ=aaa24 date +%Y%m%d`
for t in `find . -maxdepth 1 -type f` ; do ln -s $t ${t:0:6}_$IERI ; done
Keeping medicines from the blood streams of the sick; food
from the bellies of the hungry; books from the hands of the
uneducated; technology from the underdeveloped; and putting
advocates of freedom in prisons. Intellectual property is
to the 21st century what the slave trade was to the 16th.
@grimmo
grimmo / gist:5620007
Created May 21, 2013 14:02
Day of the week
#!/usr/bin/env python
COMMON_YEAR_DAYS =365
LEAP_YEAR_DAYS = 366
days_in_months = {0:0,1:31,2:28,3:31,4:30,5:31,6:30,7:31,8:31,9:30,10:31,11:30,12:31}
giorni = ['monday','tuesday','wednsday','thursday','friday','saturday','sunday']
def is_it_leap(year):
return year%4 == 0 and not year%100 == 0 or year%400 ==0
def day_of_the_week(year,month,day):
@grimmo
grimmo / gist:5619988
Created May 21, 2013 13:59
Psypress scraping book list
#!/usr/bin/env python3
import csv,urllib.request,urllib.parse,urllib.error
from bs4 import BeautifulSoup
from time import sleep
URL_SITO = "http://www.psypress.com/books/search/?qs=1&imprint=psychology_press&sort=date&order=desc&range=published&page="
#ciccio = open ('psy.html','r').read()
csout = open('psy.csv','w')
cswrite = csv.writer(csout)
for pagina in range(1,8):
print("Opening %s%i\n" % (URL_SITO,pagina))