Skip to content

Instantly share code, notes, and snippets.

@wandernauta
wandernauta / app.py
Last active August 27, 2015 13:33
Authenticating Estonian ID cards using Flask and nginx
import re
from flask import Flask, request
app = Flask(__name__)
@app.route("/")
def hello():
dn = request.headers['X-Client']
fields = dict(re.findall("/([^=]*)=([^/]*)", dn))
doctype = "<!doctype html>"
62A99C0E 00000000 2014-34-30T02:34:51 org.teddybear.test.DummyModel|foo=Yea|widgets=10
F869E12F 00000001 2014-34-30T02:34:51 org.teddybear.test.DummyModel|foo=Man|widgets=10
F8D6C5FD 00000002 2014-34-30T02:34:51 org.teddybear.test.OtherDummyModel|bits=20|bobs=30
@wandernauta
wandernauta / drawmap.c
Last active August 29, 2015 13:57
drawmap.c
i=0;j=0;w=160;f=40;t;b;p;s;e;k;d=86400;q=599;char* m="M('+z EDz :!#\"!*!8S$[\"!$!#\"\")\"!3R)V$'!!()1M./!F)\"!!!!)'/GE5@\"\"!&%.3&,Y$D\"!!%$)5i\"\"\"F\"%&&6%!e'A#!#!!#&$5&!f&A'$*\"5&!c-#'3''8\"$!!#\"U'\"=5$'8#$$\"S(#=7!*5\"!\"#['!A@6#!^H=!#6bH;!!!\"6_!!I;<&!&\"!!$\"F\"!I8;&\"#\"$&#\"C#\"I7<%#!\"/\"BP5=$*,\"=#\"$!L4A%&\"\"G\"\"\"#M1@)*F\"%P/@,!N#!S(E;!@W'E=!!!<Y&D7!&!\"$7\\$D8!)$4_$C8!('&#&!!a&@9!&(%$&g$>9!$*#(%h\">:!!-\"(%&!b!$&5:!\"+\"(!!#$!!!c+5<-!'!'!#!e)5:.!(!&!\"\"e,:25!!!\"!\"\"h-;07#\"$h.9/:\"\"$!!#\"a17-;'!\"$!!\"$!X46,<\"%\"&$\\45,>#&!$$#!W45,C!!!'!\"!$!V26,H\"#!$!\"!\"!S17-#!A!!#\"!_07,\"#A&!\"`.7+#\"A*.!Q.7*$\">/^-9)$\"=0^*<)$!>1]*<(D1])>&E2\\)>&F&!)\\)@#G$%(\\'w%]'x#,\"P%z .\"P%z .!R$z -\"S$z b#z c#z d#z 3";main(){t=(time(0)%d*160)/d;printf("P2\n%d 62\n5\n",w);for(;i<q;i++){for(j=m[i]-' ';j>0;j--){p=k%w,s=(t-f),e=(t+f);printf("%c ", "1324"[b*2+((p>s&&p<e)||(p>s+w&&p<e+w)||(p>s-w&&p<e-w))]);k++;}b=!b;}}

It's life, Jim, but not as we know it

You probably know Conway's Game of Life, the famous cellular automaton invented by mathematician John Conway. Life is a set of rules that, together, allow you to simulate a two-dimensional board of cells. The rules decide which cells on the board live and which ones die. With some imagination, you could say that Life is a zero-player game: a game with the objective to find patterns with interesting behavior, like the famous glider.

Glider

A zero-player game... Until today. You are to write a program that plays the Game of Life - and plays it to win, while your opponent's program tries to do the same. The winner is either the last bot standing, or the player with the most live cells after 5 minutes of clock time.

Game rules

#include <stdio.h>
int main() {
int a = 'abcd';
int b = ((('a')<<24) | (('b')<<16) | (('c')<<8) | ('d'));
printf("%d == %d\n", a, b);
}
wn@jeltz ~> route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default gateway 0.0.0.0 UG 203 0 0 eno1
130.89.0.0 if-openvpn.rout 255.255.0.0 UG 0 0 0 tap0
130.89.104.0 * 255.255.248.0 U 0 0 0 tap0
130.89.254.224 gateway 255.255.255.224 UG 0 0 0 eno1
192.168.3.0 * 255.255.255.0 U 203 0 0 eno1
wn@jeltz ~> traceroute wiki.student.utwente.nl.
traceroute to wiki.student.utwente.nl. (130.89.163.107), 30 hops max, 60 byte packets
import structs/ArrayList
import os/Time
"For vs Each: on the bench \n" println()
/* Prepare a thousand-item List */
l := ArrayList<Int> new()
for (i in 0..300000) {
yajl/Yajl.ooc:170:23 [ERROR] No such function Pointer.getType()
if(arr get(i) getType() == ValueType MAP && !arr get(i) complete) {
^^^^^^^
[FAIL]
import os/Time
include time
/* Functions (don't use these) */
strftime: extern func(dest: String*, maxsize: SizeT, format: String*, tm: TMStruct*) -> SizeT
/* Classes (use these) */
CalendarTime: cover from TMStruct {