Skip to content

Instantly share code, notes, and snippets.

#
# TODO test for password expirying
#
@javascript
Feature: Recover password
In order to not having to contact my manager when I forgot my password
As an employee
I want to be able to reset the password myself
@thomasbrus
thomasbrus / deeltoets_2.asm
Created December 19, 2011 16:07
Count positive numbers
! This program determines the number of positive values in an array
!
! Register usage: %r1 - Index of array
! %r2 - Current value
! %r3 - Positive numbers counter
.begin
.org 2048
a_start .equ 3000
@thomasbrus
thomasbrus / Rotation.java
Created March 14, 2012 14:36
Tic Tac Toe board rotation
package tictactoe.transformation;
import tictactoe.*;
public class Rotation implements Transformation {
private final int times;
public Rotation(int times, boolean clockwise) {
// Rotating more than four times is superfluous
times = times % 4;
@thomasbrus
thomasbrus / node.rb
Created June 25, 2012 20:17
Brew Formula for Node 0.8.0
require 'formula'
class Node < Formula
homepage 'http://nodejs.org/'
url 'http://nodejs.org/dist/v0.8.0/node-v0.8.0.tar.gz'
sha1 '5171fb46fbfee5ac7129c4b17207a3f35a1f57e8'
head 'https://github.com/joyent/node.git'
devel do
@thomasbrus
thomasbrus / torrentz.eu.coffee
Created June 27, 2012 11:54
dotjs script that turns torrentz.eu search results into magnet uri's.
class MagnetURI
@compile: (hash, title) ->
'magnet:?' + [
"xt=urn:btih:#{hash}"
"dn=#{encodeURIComponent(title)}",
"tr=#{encodeURIComponent('udp://tracker.openbittorrent.com:80/announce')}",
"tr=#{encodeURIComponent('udp://tracker.1337x.org:80/announce')}",
"tr=#{encodeURIComponent('http://tracker.publicbt.com/announce')}"
].join '&'
@thomasbrus
thomasbrus / .gitconfig
Created August 1, 2012 18:27
Git alias to show todo's.
[alias]
todo="grep --heading --break --ignore-case --color='always' -e ' TODO: *'"
defmodule Parser do
import Enum, only: [
take_while: 2,
drop_while: 2,
split_with: 2,
filter: 2
]
defp parse(:digit, [48|xs]) do { 0, xs } end
defp parse(:digit, [49|xs]) do { 1, xs } end
boolean isPartOfCycle(int[][] matrix, Edge e) {
// Verwijder edge vw
matrix[v][w] = matrix[w][v] = 0;
Node v = e.node1;
Node w = e.node2;
// Bepaal of er een pad is van v naar w
List<Node> reachableNodes = getReachableNodes(matrix, v);
boolean canRemoveEdge(HashMap<Node, List<Node>> adjacencyList, node1, node2) {
// Verwijder edge vw
adjacencyList.get(node1).remove(node2);
adjacencyList.get(node2).remove(node1);
List<Node> reachableNodes = getReachableNodes(adjacencyList, [], node1);
return reachableNodes.contains(node2);
}
(def max-marbles (memoize (fn [board x y i j]
(let [tile-marbles (nth (nth board x) y)]
(cond
(and (= x i) (= y j)) tile-marbles
(= x i) (+ tile-marbles (max-marbles board x (inc y) i j))
(= y j) (+ tile-marbles (max-marbles board (inc x) y i j))
:else (+ tile-marbles (max
(max-marbles board x (inc y) i j)
(max-marbles board (inc x) y i j))))))))