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 / lisp-quality.awk
Created February 24, 2010 16:05
A diagnosis tool for lisp code.
#!/bin/awk -f
BEGIN {
total = 0
good = 0
}
{
total += length
gsub(/[^()]/, "")
good += length
@jaspervdj
jaspervdj / gist:332603
Created March 15, 2010 07:31
A draft for the BlazeHtml API
<h1>A HTML combinator library proposition</h1>
> {-# LANGUAGE OverloadedStrings #-}
This is a proposal for a HTML combinator interface library. I'm writing this
document because I would like feedback and pointers on the API before I actually
start coding it.
> import Control.Monad.Reader
> import Control.Monad.State
@jaspervdj
jaspervdj / Draft simon meier
Created March 19, 2010 14:01
Draft of BlazeHtml by simon meier
{-# LANGUAGE OverloadedStrings, GeneralizedNewtypeDeriving, FlexibleInstances, TypeSynonymInstances #-}
-- | Another draft of an API for a blazingly fast Html generation library.
--
-- Here we take the following approach.
--
-- (1) We define a Html typeclass for the basic combinators required to build
-- well-formed Html documents. Part of their semantics is defined by
-- equalities they satisfy.
--
-- (2) Based upon these combinators we build the whole set of combinators
-- | Viterbi algorithm in Haskell, legacy of my course on bio-informatics.
--
module Viterbi where
import Data.Ord (comparing)
import Data.Maybe (fromJust)
import Data.List (sort, maximumBy)
import Data.Map (Map)
import qualified Data.Map as M
#include <stdio.h>
#include <stdlib.h>
/* Data structure used for marking. */
typedef struct {
/* Size of the universe. */
int size;
/* "Big" array, containing the entire universe. */
int *array;
@jaspervdj
jaspervdj / add-user.rb
Created September 27, 2010 13:11
Script to add users to the ZeusWPI LDAP
#!/usr/bin/ruby
# Script to add a new user in the Zeus LDAP
require 'fileutils'
# Find a new user id
#
def find_new_user_id
id = 1200
while not `getent passwd #{id}`.empty? do id = id + 1 end
module Formlets where
import Control.Applicative
import Control.Monad
import Control.Monad.Reader
import Control.Monad.State
import Control.Arrow (first)
import Data.Monoid
import Data.Either
import Data.Maybe
-- | Proof-of-concept: use digestive functors for a command line interface
-- prompt
--
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module IncrementalCli where
import Data.Map (Map)
import qualified Data.Map as M
import Data.Monoid (Monoid, mempty, mappend)
import Control.Applicative ((<$>), (<*>))
@jaspervdj
jaspervdj / diff.lua
Created January 31, 2011 09:55
String diff using higher order functions for character distances
#!/usr/bin/lua
--------------------------------------------------------------------------------
-- Distance implementation (abstract) --
--------------------------------------------------------------------------------
-- Simple minimum function for 3 arguments
local function min3(a, b, c)
local x = a < b and a or b
return x < c and x or c
@jaspervdj
jaspervdj / lz77.lua
Created January 31, 2011 12:09
Solver for LZ77 exercises
-- lz77.lua
module(..., package.seeall)
-- Length of the common prefix of str1 and str2
function equal_characters(str1, str2)
-- Shortest length
local len
if string.len(str1) < string.len(str2) then
len = string.len(str1)
else