Skip to content

Instantly share code, notes, and snippets.

View niklasf's full-sized avatar

Niklas Fiekas niklasf

View GitHub Profile
@niklasf
niklasf / lebesgue.py
Created May 2, 2013 11:08
Calculate the lebesgue constant of a polynomial interpolation operator.
import math
n = 20
#x_k = [-1 + 2 * k / float(n) for k in range(0, n + 1)]
x_k = [math.cos((2.0 * k + 1) / (2.0 * n +2.0) * math.pi)
for k in range(0, n + 1)]
def l_j(j, x):
@niklasf
niklasf / update.py
Created May 1, 2013 22:32
Sample Git update hook that deploys the changed files to the web root.
#!/usr/bin/python
import logging
import git
import sys
import os
def main():
"""
Update all files according to a diff.
@niklasf
niklasf / tic-tac-toe.js
Last active December 16, 2015 21:09
Tic-tac-toe over TCP.
var net = require('net');
var nextGame = null;
function Game() {
var self = this;
this.clients = new Array();
var board = new Array("1", "2", "3",
@niklasf
niklasf / db.class.php
Created February 22, 2011 22:03
A reusable class for MySQL queries in PHP.
<?php
error_reporting(E_ALL);
define('DB_HOSTNAME', 'localhost');
define('DB_USERNAME', '***');
define('DB_PASSWORD', '***');
define('DB_DATABASE', '***');
define('DB_PCONNECT', TRUE);