Skip to content

Instantly share code, notes, and snippets.

View westphahl's full-sized avatar
😬
Whoops!

Simon Westphahl westphahl

😬
Whoops!
View GitHub Profile
@westphahl
westphahl / gist:988332
Created May 24, 2011 08:27
Ankünfte und Verspätungen für Bahnhof
#!/usr/bin/env python
import sys
import urllib2
from urllib2 import URLError
from BeautifulSoup import BeautifulSoup
URL = "http://reiseauskunft.bahn.de/bin/bhftafel.exe/dn?rt=1&input=%s&boardType=arr&time=actual&productsFilter=11110&start=yes"
if __name__ == '__main__':
@westphahl
westphahl / gist:643740
Created October 24, 2010 17:56
Exercise 2 (DBSYS)
CREATE TABLE disziplinen (
dnr INTEGER CONSTRAINT pk_disziplinen PRIMARY KEY,
weltrekord VARCHAR(50),
sport_gattung VARCHAR(50),
mannschaft INTEGER,
bezeichnung VARCHAR(50)
);
CREATE TABLE wettkaempfe (
wnr INTEGER CONSTRAINT pk_wettkaempfe PRIMARY KEY,
@westphahl
westphahl / Systementwurf (Server)
Created October 16, 2010 15:27
Systementwurf: SysPro
Server
======
Module
------
- Login-Thread
- Broadcasting-Agent
- Client-Thread
- Clientliste/Benutzerverwaltung/Rechteabfrage
- Tafel + Zugriffsfunktionen
@westphahl
westphahl / hash_mod_mult.py
Created June 15, 2010 11:16
Hash distribution for mult and mod
"""
Author: Simon Westphahl <westphahl@gmail.com>
Description: Testing hash distribution for multiplication and modulo.
"""
from math import sqrt, floor
text = "Loraem ipbsum dcolor sdit ameet cosetetur sadpscing eltr seed dgam nosumy eird temdfpor inidunt udft lbore edft dlore mgasdna aquyam eabrat stied dfiam volptua Atat veron eods eukt ascsam ennt jullsto duno dors ehfht eajt rbum Stimet citlla kabsd gbergren notre sklma tkitatta sanlicttus ermist Lopprem isrum dmuolor siast amppet"
word_list = text.split()
@westphahl
westphahl / optimal_tsp.py
Created June 10, 2010 11:46
TSP brute-force solution
"""
Author: Simon Westphahl <westphahl@gmail.com>
Description: Brute-force implementation for solving the TSP.
http://en.wikipedia.org/wiki/Travelling_salesman_problem
"""
routes = []
def find_paths(node, cities, path, distance):
@westphahl
westphahl / gist:368358
Created April 16, 2010 12:33
Script for HS WLAN login
#!/bin/bash
# Usage: $./hs-wlan-login username
# Author: Simon Westphahl <westphahl@gmail.com>
# Required (Ubuntu): zenity, libnotify-bin, curl
if test -z "$1"
then exit
else
USERNAME=$1
@westphahl
westphahl / gist:360442
Created April 8, 2010 19:35
logrotate.d script for Nginx
/var/log/nginx/*.log {
daily
missingok
rotate 52
compress
delaycompress
notifempty
create 640 root adm
sharedscripts
postrotate
@westphahl
westphahl / gist:351974
Created April 1, 2010 15:53
Nginx config (uWSGI example)
# Stripped down Nginx config file for example.com
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
@westphahl
westphahl / gist:351959
Created April 1, 2010 15:40
Nginx Upstart script
# file: /etc/event.d/nginx
description "Nginx HTTP server"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
exec /usr/sbin/nginx
# setup.py
setup(
# [...]
version=__import__('example').__version__,
# [...]
)
# example/__init__.py