Skip to content

Instantly share code, notes, and snippets.

View slagyr's full-sized avatar

Micah Martin slagyr

  • Clean Coders, LLC
  • Scottsdale, AZ
View GitHub Profile
@slagyr
slagyr / gist:41040748cf6335d01f1d
Created September 10, 2014 19:14
Bowling Game
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class GameTest
{
public Game game;
@slagyr
slagyr / gist:2aed1ccfd8ec702d7051
Created November 24, 2014 03:53
stubbing fns in another namespace
;; On the console:
;$ lein new speclj stubby
;; stubby/spec/stubby/core_spec.clj
(ns stubby.core-spec
(:require [speclj.core :refer :all]
[stubby.core :as p]))
(defn fn-under-test []
(p/foo))
(micahmartin) ~/Projects/clojure/clojurescript
$ ./script/repl
Clojure 1.6.0
user=> (require '[cljs.repl :as repl])
nil
user=> (require '[cljs.repl.rhino :as rhino])
nil
user=> (def env (rhino/repl-env))
#'user/env
user=> (repl/repl env)
(micahmartin) ~/Projects/clojure/clojurescript
$ ./script/repljs
To quit, type: :cljs/quit
ClojureScript:cljs.user> (str (ex-info "foo" {}))
org.mozilla.javascript.JavaScriptException: TypeError: Cannot call method "cljs$core$IPrintWithWriter$_pr_writer$arity$3" of undefined (<cljs repl>#12)
at <cljs repl>:12
at <cljs repl>:1
ClojureScript:cljs.user>
(micahmartin) ~/Projects/clojure/clojurescript
$ ./script/repljs
To quit, type: :cljs/quit
ClojureScript:cljs.user> (require '[cljs.closure :as cljsc])
clojure.lang.ExceptionInfo: No such namespace: cljs.closure at line 1 <cljs repl> {:tag :cljs/analysis-error, :file "<cljs repl>", :line 1, :column 1}
at clojure.core$ex_info.invoke(core.clj:4403)
at cljs.analyzer$error.invoke(analyzer.clj:307)
at cljs.analyzer$error.invoke(analyzer.clj:304)
at cljs.analyzer$analyze_deps.invoke(analyzer.clj:1117)
at cljs.analyzer$eval1661$fn__1663.invoke(analyzer.clj:1343)
  • Compiler in REPL seems broken: https://gist.github.com/slagyr/7d52ba4ba98e96172456
  • Not interested in Node.js so I skipped all that
  • Development Mode: Okay... this is where I'm confused.
    • The wiki says include 'hello.js'.
    • hello-dev.html explicitely includes goog.base.js.
    • hello-dev.html also requires hello.core.
    • The generated hello.js loads goog.base if it isn't already.
    • out/cljs_deps.js looks like cljsbuild's :output-to file
    • cljbuild doesn't generate anything like sample/hello.js
  • maybe I'll learn about all these difference later in the guide
@slagyr
slagyr / Application (Java) run configuration
Last active August 29, 2015 14:19
ANSI color example in IntelliJ/Cursive
Name: ansi
Main class: clojure.main
Program arguments: src/clj/ansi.clj
Working directory: <some path to configured project where you put ansi.clj>
(micahmartin) ~/Projects/clojure/speclj
$ lein deps :tree
warn
[clojure-complete "0.2.3" :scope "test" :exclusions [[org.clojure/clojure]]]
[fresh "1.1.1"]
[mmargs "1.2.0"]
[org.clojure/clojure "1.7.0-RC2"]
[org.clojure/clojurescript "0.0-3308"]
[com.google.javascript/closure-compiler "v20150505"]
[args4j "2.0.26"]
@slagyr
slagyr / gist:09e17d505af1bafa22ed
Created June 19, 2015 16:26
cljsbuild stacktrace
(micahmartin) ~/Projects/clojure/speclj
$ lein cljsbuild once dev
Compiling ClojureScript.
clojure.lang.Compiler$CompilerException: java.io.FileNotFoundException: Could not locate cljs/util__init.class or cljs/util.clj on classpath: , compiling:(cljs/closure.clj:1:1)
at clojure.lang.Compiler.load (Compiler.java:7142)
clojure.lang.RT.loadResourceScript (RT.java:370)
clojure.lang.RT.loadResourceScript (RT.java:361)
clojure.lang.RT.load (RT.java:440)
clojure.lang.RT.load (RT.java:411)
clojure.core$load$fn__5066.invoke (core.clj:5641)
one.rb -------------------
Java::Main.thing = "thing1"
two.rb -------------------
thing = Java::Main.thing
puts "thing: #{thing}"
puts "thing.class: #{thing.class}"