Skip to content

Instantly share code, notes, and snippets.

View dansondergaard's full-sized avatar

Dan Søndergaard dansondergaard

View GitHub Profile
package main
import "fmt"
import "big"
func main() {
fmt.Println(fib(50))
fmt.Println(fibrec(big.NewInt(10)))
fmt.Println(fibbig(big.NewInt(50)))
}
<!-- Run all tests, remove temporary files, zip the project directory
avoiding .class files, name the file correctly, and profit. -->
<property name="groupName" value="Batman" />
<property name="deliverDest" value="../" />
<target name="deliver" depends="test,clean">
<delete failonerror="false" file="../C${groupName}.zip" />
<zip destfile="${deliverDest}C${groupName}.zip" level="9">
<zipfileset dir="." prefix="C${groupName}/${ant.project.name}">
<exclude name="**/*.class" />
</zipfileset>
@dansondergaard
dansondergaard / testgen.py
Created September 13, 2011 13:27
Fetches tests from dOvs website
import requests
import os
from os.path import splitext, basename
from lxml.html import document_fromstring as parse
ROOT = 'http://www.cs.au.dk/~mis/dOvs/'
DEST = '/home/dan/Desktop/feature_tests/'
r = requests.get('http://www.cs.au.dk/~mis/dOvs/languages.html')
d = parse(r.content)
@dansondergaard
dansondergaard / js-is-fucked.js
Created August 23, 2012 10:56
JavaScript is fucked
function hello() {
return {
a: 2
};
}
function hello2() {
return
{
a: 2
int scoreMatrixRead(ScoreMatrix *sm, char x, char y) {
int idx, jdx;
switch (tolower(x)) {
case 'a': idx = 0; break;
case 'c': idx = 1; break;
case 'g': idx = 2; break;
case 't': idx = 3; break;
}
@dansondergaard
dansondergaard / Newick.scala
Created November 6, 2012 20:44
Newick Parser, much simplified, with printer
package dk.linnk
import scala.util.parsing.combinator._
sealed abstract class Tree
case class Node(edges: List[Edge], name: Option[String]) extends Tree
case class Leaf(name: Option[String]) extends Tree
case class Edge(to: Tree, weight: Option[Double]) extends Tree
trait Newick {
@dansondergaard
dansondergaard / Viterbi.scala
Created November 25, 2012 18:46
Viterbi in Scala
package dk.linnk.hmm
object Viterbi {
type State = String
type Observation = String
type Probability = Double
type ProbabilityMap = (State, State) => Probability
type EmissionMap = (State, Observation) => Probability
type ProbabilityPath = (Probability, List[State])
@dansondergaard
dansondergaard / jvm-core-dump.txt
Created December 8, 2012 15:19
jvm core dump
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x000000010a0e83e3, pid=15815, tid=19459
#
# JRE version: 7.0_07-b10
# Java VM: Java HotSpot(TM) 64-Bit Server VM (23.3-b01 mixed mode bsd-amd64 compressed oops)
# Problematic frame:
# V [libjvm.dylib+0x3cd3e3]
#
@dansondergaard
dansondergaard / CMakeLists.txt
Last active December 10, 2015 15:39
Generic CMake C++ template. Supports GCC and clang.
cmake_minimum_required (VERSION 2.6)
project(myproject)
file(GLOB "${PROJECT_NAME}_SOURCES" *.cpp)
set(CMAKE_CXX_FLAGS "-Wall -pedantic -std=c++11")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
set(CMAKE_CXX_FLAGS_MINSIZEREL, "-Os -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE, "-O4 -DNDEBUG")
@dansondergaard
dansondergaard / README.md
Created January 11, 2013 08:55
Easily modify your scripts to run any command in parallel.

= q

Many of the command-line tools we use and write daily have no clue about multiple cores or threads. Wrote a script to convert a directory of music files to some other format? You probably did it serially! Did you write a script for downloading a bunch of big files? You probably did that serially too!

These problems are inherently parallisable. Don't waste idle CPU cycles on your machine.

q is here to help. It allows you to conveniently build a queue of commands that you wish to run. When you're done adding commands to the queue, you execute the queue. q will automatically figure out how many cores you've got and run your commands in parallel. Here's a generic example: