Skip to content

Instantly share code, notes, and snippets.

View thomasfr's full-sized avatar

Thomas Fritz thomasfr

View GitHub Profile
@thomasfr
thomasfr / german-porter-stemmer.js
Created March 25, 2012 21:32 — forked from marians/german-porter-stemmer.js
German Porter Stemmer in JavaScript
/* by Joder Illi, Snowball mailing list */
function stemm(word) {
/*
Put u and y between vowels into upper case
*/
word = word.replace(/([aeiouyäöü])u([aeiouyäöü])/g, '$1U$2');
word = word.replace(/([aeiouyäöü])y([aeiouyäöü])/g, '$1Y$2');
/*
and then do the following mappings,
@thomasfr
thomasfr / output.json
Created April 23, 2012 12:56
Simple query language parser in PEGjs
{
"type": "OR",
"terms": [
{
"type": "AND",
"terms": [
"foo",
"bar"
]
},
@thomasfr
thomasfr / gist:3386122
Created August 18, 2012 11:08
JSON.stringify example
var testArray = [
{ foo: 'bar',
foo_2: 'bar2',
foo_3: 123,
subobj: { foo_foo: 'barbar' } },
{ foo: 'bar',
foo_2: 'bar2',
foo_3: 123,
subobj: { foo_foo: 'barbar' } },
{ foo: 'bar',
var redis = require('redis');
var client = redis.createClient(9056, 'char.redistogo.com'); // arguments are interchanged
client.auth('1234567890abcdefghijklm', function (err) {
if (err) { throw err; }
// You are now connected to your redis.
});
@thomasfr
thomasfr / gist:3526258
Created August 30, 2012 10:54
Get latest stable and latest dev version Copied from https://github.com/isaacs/nave/blob/master/nave.sh
nave_latest () {
curl -s http://nodejs.org/dist/ \
| egrep -o '[0-9]+\.[0-9]+\.[0-9]+' \
| sort -u -k 1,1n -k 2,2n -k 3,3n -t . \
| tail -n1
}
nave_stable () {
curl -s http://nodejs.org/dist/ \
| egrep -o '[0-9]+\.[0-9]*[02468]\.[0-9]+' \
@thomasfr
thomasfr / gist:3541551
Created August 30, 2012 21:28
One liner to get latest stable version of node.js
curl --insecure -# -sSL http://nodejs.org/dist/ | sed -n -E "s/.*([0-9]+\.[0-9]+\.[0-9]+).*/\1/gp" | sort -u -k 1,1n -k 2,2n -k 3,3n -t . | tail -n1
@thomasfr
thomasfr / redis.conf
Created September 22, 2012 12:18
redis config for redis-2.6rc7
# Redis configuration file example
# Note on units: when memory size is needed, it is possible to specify
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
@thomasfr
thomasfr / rc.d
Created November 20, 2012 11:55 — forked from jippi/rc.d
Logstash Init script
update-rc.d logstash-shipper defaults
update-rc.d logstash-reader defaults
@thomasfr
thomasfr / elasticsearch.conf
Created November 20, 2012 18:18 — forked from rbscott/elasticsearch.conf
upstart job for elastic search
# ElasticSearch Service
description "ElasticSearch"
start on (net-device-up
and local-filesystems
and runlevel [2345])
stop on runlevel [016]
@thomasfr
thomasfr / geocodeFunctions
Created June 19, 2013 09:52
Some Google App Script functions. The functions can be used as Google Spreadsheet formulas.
function geocode(address) {
if(address) {
var response = Maps.newGeocoder().setRegion('at').geocode(address);
var longLat = {};
var l;
Logger.log("address: " + address);
if (response.status === "OK") {
Logger.log("response " + JSON.stringify(response));
if((l = response.results[0].geometry.location)) {
longLat.lng = l.lng;