Skip to content

Instantly share code, notes, and snippets.

View nkpart's full-sized avatar

Nick Partridge nkpart

  • Brisbane, Australia
View GitHub Profile
@nkpart
nkpart / Consuming.hs
Created August 26, 2015 03:34
Consuming keys from a json object
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE OverloadedStrings #-}
module Data.Yaml.Extended (module Data.Yaml.Extended, lift) where
import Data.Yaml
import qualified Data.Text as T
import Control.Monad.State.Strict (StateT, runStateT, unless, lift, get, modify)
import qualified Data.HashMap.Strict as HM (null, delete, keys)
import Data.List (intercalate)
$s = Time.now
$logger = Object.new
def $logger.method_missing(sym, *args)
puts "[%s, %.3f] %s" % [sym.to_s.upcase, Time.now - $s, args.join(' ')]
end
#! /bin/sh
BASEDIR=`dirname $0`
JAVA_OPTS="-Xmx2048m -Xms2048m -Xmn512m -server"
MAIN="start"
CP=$BASEDIR/../lib/jruby.jar:$BASEDIR/../lib/jgrapht-jdk1.5.jar:$BASEDIR/../lib/ped-assign.jar
java -cp $CP $JAVA_OPTS $MAIN $*
$logger = Object.new {
#now I want to override stuff in here
def foo
"bar"
end
}
@nkpart
nkpart / gist:1985
Created July 24, 2008 01:23 — forked from benhoskings/gist:1974
undefined
class PedAssignOptions < Struct.new(:links_file, :access_file, :walk_int_file, :output_file); end
class ParseFail < Struct.new(:reason); end
class ArgvParser
def parse argv
if argv.size == 1 and ['-h','--help'].include? argv.first then
return :help
end
if argv.length != PedAssignOptions.members.size then
return ParseFail.new("Incorrect number of arguments, got #{argv.size} expected #{PedAssignOptions.members.size}")
@nkpart
nkpart / fuzzy_window_select.tmux.conf
Last active August 29, 2015 13:56
Selecta + Tmux
# Creates a new window to run selecta over list-windows, then selects the result.
bind-key g new-window -n "__SELECTA__" "tmux list-windows | grep -v __SELECTA__ | selecta | sed s/:.*// | xargs -I {} tmux select-window -t {}"
# The same in a split (this is probably better). 21 is how high selecta is by default, 1 line for the prompt, 20 for results
bind-key g split-window -l 21 "tmux list-windows | selecta | sed s/:.*// | xargs -I {} tmux select-window -t {}"
@nkpart
nkpart / example.rb
Last active August 29, 2015 13:56
Ruby semigroups
class LotsOfData < Struct.new(:field1, :field2, :field3, :field4, :value)
def as_accumulation
# Group by field1, then the pair of field2 and field3, then field4, finally summing all the values
{ field1 => { [field2, field3] => { field4 => Plus.new(value) } } }
end
end
many_data = [
LotsOfData.new(:a, :b, :c, :d, 15),
LotsOfData.new(:a, :b, :c, :d, 20),
@nkpart
nkpart / news.md
Created February 25, 2014 09:36
BFPG FP News, 25th February 2014
@nkpart
nkpart / ideas.md
Last active August 29, 2015 13:56
cabal tool ideas

cabal tooling ideas

  • give me a list of all source files in a target, or targets
  • hothasktags integration
  • tell me when a source file isn't in the modules list of anything
@nkpart
nkpart / linking
Created March 3, 2014 00:03
link time is super slow
∴ cabal test | timestamp
10:02:42 Building dredd-0.1...
10:02:42 Preprocessing library dredd-0.1...
10:02:43 In-place registering dredd-0.1...
10:02:43 Preprocessing executable dredd for dredd-0.1...
10:02:43 Linking dist/build/dredd/dredd ...
10:02:46 Preprocessing test suite tasty for dredd-0.1...
10:02:46 Linking dist/build/tasty/tasty ...
10:02:49 Running 1 test suites...
10:02:49 Test suite tasty: RUNNING...