Skip to content

Instantly share code, notes, and snippets.

@melwil
melwil / users.yml
Created February 23, 2012 02:25
Users for survival (pub)
users:
melwil:
permissions: []
groups:
- reg
@melwil
melwil / groups.yml
Created February 23, 2012 02:25
Groups for survival (pub)
default: default
groups:
admin:
permissions:
- bPermissions.admin
groups:
- mod
meta:
priority: '100'
mod:
@melwil
melwil / Artist.java
Created March 1, 2012 01:35
artist umarshalling spotify
XML from spotify API
------------------
<?xml version="1.0" encoding="iso-8859-1"?>
<artist xmlns="http://www.spotify.com/ns/music/1">
<name>David Guetta</name>
</artist>
------------------
Artist.java;
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<artist>
<name>Moo the man</name>
</artist>
with namespace="http://www.spotify.com/ns/music/1"
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:artist xmlns:ns2="http://www.spotify.com/ns/music/1">
@melwil
melwil / gist:4750311
Created February 10, 2013 17:27
Star Wars Episode V: A New Hope
17 Episode.IV (206.214.251.1) 208.584 ms 212.080 ms 211.850 ms
18 A.NEW.HOPE (206.214.251.6) 205.525 ms 208.306 ms 209.565 ms
19 It.is.a.period.of.civil.war (206.214.251.9) 211.444 ms 211.287 ms 214.330 ms
20 Rebel.spaceships (206.214.251.14) 207.952 ms 209.508 ms 210.667 ms
21 striking.from.a.hidden.base (206.214.251.17) 205.953 ms 211.800 ms 207.414 ms
22 have.won.their.first.victory (206.214.251.22) 209.155 ms 211.656 ms 209.797 ms
23 against.the.evil.Galactic.Empire (206.214.251.25) 215.165 ms 216.145 ms 216.667 ms
24 During.the.battle (206.214.251.30) 211.148 ms * *
25 Rebel.spies.managed (206.214.251.33) 214.694 ms * *
26 to.steal.secret.plans (206.214.251.38) 209.016 ms 205.519 ms 205.806 ms
@melwil
melwil / TestBASE64.java
Created May 3, 2013 08:46
Small test suite for BASE64 regex.
public class TestBASE64 {
public static void main(String[]a) {
String regex = "^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$";
String[] test = {
"TWFu",
"TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=",
"YW55IGNhcm5hbCBwbGVhc3VyZS4=",
"YW55IGNhcm5hbCBwbGVhc3VyZQ==",
"YW55IGNhcm5hbCBwbGVhc3Vy",
@melwil
melwil / christmas-tree.py
Last active December 29, 2015 16:48
Generates christmas trees.
# -*- coding:UTF-8 -*-
#######################################################
# #
# This program creates chrismas trees. The initial #
# purpose of it was to have a template to make pixel #
# art trees for the windows of the office at NTNU. #
# #
# Author: Håvard Slettvold aka. melwil #
# #
# Dependencies: PyPNG #
@melwil
melwil / Console.java
Created January 25, 2014 19:16
UTF-8 printing in windows console
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.win32.StdCallLibrary;
/**
* This class handles output for the ConsoleUI.
* Special handling for this is needed as UTF-8 output in Windows is unreliable
* due to a broken unicode page.
*
@melwil
melwil / gist:62ef02f24c9d9c53a457
Created September 10, 2014 11:04
Arduinoeksperiment hos Iterate
//#include <Esplora.h>
// Kontrollvariabler
int counter = 0;
boolean firstNoise = false;
boolean hasPause = false;
int iterationsSinceSound = 0;
// Mikrofon
int maxVal = 0;
from sys import stdin
import re
import operator
tracks = []
track = []
already_on_map = []
recorded_players = []
timepattern = re.compile("^[^<]+<time> \[([\w\d]+) \(([^)]+)\)\] (\d+:\d+\.\d+)")