Skip to content

Instantly share code, notes, and snippets.

@nmandery
nmandery / camera_audio_trigger.py
Created December 25, 2010 19:54
camera_audio_trigger.py
#!/usr/bin/python
import alsaaudio, time, audioop
import sys
import piggyphoto
# init camera
try:
C = piggyphoto.camera()
@nmandery
nmandery / wget_github.sh
Created March 15, 2011 16:59
bash function to download github tarballs
function wget_github {
GHUSER=$1
GHREPO=$2
wget --no-check-certificate "https://nodeload.github.com/$GHUSER/$GHREPO/tarball/master" -O "./$GHUSER-$GHREPO.tar.gz"
}
@nmandery
nmandery / size_schemata.sql
Created March 18, 2011 08:17
views to get relations sizes in postgresql
create or replace view public.size_schemata as
select table_schema,
pg_size_pretty(sum(pg_total_relation_size(table_schema || '."' || table_name || '"')::bigint)::bigint) As fulltblsize,
pg_size_pretty(sum(pg_relation_size(table_schema || '."' || table_name || '"')::bigint)::bigint) As justthetblsize
from information_schema.tables
where table_catalog = current_database()
group by table_schema
@nmandery
nmandery / hexcolor_to_mapserver.sql
Created March 29, 2011 08:59
convert hex colors to mapserver format in postgresql
create or replace function public.hexcolor_to_mapserver(hexcolor text) returns text as
$body$
declare
thexcolor text;
color_r int;
color_g int;
color_b int;
begin
thexcolor := trim(both ' ' from hexcolor);
if not thexcolor ~ '^#[0-9a-fA-F]{6}$' then
@nmandery
nmandery / odf-pack.sh
Created April 7, 2011 14:39
pack directories to odf files
#!/bin/sh
set -e
TSTAMP=$(date +%Y%m%d-%H%M%S)
INDIR="$1"
OUTFILE_BASE=$(echo "$INDIR" | sed 's/-unpacked//g' | sed 's/.odt//g')
OUTFILE="$OUTFILE_BASE.odt"
[ -d $INDIR ] || exit 1
@nmandery
nmandery / odf-unpack.sh
Created April 7, 2011 14:40
unpack odf files
#!/bin/sh
set -e
TSTAMP=$(date +%Y%m%d-%H%M%S)
ODFFILE=$1
ODFDIR="$ODFFILE-unpacked"
[ -f "$ODFFILE" ] || exit 1
@nmandery
nmandery / tripod-notes.txt
Created January 1, 2012 22:30
tripod notes
http://photography-on-the.net/forum/showthread.php?t=879433
http://photography-on-the.net/forum/showthread.php?t=929789
http://www.pixtus.com/forum/product-reviews/138424-benro-trcb069-travel-angel.html
http://www.benro.de/stative/travelangel.htm
http://www.canonclubitalia.com/public/forum/Benro-Travel-Angel-recensioni-con-t351810.html
http://blog.sebastianbober.com/2011/10/15/gear-review-giottos-vitruvian-vgrn8265-with-5501-652-ball-head/
@nmandery
nmandery / rsync_svn_only.sh
Last active September 29, 2015 21:17
rsync only svn files (directory and contents)
# copy only the .svn diretories form all subdirs
rsync -avP --include="*/" --include='.svn/***' --exclude='*' from/ to/
@nmandery
nmandery / defer.cc
Created March 7, 2012 20:32
Go-like defer statement (C++11)
/**
* Go-like defer statement (C++11)
*
* g++ --std=c++0x -o def def.cc
*
* also see http://blog.korfuri.fr/post/go-defer-in-cpp/
*/
#include <functional>
#include <iostream>
@nmandery
nmandery / make-git-changelog.sh
Last active November 29, 2016 12:10
generate a changelog from git tags
#!/bin/bash
# generate a changelog from git tags
TAGLIST=`git tag | grep -E '^v[0-9]+' | xargs -I@ git log --format=format:"%ai @%n" -1 @ | sort -r | awk '{print $4}'`
LAST_IN_LIST=HEAD
echo "Changelog"
echo "---------"
echo ""