Skip to content

Instantly share code, notes, and snippets.

View dvarrazzo's full-sized avatar

Daniele Varrazzo dvarrazzo

View GitHub Profile
@dvarrazzo
dvarrazzo / codice_catastale.sql
Last active August 29, 2015 14:05
Script di importazione codici catastali, vedi italian_codes #1
-- Crea una tabella di importazione dati
create table codice_catastale_import (
codice text not null,
codice_belfiore text,
provincia text,
comune text not null,
annotazione text,
codice_var text,
codice_belfiore_var text,
provincia_var text,
@dvarrazzo
dvarrazzo / pypi_docs_upload.py
Created September 1, 2014 15:19
Script script to upload a project docs on PyPI
# -*- coding: utf-8 -*-
"""
Standalone script to upload a project docs on PyPI
Hacked together from the following distutils extension, avaliable from
https://bitbucket.org/jezdez/sphinx-pypi-upload/overview (ver. 0.2.1)
sphinx_pypi_upload
~~~~~~~~~~~~~~~~~~
@dvarrazzo
dvarrazzo / 0_reuse_code.js
Last active August 29, 2015 14:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@dvarrazzo
dvarrazzo / README.md
Last active August 29, 2015 14:06
Test what happens to a libpq connection when we close the file

A test to verify psycopg issue #263. Compile with:

$ gcc -I$(pg_config --includedir) -c testclose.c
$ gcc -o testclose testclose.o -L$(pg_config --libdir) -lpq

The output (with PostgreSQL 9.3.5) suggests PQstatus is not good to detect the closed fd.

$ ./testclose 
PQconsumeInput is fine
@dvarrazzo
dvarrazzo / find-rated-pics
Created May 20, 2015 23:12
Find pictures rated one star or more
#!/usr/bin/env python
"""Find pictures rated one star or more and print their file names.
The output can be used e.g. with rsync --files-from
"""
import os
import sys
from glob import glob
from xml.etree import cElementTree as ET
@dvarrazzo
dvarrazzo / hwclient.py
Created March 31, 2012 20:48
zmq eventlet tests
import sys
import zmq
try:
n = int(sys.argv[1])
except:
n = 10
ctx = zmq.Context()
@dvarrazzo
dvarrazzo / rtdealer.py
Created April 2, 2012 20:12
syncing over tcp appears working
#!/usr/bin/env python
"""
This script should be a test in synchronizing zmq sockets.
Synchronization fails even if the threads prepare the subscriber before
signaling they are ready.
"""
import sys
import random
@dvarrazzo
dvarrazzo / patch_db.py
Created November 28, 2012 12:58
A simple script to record the schema patches applied to a database
#/usr/bin/env python -u
"""
Apply database patches.
Database patches are found in the 'db' directory relative to this script. They
are recorded in the schema_patch table of the database.
The dsn to connect to defaults to a local one (empty connection string). It
can be chosen using the command line or an environment variable (so that the
Makefile doesn't need to be tweaked per developer). Patches application is
@dvarrazzo
dvarrazzo / include_defaults.py
Last active November 2, 2015 16:36
Ansible Plugin implementing the include_defaults action.
"""
Ansible Plugin implementing the include_defaults action.
Like include_vars, but the included defaults can be overridden by the
inventory or by group vars. Can be used to read the defaults from another role.
Usage: drop it into a directory called ``action_plugins`` in your playbook
directory. Then you can use it with::
- name: get the defaults from the web server role
@dvarrazzo
dvarrazzo / reren
Last active December 21, 2015 07:19
A script for smart file rename. Written several years ago, not necessarily the best tool for the job.
#!/usr/bin/python
'''reren -- rinomina usando espressioni regolari.
Utilizzo:
reren "from" "to" [dir] [-y] [-s] [-f]
from: Pattern a cui devono corrispondere i file. I file vengono letti
in ordine alfabetico.
to: Stringa in cui vanno trasformati i file;
se viene specificata l'opzione -f, deve essere una funzione