Skip to content

Instantly share code, notes, and snippets.

@mattes
mattes / mkcard.sh
Created October 22, 2012 19:47
format sd card for arch linux and others
#!/bin/bash
# Quelle: http://omappedia.org/wiki/Minimal-FS_SD_Configuration, 06.06.2012
if [ ! "$1" = "/dev/sda" ] ; then
unset LANG
DRIVE=$1
if [ -b "$DRIVE" ] ; then
dd if=/dev/zero of=$DRIVE bs=1024 count=1024
SIZE=`fdisk -l $DRIVE | grep Disk | awk '{print $5}'`
echo DISK SIZE - $SIZE bytes
CYLINDERS=`echo $SIZE/255/63/512 | bc`
@mattes
mattes / bootcmd
Created October 23, 2012 09:31
bootcmd for u-boot
fatload mmc 0 0x80300000 uImage
setenv bootargs console=ttyO2,115200n8 noinitrd init=/sbin/init root=/dev/mmcblk0p2 rootwait rw loglevel=8
bootm 80300000
@mattes
mattes / watch.c
Created October 31, 2012 13:54
watch directory for changes and print "update" on change
#include <sys/event.h>
#include <sys/time.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <iostream>
int main (int argc, const char *argv[])
{
@mattes
mattes / gist:3990176
Created October 31, 2012 21:54
update rsync on mac os to rsync 3.0.8

Do in Terminal (requires XCode with Command line tools installed):

curl -O http://rsync.samba.org/ftp/rsync/src/rsync-3.0.8.tar.gz
tar -xzvf rsync-3.0.8.tar.gz
rm rsync-3.0.8.tar.gz
curl -O http://rsync.samba.org/ftp/rsync/src/rsync-patches-3.0.8.tar.gz
tar -xzvf rsync-patches-3.0.8.tar.gz
rm rsync-patches-3.0.8.tar.gz
cd rsync-3.0.8

patch -p1

@mattes
mattes / example.prf
Created November 1, 2012 00:36
unison profile
root = /Users/matthias/somedir
root = ssh://matthias@host:9000/somedir
auto = true
log = true
logfile = /Users/matthias/.unison/unison.log
maxbackups = 5
backup = Name *
@mattes
mattes / gist:3994595
Created November 1, 2012 16:05
Regular Expression for command line parameters
--command value
--command "another value"
/\s*("[^"]+"|[^\s"]+)/
@mattes
mattes / js.js
Created February 15, 2013 02:25
~hash.indexOf(key)
if(~hash.indexOf(key)) {
return true;
} else {
return false;
}
@mattes
mattes / skype-status.html
Last active April 20, 2017 17:31
print skype status
<!DOCTYPE html>
<head>
<title>Skype Status</title>
</head>
<body>
<h1>Return Skype Status</h1>
<p>return skype status (requires the skype privacy setting set to true)<br>
using Open Data tables with YQL (<a href="http://www.datatables.org/">www.datatables.org</a>)</p>
<p>Offline (1), Online (2), Away (3), Do not disturb (3)</p>
@mattes
mattes / kippt.user.clips.js
Created May 11, 2013 17:28
read kippt user clips
var getKipptReads = function(userId, callback) {
if(!userId) throw new Error('missing user id');
var query = 'use "store://OdRiZuDnzAn82XXFXFeQBg" as kippt.user.clips; select * FROM kippt.user.clips WHERE user_id="' + userId + '";';
$.getJSON('http://query.yahooapis.com/v1/public/yql?q=' + encodeURI(query + '&format=json&env=store://datatables.org/alltableswithkeys&callback=?'),
function(data){
if(data.query.count > 0) {
if(callback) return callback.call(null, data.query.results.json);
} else {
if(callback) return callback.call(null, false);
}