Skip to content

Instantly share code, notes, and snippets.

View raphaelm's full-sized avatar

Raphael Michel raphaelm

View GitHub Profile
@raphaelm
raphaelm / benchmark-echo.php
Created April 18, 2010 13:06
PHP echo "",""; VS echo ""."";
<?php
ob_start();
$start = microtime(1);
for($i = 0; $i < 1000000; $i++){
echo "abc", "def", "ghi", "jkl", "mno", "pqr";
}
$end = microtime(1);
ob_end_clean();
echo "Kommas: ".(($end-$start)/1000000)."\n";
@raphaelm
raphaelm / ext.gif
Created April 19, 2010 17:14
Strahlensätze: JavaScript zur Berechnung fehlender Werte in bestimmten Figuren unter Anwendung der Strahlensätze
ext.gif
@raphaelm
raphaelm / unbenannt.pas
Created July 1, 2010 19:16
Fibonacci for lutoma's performance comparisons - in object free pascal
program unbenannt;
{$mode objfpc}{$H+}
uses sysutils;
var i, nums: integer;
var a, b, now: real;
BEGIN
# Debian lighttpd configuration file
#
############ Options you really have to take care of ####################
## modules to load
# mod_access, mod_accesslog and mod_alias are loaded by default
# all other module should only be loaded if neccesary
# - saves some time
# - saves memory
@raphaelm
raphaelm / skype-ch.py
Created January 4, 2012 21:13
Skype+MPD currently hearing as message
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from mpd import (MPDClient, CommandError)
import sys
import datetime
import Skype4Py
from time import sleep
if len(sys.argv) < 2:
@raphaelm
raphaelm / tunnel.sh
Created June 7, 2012 17:43
SSH Tunnel + Chrome
#!/bin/sh
urxvt -bg black -fg green -e ssh -D 2323 HOST &
pkill google-chrome
killall google-chrome
google-chrome --proxy-server=socks4://localhost:2323&
@raphaelm
raphaelm / my_i3status.bash
Created December 28, 2012 21:30
Thinkpad X230 mic mute button status displayed in i3status, because even though you can make the button function via an ACPI event, it is impossible to use the button's LED with kernel 3.5 Requires: jshon
#!/bin/bash
i3status | while :
do
read line
if [[ "$line" == *"full_text"* ]] ; then
if ! amixer sget 'Capture',0 | grep '\[on\]' > /dev/null 2>&1 ; then
if [[ "$line" == ","* ]]; then
echo -n ","
fi
echo $line | sed s/^,//g | jshon -n object -i 0 -e 0 -s "name" -i "micmute" -s "mic muted" -i "full_text" -p | tr '\n' ' '
@raphaelm
raphaelm / elements.py
Last active December 12, 2015 03:58
Checks whether it is possible to compose a given name out of chemical element symbols, like Caroline out of Carbon (C), Argon (Ar), Oxygen (O), Lithium (Li) and Neon (Ne).
#!/usr/bin/env python
#
# elements.py
#
# Checks whether it is possible to compose a given name out of chemical
# element symbols, like Caroline out of Carbon (C), Argon (Ar), Oxygen (O)
# Lithium (Li) and Neon (Ne).
#
# The implementation consists of a simple backtracking algorithm.
#
# History
HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=1000
zstyle :compinstall filename '/home/raphael/.zshrc'
# Load colors
autoload -U colors && colors
@raphaelm
raphaelm / decrypt.py
Created August 19, 2013 14:37
EasyMoney (Android expense tracker) backup files are obfuscated. This script decrypts them and stores the data in an SQLite3 file (just like it is stored on the Android device).
#!/usr/bin/env python3
import sys
import re
import sqlite3
import os.path
try:
INFILE = sys.argv[1]
OUTFILE = sys.argv[2]
except: