Skip to content

Instantly share code, notes, and snippets.

View jaspervdj's full-sized avatar
🧀
eating cheese

Jasper Van der Jeugt jaspervdj

🧀
eating cheese
View GitHub Profile
@jaspervdj
jaspervdj / fast-aleck-draft.h
Created May 14, 2012 17:28
Draft of the fast-aleck API
#include <string.h>
/*******************************************************************************
* Builder *
*******************************************************************************/
/* Smart and fast string concatenation which allows streaming */
typedef struct {
/* ??? */
@jaspervdj
jaspervdj / 2012-04-17-test-run-replay
Created April 17, 2012 19:08
12Urenloop test run 17/04/2012
REPLAY,1334685038,00:21:91:F1:EA:0A,00:01:E3:A7:FE:B0,-87.0
REPLAY,1334685056,00:21:91:F1:EA:0A,00:01:E3:A7:FE:B0,-85.0
REPLAY,1334685061,00:21:91:F1:EA:0A,00:01:E3:A7:FE:B0,-88.0
REPLAY,1334685076,00:21:91:F1:EA:0A,00:01:E3:A7:FE:B0,-89.0
REPLAY,1334685146,00:21:91:F1:EA:0A,00:01:E3:A7:FE:B0,-86.0
REPLAY,1334685151,00:21:91:F1:EA:0A,00:01:E3:A7:FE:B0,-87.0
REPLAY,1334685338,00:21:91:F1:EA:0A,00:01:E3:A7:FE:B0,-88.0
REPLAY,1334685366,00:21:91:F1:EA:0A,00:01:E3:A7:FE:B0,-88.0
REPLAY,1334685486,00:21:91:F1:EA:0A,00:01:E3:A7:FE:B0,-89.0
REPLAY,1334685550,00:21:91:F1:EA:0A,00:01:E3:A7:FE:B0,-88.0
@jaspervdj
jaspervdj / xrandr-setup.rb
Created January 19, 2012 11:37
Setup dual-screen and create a multi-monitor wallpaper using xrandr en RMagick
#!/usr/bin/ruby
# This script reads your monitor settings using the `xrandr` tool. It selects a
# random wallpaper for each monitor from a specified directory. A large image is
# created to fit all monitors, which can then be set using any tool.
require 'RMagick'
class Screen
attr_reader :name, :width, :height, :offset_x, :offset_y
@jaspervdj
jaspervdj / site.hs
Created January 12, 2012 07:24
File listing using Hakyll
{-# LANGUAGE OverloadedStrings #-}
import Control.Applicative ((<$>))
import Control.Arrow ((>>>))
import Data.Monoid (mempty)
import System.FilePath (takeBaseName)
import System.Posix (getFileStatus, fileSize)
import qualified Data.Map as M
import Hakyll
@jaspervdj
jaspervdj / mastermind.hs
Created January 5, 2012 16:26
Suboptimal, quick and dirty Haskell mastermind solver
import Control.Applicative ((<$>))
type Code = [Char]
universe :: [Code]
universe = universe' (4 :: Int)
where
universe' 0 = [[]]
universe' n = [x : xs | x <- ['0' .. '9'], xs <- universe' (n - 1)]
@jaspervdj
jaspervdj / urxvt-solarized.rb
Created October 26, 2011 12:05
Generate Solarized theme for urxvt
# Map color names to actual values
SOLARIZED = {
:base03 => '#002b36', # brblack
:base02 => '#073642', # black
:base01 => '#586e75', # brgreen
:base00 => '#657b83', # bryellow
:base0 => '#839496', # brblue
:base1 => '#93a1a1', # brcyan
:base2 => '#eee8d5', # white
:base3 => '#fdf6e3', # brwhite
@jaspervdj
jaspervdj / websockets-type-tagging-draft.hs
Created October 10, 2011 20:58
Type restrictions for the Haskell Websockets library
{-# LANGUAGE ExistentialQuantification, FlexibleInstances #-}
import Control.Monad.Reader (ReaderT, ask, runReaderT)
import Control.Monad.Trans (liftIO)
import System.Random (randomRIO)
--------------------------------------------------------------------------------
data Message = Text String | Binary String
class Protocol p where
@jaspervdj
jaspervdj / count_newlines.ml
Created August 22, 2011 13:45
Count the number of newlines in a file (learning OCaml)
(* Fold over a file in chunks *)
let fold_file f x file_name =
let buffer = String.create 1024 in
let file = open_in file_name in
let rec go a =
let length = input file buffer 0 (String.length buffer) in
let a' = f a (String.sub buffer 0 length) in
if length > 0 then go a' else a' in
let r = go x in
close_in file;
@jaspervdj
jaspervdj / criterion-runner.rb
Created August 16, 2011 09:09
Ruby wrapper to run criterion benchmarks one at a time
#!/usr/bin/ruby
require 'tempfile'
if ARGV.length < 1 then
puts "Usage: #{$0} <criterion program> [output CSV file]"
puts "If not supplied, results.csv is used as default CSV filename"
exit 1
end
@jaspervdj
jaspervdj / diff-plot.r
Created August 16, 2011 06:39
Procentual change R plot for the means in two Criterion-produced CSV files
# Read CSV files
v1 <- read.csv(file="s.csv", header=T)
v2 <- read.csv(file="rs.csv", header=T)
# Get result means
m1 <- v1$Mean
m2 <- v2$Mean
# Calculate procentual change
d <- (m2 - m1) * 100 / m1