Skip to content

Instantly share code, notes, and snippets.

View eneroth's full-sized avatar

Henrik Eneroth eneroth

View GitHub Profile
;; Load config
(defn load-config [config-path]
(let [ch (chan)]
(go
(let [{:keys [succeeded data]} (<! (path/resolve config-path))
abs-path data]
(if-not succeeded
(failure ch data (str "load-config: couldn't resolve path '" config-path "'"))
(let [{:keys [succeeded data]} (<! (file/read abs-path :utf-8))
config-content data]

Keybase proof

I hereby claim:

  • I am eneroth on github.
  • I am eneroth (https://keybase.io/eneroth) on keybase.
  • I have a public key ASAcj6_a7ptkxlPrJD0OE87QcZzU8sBMesZE5fUb5UH-7wo

To claim this, I am signing this object:

@eneroth
eneroth / Increment (Plain React).js
Last active February 19, 2021 11:14
Incrementing timer in React, in JavaScript and ClojureScript (Reagent)
var Timer = React.createClass({
getInitialState: function() {
return {secondsElapsed: 0};
},
tick: function() {
this.setState({secondsElapsed: this.state.secondsElapsed + 1});
},
componentDidMount: function() {
this.interval = setInterval(this.tick, 1000);
},
(defn add [a b]
(+ a b))
(let [add-1 (partial add 1)]
(println (add-1 6))
(println (add-1 12)))
(let [grunka #(mate (rand-nth fittest) (rand-nth fittest))
pryl (repeatedly num-matings grunka)]
(scores goal (mutate-population pryl)))
@eneroth
eneroth / gist:9261567
Last active August 29, 2015 13:56
Lyssna på enter (kolla konsollen)
;; Rendera en låda
;; ---------------
(defn command-box
[]
[:input#commandbox {}]) ;; "commandbox" är IDt
(render-component [command-box] (get-element "body"))
;; Lyssna på events fran elementet
;; -------------------------------