Skip to content

Instantly share code, notes, and snippets.

@nmandery
nmandery / thinkpad_t420_samsung_syncmaster_205bw_modes.sh
Last active August 29, 2015 14:14
thinkpad_t420_samsung_syncmaster_205bw_modes.sh
# from https://wiki.archlinux.org/index.php/xrandr
# create modeline output based on the monitors resolution
cvt 1680 1050
# use that modeline for creating a new resolution
# also remove all non-resolution charaters from the mode
# name - otherwise arandr will crash
xrandr --newmode "1680x1050" 146.25 1680 1784 1960 2240 1050 1053 1059 1089 -hsync +vsync
@nmandery
nmandery / rename_photos.py
Last active August 29, 2015 14:07
Rename all images in a directory to timestamp when they have been taken. also rename existing sidecar files
#!/usr/bin/env python
#
# Rename all images in a directory to timestamp when they have been taken.
# also rename existing sidecar files
import sys
import glob
import pyexiv2
import os.path
import shutil
bash
====
hotkey to put current commandline to text-editor: CTRL+x+e
@nmandery
nmandery / start-qemu-debian.bash
Last active August 29, 2015 13:56
qemu start command for images provided on http://people.debian.org/~aurel32/qemu/amd64/
#!/bin/bash
# qemu start command for images provided on http://people.debian.org/~aurel32/qemu/amd64/
set -eu
IMG=$(dirname $0)/images/debian-wheezy.qcow2
VM_MEMORY='1024'
SSH_PORT=2223
VM_NCPUS="`grep -c ^processor /proc/cpuinfo`"
@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 / statemachine.c
Created February 1, 2012 14:55
State machines are very simple in C if you use function pointers.
/*
http://stackoverflow.com/questions/1371460/state-machines-tutorials/1371654#1371654
State machines are very simple in C if you use function pointers.
Basically you need 2 arrays - one for state function pointers and one for state
transition rules. Every state function returns the code, you lookup state
transition table by state and return code to find the next state and then
just execute it.
*/
@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 / 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 / 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 / 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