Skip to content

Instantly share code, notes, and snippets.

View westphahl's full-sized avatar
😬
Whoops!

Simon Westphahl westphahl

😬
Whoops!
View GitHub Profile
/* For reference see:
* http://www.franken-business.de/galileo-computing/c-von-a-bis-z/022_c_algorithmen_003.htm#mj925248949647af9ef7f16d215f433a8c
* http://www.algorithm-code.com/wiki/Insertion_sort#C_Code
*/
#include <stdio.h>
void insertion_sort(int arr[], int n) {
int i, j, x;
for (i = 1; i < n; i++) {
# setup.py
setup(
# [...]
version=__import__('example').__version__,
# [...]
)
# example/__init__.py
@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
@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: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:368358
Created April 16, 2010 12:33
Script for HS WLAN login
#!/bin/bash
# Usage: $./hs-wlan-login username
# Author: Simon Westphahl <[email protected]>
# Required (Ubuntu): zenity, libnotify-bin, curl
if test -z "$1"
then exit
else
USERNAME=$1
@westphahl
westphahl / optimal_tsp.py
Created June 10, 2010 11:46
TSP brute-force solution
"""
Author: Simon Westphahl <[email protected]>
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 / hash_mod_mult.py
Created June 15, 2010 11:16
Hash distribution for mult and mod
"""
Author: Simon Westphahl <[email protected]>
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 / 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 / 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,