Skip to content

Instantly share code, notes, and snippets.

@pastafari
pastafari / lein-errors.log
Created February 22, 2019 11:01
leiningen stack trace
clojure.lang.Compiler$CompilerException: Syntax error macroexpanding clojure.core/fn at (clojure/core/unify.clj:83:18).
#:clojure.error{:phase :macro-syntax-check, :line 83, :column 18, :source "clojure/core/unify.clj", :symbol clojure.core/fn}
at clojure.lang.Compiler.checkSpecs (Compiler.java:6971)
clojure.lang.Compiler.macroexpand1 (Compiler.java:6987)
clojure.lang.Compiler.analyzeSeq (Compiler.java:7092)
clojure.lang.Compiler.analyze (Compiler.java:6789)
clojure.lang.Compiler.analyzeSeq (Compiler.java:7094)
clojure.lang.Compiler.analyze (Compiler.java:6789)
clojure.lang.Compiler.access$300 (Compiler.java:38)
clojure.lang.Compiler$DefExpr$Parser.parse (Compiler.java:596)
(ns water-towers.core)
(defn- find-deltas
"Find max possible water between this tower and its tallest left neighbor"
[xs]
(:deltas (reduce (fn [m x]
(let [left-bound (:max m)
delta-so-far (:deltas m)]
(if (< x left-bound)
{:max left-bound
@pastafari
pastafari / aliases.sh
Last active December 16, 2015 16:48
Useful aliases while running Vagrant on Virtual Box
# Vagrant aliases
alias vssh="vagrant ssh"
alias vup="vagrant up"
alias vhalt="vagrant halt"
alias vreload="vagrant reload"
# VirtualBox aliases
alias runningvms="VBoxManage list runningvms"
alias vms="VBoxManage list vms"
@pastafari
pastafari / stretch.applescript
Created September 17, 2012 19:01
Stand up and stretch reminder in Applescript
repeat
say "Stand up and Stretch"
delay 30 * 60 #time in seconds
end repeat
class Array
def transpose
empty? ? [] : inject {|memo, ary| memo.zip(ary)}.collect(&:flatten)
end
end
@pastafari
pastafari / sicp-1.5.scm
Created July 30, 2012 18:31
SICP Exercise 1.5
; First an observation:
; The abstraction 'p' yields itself parenthesized, i.e. p -> (p)
; If eval'ed, this will lead to a infinite recursion yielding (((((((.........(p).........)))))))
;
; Moving on to the abstraction 'test', it yields 0 if x is 0, or y otherwise
; Consider the expression: (test 0 (p))
; Consider the two cases:
; Applicative order evaluation:
; The operator evaluates to the body of the abstraction 'test'
; The first operand evaluates to 0
@pastafari
pastafari / sandwich_code.rb
Created July 15, 2011 13:40
Got Sandwich Code? Use blocks...
def method_that_takes_implicit_block
#do bread part of code here
yield
#remaining bread part
end
def method_that_takes_explicit_block(&block)
#do bread part of code here
block.call
#remaining bread part
end