Skip to content

Instantly share code, notes, and snippets.

View matths's full-sized avatar
💻
In a former live I was a flash developer.

Matthias Dittgen matths

💻
In a former live I was a flash developer.
View GitHub Profile
#!/bin/sh
CURRENT=$(node -v)
#version details
VERSION=$(curl -L -s http://nodejs.org/dist/latest/ \
| egrep -o '[0-9]+\.[0-9]+\.[0-9]+' \
| tail -n1)
PLATFORM=linux
ARCH=x64
@matths
matths / gist:4500902
Created January 10, 2013 10:04
some basics using NSJSONSerialization (iOS5 and up.)
NSString *strArrayExample = @"%5B%22hello%22%2C%22world!%22%2C12%5D";
NSString *strObjectExample = @"%7B%22a%22%3A%221%22%2C%22b%22%3A%22c%22%7D";
NSString *str = [strArrayExample stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(@"str:: %@", str);
NSData *data = [str dataUsingEncoding:NSUTF8StringEncoding];
id json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
NSLog(@"type of data:: %@", NSStringFromClass([json class]));
@matths
matths / gist:2783365
Created May 24, 2012 18:37
Fisher Yates shuffle of a jQuery selection
// http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
$.fn.scramble = function() {
var i = this.length;
if (i > 0) {
var j;
var tmp;
while (--i) {
j = Math.floor(Math.random() * (i + 1));
t = this[j];
this[j] = this[i];
@matths
matths / gist:2771311
Created May 22, 2012 20:06
grab user's facebook album cover pictures
// don't forget to set &oauth=1 in FB.init
// check for valid login, the easy way:
if (FB._authResponse != null)
FB.login(function(r) {}, {scope: 'user_photos'})
FB.api('/me/albums', function(d) {
for (var i=0; i<d.data.length; i++) {
console.log(d.data[i].id, d.data[i].name, d.data[i].link);
@matths
matths / gist:1207164
Created September 9, 2011 19:54 — forked from denis/gist:48774
download & install git code completion from github mirror while git.kernel.org is down
cd /tmp
git clone git://gist.github.com/946648.git
cd git
git checkout git-completion.bash
cp git-completion.bash ~/.git-completion.bash
cd ~
rm -rf /tmp/git
echo -e "source ~/.git-completion.bash" >> .bash_profile