Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
BACKUP_DIR=/dir/to/backup
SQL_FILE=backup.sql
mysqldump --skip-extended-insert --skip-dump-date \
-uuser -ppwd database |
grep -v 'INSERT INTO `wp_statpress`' > $BACKUP_DIR/$SQL_FILE
rsync -ax /dir/to/wordpress/wp-content/themes/twentyten \
@bamthomas
bamthomas / index.html
Created June 24, 2011 16:33
webcam war room
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<META HTTP-EQUIV="Refresh" CONTENT="1">
</head>
<body>
<img src="warroom.jpeg">
</body>
</html>
@bamthomas
bamthomas / groupBy.js
Created October 26, 2011 08:49
groupBy javascript
function groupBy(jsonArray, fun) {
return jsonArray.reduce(function(accumulator, object) {
var value = fun(object);
if (Array.isArray(accumulator[value])) {
accumulator[value].push(object);
} else {
accumulator[value] = [object];
}
return accumulator;
}, {});
@bamthomas
bamthomas / index.html
Created December 5, 2011 10:41
webcam AVSP
#!/bin/sh
sudo watch -n 1 streamer -s 1280—720 -f jpeg -o /var/www/avsp/warroom.jpeg
@bamthomas
bamthomas / mod_http_presence.erl
Created December 14, 2011 10:10
module http ejabberd
-module(mod_http_presence).
-behavior(gen_mod).
-include("ejabberd.hrl").
-include("jlib.hrl").
-export([start/2, stop/1, on_presence/4]).
start(Host, _Opts) ->
@bamthomas
bamthomas / .tmux.conf
Created June 4, 2012 20:49
tmux config
# prefix is CTRL-B and CTRL-X
set -g prefix C-b,C-x
# enable CTRL-B and CTRL-X under other programms (like vim) - you'll have to press twice le combination to have the ancien one
bind C-b send-prefix
bind C-x send-prefix
# UTF-8
set-option -g status-utf8 on
set-window-option -g utf8 on
@bamthomas
bamthomas / toggle_azerty_querty
Created July 7, 2012 12:00
toggle_azerty_querty
#!/bin/bash
if ( setxkbmap -query | grep fr > /dev/null )
then setxkbmap us -option compose:ralt
else setxkbmap fr -option ""
fi
@bamthomas
bamthomas / set_typematrix_dvorak_mapping
Created August 1, 2012 15:11
TypeMatrix set dvorak mapping
ID=`xinput list | grep TypeMatrix | grep keyboard | sed 's/.*id=\([0-9]*\).*/\1/'` && setxkbmap -device $ID dvorak -option compose:ralt
# mapping insert on mail key
xmodmap -e 'keycode 163=Insert'
@bamthomas
bamthomas / encode_music_with_single_image
Created September 7, 2012 11:01
encode_music_with_single_image
MP3=music.mp3
ffmpeg -loop_input -vframes `mp3info -p "%S" $MP3` -r 1 -f image2 -i cover.jpg -i $MP3 -ab 128k video.avi
#!/bin/bash
ORIGINAL=$1
mv $ORIGINAL/$ORIGINAL.jpg $ORIGINAL/cover.jpg
ALBUM_PATH=`echo $ORIGINAL | awk -F '-' '{print $1"/"$2}'`
mkdir -p "$ALBUM_PATH"
mv $ORIGINAL/* "$ALBUM_PATH/"
rmdir $ORIGINAL