Skip to content

Instantly share code, notes, and snippets.

View harryf's full-sized avatar

Harry Fuecks harryf

  • Zürich, Switzerland
View GitHub Profile
@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')
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 ');
#!/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