Skip to content

Instantly share code, notes, and snippets.

# Thread an arbitrary number of arguments through a series of functions
def thread1(*funcs)
-> (*args) do
funcs.reduce(args) { |args, func| func.call(*args) }
end
end
a = ->(x) { x + 2 }
b = ->(x) { x * 2 }
@hmac
hmac / keybase.md
Last active September 30, 2015 21:47
Keybase

Keybase proof

I hereby claim:

  • I am hmac on github.
  • I am harrymaclean (https://keybase.io/harrymaclean) on keybase.
  • I have a public key whose fingerprint is F135 AC78 187C 468D 4A32 CA9E 5900 876C 9FFC AB3D

To claim this, I am signing this object:

import grafica.*;
GPlot plot;
GPointsArray points;
int nPoints = 200;
int LEN = 200;
float[][] mesh = new float[1080][LEN];
float gaussian(float x, float mean, float stddev) {
@hmac
hmac / dirlist.rb
Created July 2, 2012 11:00
Print a list of folders and subfolders (1 level deep) in chosen directory
path = ARGV[0]
if !path
abort "No directory path supplied"
end
if !File.directory?(path)
abort "Path given is not a valid directory"
end
dir = Dir.new(path)
@hmac
hmac / brew-leaves.rb
Created April 10, 2012 21:27
A rewrite of brew-leaves.rb that seems to work for me, unlike the current version.
# Outputs formulas that are installed but are not a dependency for
# any other installed formula.
# See: http://github.com/mxcl/homebrew/issues/issue/1438
require 'formula'
installed = HOMEBREW_CELLAR.children.select { |pn| pn.directory? }.collect { |pn| pn.basename.to_s }
deps = Formula.all.map do |f|
next unless installed.include? f.name
f.deps.map {|c| c.to_s }