Skip to content

Instantly share code, notes, and snippets.

View nkpart's full-sized avatar

Nick Partridge nkpart

  • Brisbane, Australia
View GitHub Profile
View gist:1545
$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
@nkpart
nkpart / gist:1985
Created July 24, 2008 01:23 — forked from benhoskings/gist:1974
undefined
View gist:1985
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 / V.hs
Last active August 29, 2015 14:06 — forked from danclien/V.hs
View V.hs
-- Not the greatest Haskell code, but it's possible to create a `i -> AccValidation err a` type
-- that can keep help keep track of where errors are.
-- For aeson, may be possible to just put the `[(Text, Value)]`s in place of `[String]`?
-- e.g. * Replace `[String] -> AccValidation [VError] a` with `[(Text, Value)] -> AccValidation [VError] a`
-- where `Text` is the key name, and `Value` is the value being parsed
-- * Make the smart constructor also take in a `Value` so it can `<>` the data.
-- * `VError` would need to be parameterized too to accept `Value` instead of `String`
-- May not be useful, and please ignore the bad code for now. D: I'm tired.
View gist:36957
def number_to_ordinal num
int = num.to_i
if (10...20) === int
"#{int}th"
else
"#{int}#{%w{ th st nd rd th th th th th th }[int % 10]}"
end
end
View assign nesting resources.rb
def assign_nesting_resources
@hammock_nesting_scopes.map {|scope|
scope.kick
}.confirm {|kicked_scopes|
kicked_scopes.all? { |results| results.length == 1 }
}.map { |kicked_scopes|
kicked_scopes.map {|results|
results.first
}.each {|result|
assign_entity result
View gist:289457
git config --global alias.lg "log --date=relative --since='1 week ago' --pretty --graph"
View unicode-methods.rb
def ¿
puts 'IMA UPSIDEDOWN QUESTIONMARK LOL'
end
¿ # => IMA UPSIDEDOWN QUESTIONMARK LOL
¿ # => IMA UPSIDEDOWN QUESTIONMARK LOL
¿ # => IMA UPSIDEDOWN QUESTIONMARK LOL
¿ # => IMA UPSIDEDOWN QUESTIONMARK LOL
¿ # => IMA UPSIDEDOWN QUESTIONMARK LOL
¿ # => IMA UPSIDEDOWN QUESTIONMARK LOL
@nkpart
nkpart / dirwatch
Created February 9, 2011 06:52 — forked from markhibberd/dirwatch
View dirwatch
#!/bin/sh
#
# NAME
# dirwatch - run command on file modification
#
# SYNOPSIS
# dirwatch [-m marker] command dir ...
#
# DESCRIPTION
# dirwatch uses a touch file to track whether files
@nkpart
nkpart / merge_sort.rb
Created October 14, 2011 04:04 — forked from kimhunter/merge_sort.rb
Merge sort ruby
View merge_sort.rb
#!/usr/bin/env ruby
# 2011-10-10 20:57:53 +1000
def merge_sort(a)
return a if a.size <= 1
l, r = split_array(a)
result = combine(merge_sort(l), merge_sort(r))
end
View default.nix
{ nixpkgs ? import <nixpkgs> {}
}:
let
inherit (nixpkgs) pkgs;
python = let
packageOverrides = self: super: {
# sklearn tests fail on darwin
scikitlearn = super.scikitlearn.overridePythonAttrs(old: rec {
doCheck = false;