Skip to content

Instantly share code, notes, and snippets.

@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`"
bash
====
hotkey to put current commandline to text-editor: CTRL+x+e
@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
@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 / download_issuu_document.py
Created May 19, 2015 16:02
download the images of a document from issuu.com
#!python
# encoding=utf8
# download the images of a document from issuu.com
import requests
import urlparse
import os
import os.path
# link to the jpg of the first page
@nmandery
nmandery / waitgroup.go
Created July 24, 2015 06:16
usage of golang sync.WaitGroup
package main
import (
"fmt"
"sync"
"runtime"
)
func worker(id int, c chan int, wg *sync.WaitGroup) {
wg.Add(1)
@nmandery
nmandery / dotfiles-install.playbook.yml
Last active August 29, 2015 14:25
Ansible playbook to install the dotfiles from github.com/nmandery/dotfiles
# vi: set ft=yml
---
- hosts: all
sudo: no
vars:
dotfiles_dir: "{{ansible_user_dir}}/.dotfiles"
handlers:
- name: purge cached system packages
shell: apt-get clean
#!/usr/bin/lua
--[[
a parser for google-like search queries
]]--
lex_keywords = {
-- keywords with quotes
"([a-zA-Z]+)%s*:%s*[\"\']([^\"\']+)[\"\']",
-- keywords without quotes
# -*- coding: utf-8 -*-
from mapmatters.client import wms as wmsclient
from mapmatters.parser import wms as wmsparser
WMS_URL = "http://www.example.com/wms"
wms = wmsclient.WmsClient(WMS_URL)
parser = wmsparser.Service(wms.capabilities)
CREATE OR REPLACE FUNCTION posting_set_keywords(postingid integer, kw_array text[])
RETURNS void AS
$BODY$
begin
-- remove keywords which do not anymore exist
delete from test.posting_keyword where
posting_id=postingid and
keyword_id in (
select pl.keyword_id
from test.posting_keyword lk