This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cljs.user=> (defn foo [] (loop [i 1] (if (>i 10) i (recur (inc i))))) | |
#'cljs.user/foo | |
cljs.user=> foo | |
#object[cljs$user$foo "function cljs$user$foo(){ | |
var i = 1; | |
while(true){ | |
if(cljs.core.truth_(cljs.user._GT_i.call(null,10))){ | |
return i; | |
} else { | |
var G__23 = (i + 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn- make-stylesheet [link] | |
[:link {:rel "stylesheet" :href link}]) | |
;; Programatic style | |
[:body (into [:head] (map make-stylesheet ["foo.css" "bar.css"])) | |
[:p "content"]] | |
;; Syntax-quote style | |
`[:body [:head ~@(map make-stylesheet ["foo.css" "bar.css"])] | |
[:p "content"]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user=> (macroexpand-1 '(async/go (inc 1))) | |
(clojure.core/let [c__12900__auto__ (clojure.core.async/chan 1) captured-bindings__12901__auto__ (clojure.lang.Var/getThreadBindingFrame)] (clojure.core.async.impl.dispatch/run (clojure.core/fn [] (clojure.core/let [f__12902__auto__ (clojure.core/fn state-machine__12729__auto__ ([] (clojure.core.async.impl.ioc-macros/aset-all! (java.util.concurrent.atomic.AtomicReferenceArray. 7) 0 state-machine__12729__auto__ 1 1)) ([state_7171] (clojure.core/let [old-frame__12730__auto__ (clojure.lang.Var/getThreadBindingFrame) ret-value__12731__auto__ (try (clojure.lang.Var/resetThreadBindingFrame (clojure.core.async.impl.ioc-macros/aget-object state_7171 3)) (clojure.core/loop [] (clojure.core/let [result__12732__auto__ (clojure.core/case (clojure.core/int (clojure.core.async.impl.ioc-macros/aget-object state_7171 1)) 1 (clojure.core/let [inst_7169 (do (inc 1))] (clojure.core.async.impl.ioc-macros/return-chan state_7171 inst_7169)))] (if (clojure.core/identical? result__12732__au |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Core | |
(defn- maplast | |
"Apply map-fn to the last element in s | |
unless s contains only 1 element" | |
[map-fn s] | |
(if (> (count s) 1) | |
(conj (vec (butlast s)) | |
(map-fn (last s))) | |
s)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Add the resulting vector to `:aot` on your dev profile | |
(def directory ".") | |
(defn- read-file [file] | |
(binding [*read-eval* false] | |
(read-string (slurp file)))) | |
(defn- require-form? [form] | |
(and (seq? form) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '[clojure.core.async :as async] | |
'[clj-http.client :as client] | |
'[clojure.data.json :as json]) | |
(def concurrency 5) | |
(let [in (async/chan) | |
out (async/chan) | |
request-handler (fn [url out*] | |
(async/go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
irb(main):002:0> Ripper.sexp "'foo'" | |
=> [:program, [[:string_literal, [:string_content, [:@tstring_content, "foo", [1, 1]]]]]] | |
irb(main):003:0> Ripper.sexp '"foo"' | |
=> [:program, [[:string_literal, [:string_content, [:@tstring_content, "foo", [1, 1]]]]]] | |
irb(main):004:0> Ripper.sexp '"#{foo}"' | |
=> [:program, [[:string_literal, [:string_content, [:string_embexpr, [[:vcall, [:@ident, "foo", [1, 3]]]]]]]]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NilClass | |
def to_a | |
p 'calling to_a within NilClass' | |
[] | |
end | |
end | |
# irb(main):017:0> [*nil] | |
# "calling to_a within NilClass" | |
# => [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Parse results for Rails | |
user system total real | |
"Codeminer parse results: 0 parse errors, 0 runtime errors, 1621 files total" | |
7.760000 0.080000 7.840000 ( 7.980644) | |
"Codeminer sexp results: 0 parse errors, 0 runtime errors, 1621 files total" | |
11.080000 0.040000 11.120000 ( 11.136238) | |
"Codeminer (RubyParser compatible) sexp results: 0 parse errors, 0 runtime errors, 1621 files total" | |
11.250000 0.070000 11.320000 ( 11.317630) | |
"Codeminer flog results: 0 parse errors, 0 runtime errors, 1621 files total" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example 1: Swap the consequence and else statements in an if expression | |
if_node = CodeMiner.parse(<<-RUBY).each.first | |
if foo | |
begin | |
do_something | |
end | |
else | |
do_something_else | |
end |
NewerOlder