Skip to content

Instantly share code, notes, and snippets.

@Deraen
Deraen / rekekkonen.cljs
Created August 18, 2016 10:58
Kekkonen + Re-frame
(reg-event-fx :get-current-party
(fn [{:keys [db]} _]
{:db (assoc db :loading? true)
:kekkonen {:query :api.party/get-current-party
;; called with the body
:on-success [:set-current-party]
;; or simple assoc-in?
:on-success [:assoc-in [:current-party]]
}}))
@Deraen
Deraen / README.md
Last active August 10, 2016 10:44
Use project-name to generate IP's for vagrant boxes

Why

  • Static IPs with Vagrant clash easily with other projects
  • Dynamic IPs require using port forwards -> port forwards clash with local apps and other projects
  • Solution: Provide static IP which are calculated from project name, and then use vagrant-hostupdater to add name -> IP to hosts files for easy use
  • Uses 20 first bits from MD5 hash of the name to build IPv4 in Class B private network (smaller addres space than Class A, but rarely used)
(defn animated-component []
(let [fade-anim (ui/animated-value. 0)]
(r/create-class
{:component-did-mount
(fn [this]
(-> ui/animated
(.timing fade-anim #js {:toValue 1
:duration 3000})
(.start)))
(ns foobar.font-awesome
(:require [cljsjs.react]))
(defn icon [{:keys [name class size rotate flip fixed-width spin pulse stack inverse component]
:or {component :span}
:as props}]
[component
(assoc props
:class (str "fa fa-" class " "
(if size (str "fa-" size)) " "
@Deraen
Deraen / spec-coercion.clj
Created June 14, 2016 15:47
Clojure.spec coercion test
(ns spec-test.core
(:require [clojure.spec :as s]))
(defn x-integer? [x]
(if (integer? x)
x
(if (string? x)
(try
(integer/parseint x)
(catch exception e
@Deraen
Deraen / build.boot
Last active June 3, 2016 15:07
Thinking about Cider boot-cljs-repl env
;; Called from nREPL started by cider-jack-in
(deftask cider-dev []
(comp
(watch)
(cljs-repl-env) ;; Creates Piggieback env for use in existing nREPL
(reload)
(less)
(cljs)))
;; Called from terminal
@Deraen
Deraen / readme.md
Last active April 12, 2016 13:44
Clojure-web-formats

Built from the ashes of https://github.com/ngrunwald/ring-middleware-format

Separated concerns:

  • Content negotation
    • Low level functions?
    • Higher level functions for using with Ring request maps?
    • Separate namespaces for low-level and Ring stuff?
  • Format encoding/decoding implementations
  • Formatters?
var db = new PouchDB('mydb');
db.post({}).then(function (result) { // post a new doc
return db.get(result.id); // fetch the doc
}).then(function (doc) {
console.log(doc); // log the doc
}).catch(function (err) {
console.log(err); // log any errors
});
@Deraen
Deraen / vim-lightning-talk.md
Last active May 5, 2016 08:31
VIM Lightning talk
 __      _______ __  __            _____ _       _
 \ \    / /_   _|  \/  |    _     / ____| |     (_)
  \ \  / /  | | | \  / |  _| |_  | |    | | ___  _ _   _ _ __ ___
   \ \/ /   | | | |\/| | |_   _| | |    | |/ _ \| | | | | '__/ _ \
    \  /   _| |_| |  | |   |_|   | |____| | (_) | | |_| | | |  __/
     \/   |_____|_|  |_|          \_____|_|\___/| |\__,_|_|  \___|
                                               _/ |
                                              |__/

Keybase proof

I hereby claim:

  • I am Deraen on github.
  • I am juhoteperi (https://keybase.io/juhoteperi) on keybase.
  • I have a public key whose fingerprint is 5DDB C334 3CEC 9A95 AB02 72C9 0942 2480 8950 366D

To claim this, I am signing this object: