Skip to content

Instantly share code, notes, and snippets.

View mattias-lw's full-sized avatar

Mattias T mattias-lw

View GitHub Profile
@mattias-lw
mattias-lw / gist:7444790
Created November 13, 2013 06:47
Salt state
/usr/local/bin/lwftp:
file.managed:
- source: salt://admintool/lwftp.js
- user: root
- group: root
- mode: 755
nopt:
npm:
- installed
@mattias-lw
mattias-lw / benchmark
Last active December 11, 2015 03:19
Small performance benchmarks using code from here: http://t.co/Zw0Nh8lU
% ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin12.1.0]
% ruby bench.rb
Time per iteration = 59.04954 microseconds
% ruby -v
jruby 1.7.0 (1.9.3p203) 2012-10-22 ff1ebbe on Java HotSpot(TM) 64-Bit Server VM 1.7.0_06-b24 [darwin-x86_64]
% ruby bench.rb
Time per iteration = 26.02 microseconds
@mattias-lw
mattias-lw / rpn.clj
Created May 10, 2012 22:17
RPN i Clojure
(defn rpn [expr]
(let [head (first expr)
tail (rest expr)]
(cond
(nil? head) (fn [n] n)
(number? head) ((rpn tail) head)
:else (let [restex (rpn tail)]
(fn [n]
(fn [m]
(restex ((resolve (symbol head)) m n))
@mattias-lw
mattias-lw / rpn.rb
Created May 10, 2012 22:16
RPN i Ruby
def rpn(expr)
head, tail = expr.first, expr[1..-1]
case head
when nil
return lambda { |n| n }
when /\d+/
rpn(tail).call(Integer(head))
else
rest = rpn(tail)
lambda { |n|