Skip to content

Instantly share code, notes, and snippets.

@hanshoglund
hanshoglund / install-dist
Created July 16, 2012 15:31
Install script for dist (Unix)
#!/bin/bash
# This script will install the latest version of Dist
# See also https://github.com/hanshoglund/dist
VERSION=1.3.1
wget "https://github.com/downloads/hanshoglund/dist/dist-unix-${VERSION}.tar.gz"
tar -xvzf "dist-unix-${VERSION}.tar.gz"
@hanshoglund
hanshoglund / Let.cmake
Created July 16, 2012 20:29
Very ugly dynamic let-bindings for CMake
# - Dynamic let-bindings
# Mainly useful for temporary updating global variables
#
# Examples:
#
# set ( X "foo" )
# message ( ${X} ) # X has value 'foo'
# let ( X "bar" )
# message ( ${X} ) # X has value 'bar'
# let ( X "baz" )
@hanshoglund
hanshoglund / lispdoc.hs
Created August 26, 2012 12:03
Tentative Lisp documentation system using Pandoc
#!/usr/bin/env runhaskell
-- Converts inline Lisp documentation to Markdown
-- Requires the Haskell platform + pandoc and pandoc-types from hackage.org
-- Copyright (c) Hans Hoglund 2012
import Control.Monad
import Data.Monoid
import System.Environment (getArgs)
@hanshoglund
hanshoglund / breakList.hs
Created September 22, 2012 13:58
Util to break up a list
import qualified Data.List
import qualified Data.Monoid
-- | Divide a list into parts of maximum length n.
divideList :: Int -> [a] -> [[a]]
divideList n xs
| length xs <= n = [xs]
| otherwise = [take n xs] ++ (divideList n $ drop n xs)
-- | Break up a list into parts of maximum length n, inserting the given list as separator.
@hanshoglund
hanshoglund / dotviewer.sh
Created October 15, 2012 00:47
Dotviewer (OS X)
#!/bin/bash
# Drop in replacement for Dotty on OS X
# Renders a diagram as a PDF using 'dot' and opens the resultant file
DIR=/tmp/dotviewer
FILE=$DIR/$$.pdf
rm -r $DIR
mkdir -p $DIR
@hanshoglund
hanshoglund / notation.js
Created October 17, 2012 20:41
Old JS music notation sketches
/*
* @nolint
* Test implementation of Time notator
*
* This code generates a collection of possible notations for a given duration,
* according to notations options defined in the environment.
*
* A notation is a simple structure consisting of a list of durations or nested
* notations of a relative length, determined by the multiplier property.
*
@hanshoglund
hanshoglund / Interpolation.pde
Created October 17, 2012 20:55
Processing interpolation (from an old example)
// Interpolera slumpmässiga värden mellan 0 och 200
// Börja från mitten
final int SIZE = 230;
final int BALL_SIZE = 30;
Generator x = new RandomInterpolation(SIZE/2, 0, SIZE - BALL_SIZE, new Line(50));
Generator y = new RandomInterpolation(SIZE/2, 0, SIZE - BALL_SIZE, new Line(10));
@hanshoglund
hanshoglund / ohs.md
Created October 25, 2012 15:51 — forked from davidgranstrom/ohs.md
ohs anteckningar

Open HackSpace

Möten

OHS 7 nov 2012

  • Praktiskt:
  • Gist
@hanshoglund
hanshoglund / TypeFixCombinators.hs
Created November 5, 2012 03:13
Type-fix combinators
with :: b -> a -> b
with x _ = x
fix :: a -> (a -> b) -> a
fix x _ = x
fix1 :: (a -> b) -> (a -> a) -> a -> b
fix1 x _ = x
int :: Int -> Int
int = id
@hanshoglund
hanshoglund / gist:4027963
Created November 6, 2012 22:12
JavaScript slice, splice, substr, substring memo
x.slice() ==> x0,x1 ... xn
x.slice(a,b) ==> x0,x1 ... xn