Skip to content

Instantly share code, notes, and snippets.

View rasmusbergpalm's full-sized avatar

Rasmus Berg Palm rasmusbergpalm

View GitHub Profile
@rasmusbergpalm
rasmusbergpalm / DayZ_update.php
Created May 30, 2012 18:42
Place in steamapps\common\arma 2 operation arrowhead\@DayZ\addons and run. Requires php/winrar on PATH.
<?php
$url = 'http://cdn.armafiles.info/';
$filelist = trim(file_get_contents($url.'md5checksums.txt'));
$lines = explode("\n", $filelist);
$oldfiles = @unserialize(file_get_contents('files'));
foreach ($lines as $line) {
list($md5, $file) = preg_split('/\s/', $line,-1,PREG_SPLIT_NO_EMPTY);
$files[$md5] = $file;
@rasmusbergpalm
rasmusbergpalm / gist:2948812
Created June 18, 2012 15:06
Javascript difference between objects. keywords: compare objects, levenshtein, flatten objects
var flattenObject = function(ob) {
var toReturn = {};
for (var i in ob) {
if (!ob.hasOwnProperty(i)) continue;
if ((typeof ob[i]) == 'object') {
var flatObject = flattenObject(ob[i]);
for (var x in flatObject) {
if (!flatObject.hasOwnProperty(x)) continue;
@rasmusbergpalm
rasmusbergpalm / validnumber
Created August 27, 2012 07:58
Test whether a number follows thousand and decimal seperator rules
^-?(\d{1,3}(\,\d{3})*|(\d+))(\.\d*)?$
@rasmusbergpalm
rasmusbergpalm / boot
Last active December 11, 2015 17:58
matlab ec2 setup
#!/bin/bash
export STATUS="`curl -sL -w "%{http_code}" "http://169.254.169.254/latest/user-data" -o /dev/null`"
if [ "$STATUS" != "200" ]; then
echo "exiting"
exit 1
fi
echo "running"
export EXPERIMENT="`curl http://169.254.169.254/latest/user-data`"
s3fs <bucket> /root/s3
octave /root/research/$EXPERIMENT &> /root/s3/results/${EXPERIMENT////-}.log.txt
@MASTERSTHESIS\{IMM2012-06284,
author = "R. B. Palm",
title = "Prediction as a candidate for learning deep hierarchical models of data",
year = "2012",
school = "Technical University of Denmark, {DTU} Informatics, {E-}mail: reception@imm.dtu.dk",
address = "Asmussens Alle, Building 305, {DK-}2800 Kgs. Lyngby, Denmark",
type = "",
note = "Supervised by Associate Professor Ole Winther, owi@imm.dtu.dk, {DTU} Informatics, and Morten M{\o}rup, mm@imm.dtu.dk, {DTU} Informatics",
url = "http://www.imm.dtu.dk/English.aspx",
abstract = "Recent fi ndings [HOT06] have made possible the learning of deep layered hierarchical representations of data mimicking the brains working. It is hoped that this paradigm will unlock some of the power of the brain and lead to advances towards true {AI}.
@rasmusbergpalm
rasmusbergpalm / swagger.json
Created September 19, 2013 14:42
swagger json example
{
"apiVersion": "1.0.0",
"swaggerVersion": "1.2",
"basePath": "http://petstore.swagger.wordnik.com/api",
"resourcePath": "/user",
"produces": [
"application/json"
],
"apis": [
{
@rasmusbergpalm
rasmusbergpalm / greedy.groovy
Created November 25, 2013 12:47
simple greedy algo for distributing integers (a) in a fixed set of buckets (N) such that the sum of content of the buckets are more or less equal.
def a = [1, 2, 3, 4, 5, 6, 7, 8, 9];
def N = 3;
def buckets = [];
for (int i = 0; i < N; i++) {
buckets[i] = [k: [], t: 0]
}
a.sort { -it }.each { i ->
def b = buckets[0]
b.k.push(i)
b.t += i
{
"Outcome":"NO_PERSON"
}
@rasmusbergpalm
rasmusbergpalm / 1511.06391-set2vector.py
Last active November 26, 2015 13:24
Pseudo-code for Encoder part (section 4) of http://arxiv.org/pdf/1511.06391v1.pdf
def set2vector(x, init, f, g, h, RNN, T):
"""
x: input data w. N samples
init: function that initializes hidden state of RNN
f: f(x): function that maps each sample of x to a vector. E.g. the identity function, an MLP, etc.
g: g(m,q): function that maps vectors m and q to a single number. E.g. the dot product, an MLP, etc.
h: h(q,r): function that maps vectors q and vector r to a vector, e.g. an MLP or similar.
T: int, how many steps to run.
"""
qs[0] = init() # qs[t] is a vector (RNN "post" hidden state?)