Skip to content

Instantly share code, notes, and snippets.

View terrettaz's full-sized avatar

Pierrick Terrettaz terrettaz

View GitHub Profile
@terrettaz
terrettaz / psql_test_bench.bash
Created September 17, 2012 20:37
Postgres benchmark
#!/bin/bash
DATABASE="benchmark_test_db"
TMP_DIR=/tmp
if [ ! -x "`which psql`" ]; then
echo "psql check failed: postgsql is needed"
exit 1
fi
@terrettaz
terrettaz / friends_info.py
Created November 29, 2011 00:02
Get information about facebook friends and lists
#!/usr/bin/env python
# -*- coding: iso-8859-1 -*-
__version__ = "$Revision: 0.1 $"
__author__ = "Pierrick Terrettaz"
__date__ = "2011-11-28"
import sys
import re
import urllib
import httplib
@terrettaz
terrettaz / jpeg-sort.py
Created February 12, 2011 10:27
This script orders your jpeg files by adding a prefix number to each file based on the EXIF creation date. It can be run recursively. It ask a confirmation before making any changes.
#!/usr/bin/python
# -*- coding: iso-8859-1 -*-
__version__ = "$Revision: 0.1 $"
__author__ = "Pierrick Terrettaz"
__date__ = "2007-08-15"
import sys, os
import popen2
import pprint
@terrettaz
terrettaz / find_emails.py
Created February 12, 2011 10:23
Run this script on a Mac to find all email addresses of persons who wrote emails to a specific email address.
#!/usr/bin/python
# -*- coding: iso-8859-1 -*-
__version__ = "$Revision: 0.1 $"
__author__ = "Pierrick Terrettaz"
__date__ = "2008-05-08"
import popen2
import re
import sys
@terrettaz
terrettaz / word_count.py
Created February 12, 2011 10:17
It counts the amount of occurrences of words in a file and sorts those words. This script accepts a file as first parameter or it use the stdin if no arguments are given.
#!/usr/bin/python
# -*- coding: iso-8859-1 -*-
__version__ = "$Revision: 0.5 $"
__author__ = "Pierrick Terrettaz"
__date__ = "2006-12-09"
import sys
import time
import re
@terrettaz
terrettaz / replace_filename.py
Created February 12, 2011 10:08
This script lets you define rules to rename your files in a specific directory.
#!/usr/bin/env python
# -*- coding: iso-8859-1 -*-
__version__ = "$Revision: 0.2$"
__author__ = "Pierrick Terrettaz"
__date__ = "2006-12-09"
import os, sys, re
from optparse import OptionParser
def rename_file(path, search, replace, options, sub):
@terrettaz
terrettaz / psql_benchmark.bash
Created November 21, 2010 15:28
A simple script to do some benchmark on postgresql
#!/bin/bash
DATABASE="benchmark_test_db"
TMP_DIR=/tmp
if [ ! -x "`which psql`" ]; then
echo "psql check failed: postgsql is needed"
exit 1
fi
@terrettaz
terrettaz / list adressbook
Created October 17, 2009 16:19
Just a simple way to extract email address from your Mac OS AddressBook
mdfind "(kMDItemContentType == com.apple.addressbook.person)" | sed -e 's| |\\ |g' | xargs mdls -name kMDItemEmailAddresses | grep -E '".*@.*"' | sed -e 's|.*"\(.*@.*\)"|\1|g' | sort