Skip to content

Instantly share code, notes, and snippets.

View harryf's full-sized avatar

Harry Fuecks harryf

  • Zürich, Switzerland
View GitHub Profile
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from random import randrange
def fisher_yates_shuffle(unshuffled, shuffled):
"""
http://en.wikipedia.org/wiki/Fisher-Yates_shuffle#The_modern_algorithm
...but using recursion instead of counters
"""
if not unshuffled: return shuffled
http = require('http');
querystring = require('querystring');
sys = require('sys');
/* Display the index page */
function showIndex(req, res) {
// Write the static data
res.write('<html>');
res.write('<h1>local.ch Töggeli Server</h1>');
res.write('<p>You want to play töggeli? Input your name to add yourself ');
@harryf
harryf / techup.py
Created December 30, 2010 16:16
Puts whatever it finds in the feed in elastic search
#!/usr/bin/env python
import httplib, hashlib, json
import feedparser
def index_event(e):
""" Pass the event to ElasticSearch for indexing """
id = hashlib.md5(e.link).hexdigest()
body = json.dumps({'title': e.title, 'updated': e.updated,
'summary': e.summary, 'link': e.link})
connection = httplib.HTTPConnection('127.0.0.1:9200')
@harryf
harryf / mapping.sh
Created December 30, 2010 17:31
An elasticsearch mapping for techup events
#!/bin/sh
echo "Deleting index"
curl -XDELETE 'http://localhost:9200/techup/'
echo "\nCreating index"
curl -XPUT 'http://localhost:9200/techup/'
echo "\nApplying mapping"
curl -XPUT 'http://localhost:9200/techup/events/_mapping' -d '
{
{"took":4,
"_shards":
{"total":5,
"successful":5,
"failed":0},
"hits":
{"total":2,
"max_score":null,
"hits":[
{"_index":"techup",
@harryf
harryf / search.sh
Created December 30, 2010 18:49
more advanced search
#!/bin/sh
echo "\nSearching..."
curl -XGET 'http://localhost:9200/techup/events/_search' -d @- <<EOF
{
"query" : {
"filtered" : {
"query" : {
"query_string" : {
"query" : "twitter"
}
curl -XPUT 'http://192.168.80.67:9200/_river/techup_couch/_meta' -d '{
"type" : "couchdb",
"couchdb" : {
"host" : "192.168.80.67",
"port" : 5984,
"db" : "techup_couch",
"filter" : null
}
}'
echo ""
#!/bin/sh
curl -XGET localhost:9200/drs/shows/_search -d '
{
"query" : {
"match_all" : { }
},
"facets" : {
"today_facet" : {
"query" : {
"term" : { "text" : "heute" }

Keybase proof

I hereby claim:

  • I am harryf on github.
  • I am harryf (https://keybase.io/harryf) on keybase.
  • I have a public key whose fingerprint is 69D7 1737 17F1 185F 91EB 5885 C54C 56AD A24C BC70

To claim this, I am signing this object:

@harryf
harryf / Insulter
Created November 7, 2015 12:18
Provides a random insult in German to anyone who presses the button
/*
Requirements: http://www.techwillsaveus.com/shop/diy-kits/diy-gamer-kit-arduino/
*/
#include <Gamer.h>
Gamer gamer;
String insults[10] = {
"Schlampe",
"Idiot!",