Skip to content

Instantly share code, notes, and snippets.

@Deraen
Deraen / Vagrantfile
Created December 14, 2014 00:05
Testing boot
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
$script = <<SCRIPT
apt-get install -y git maven openjdk-7-jdk
(
cd /usr/local/bin
wget https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein -O lein
chmod +x lein
)
@Deraen
Deraen / README.md
Created December 14, 2014 11:52
Necessitate.js, POC JS modules

Feb 2014, not used, not maintained

Necessitate.js

Does RequireJS seem to complicated? You don't like that Browserify requires compilation while developing?

This is a library to implement simple modules.

  • Function params used to define dependencies
@Deraen
Deraen / angular-filesize.js
Last active July 5, 2017 15:14 — forked from thomseddon/gist:3511330
Humanize filesize
app.filter('bytes', function() {
return function(bytes, precision) {
if (isNaN(parseFloat(bytes)) || !isFinite(bytes)) return '-';
if (typeof precision === 'undefined') precision = 1;
var units = ['bytes', 'kB', 'MB', 'GB', 'TB', 'PB'];
var number = Math.floor(Math.log(bytes) / Math.log(1024));
return (bytes / Math.pow(1024, Math.floor(number))).toFixed(precision) + ' ' + units[number];
};
});
@Deraen
Deraen / NOTES.md
Last active August 29, 2015 14:12
Clojure Schema/Validation Libs

Notes

  • Most libraries do only validation. Schema does also coercion.

Pros:

  • Schemas are represented using collections and maps etc.
  • It's easy to modify existing schemas using general fns:
@Deraen
Deraen / build.boot.clj
Last active August 29, 2015 14:12
Cljsjs
(set-env!
:resource-paths #{"resources"}
:dependencies '[[adzerk/bootlaces "0.1.8" :scope "test"]])
(require '[adzerk.bootlaces :refer :all])
(def +version+ "2.6.0-0")
(bootlaces! +version+)
(task-options!
[clj-pdf "1.11.21" :exclusions [org.apache.xmlgraphics/batik-gvt]]
[org.apache.xmlgraphics/batik-gvt "1.7" :exclusions [org.apache.xmlgraphics/batik-bridge]]
[org.apache.xmlgraphics/batik-bridge "1.7" :exclusions [org.apache.xmlgraphics/batik-gvt org.apache.xmlgraphics/batik-script org.apache.xmlgraphics/batik-anim]]
[org.apache.xmlgraphics/batik-script "1.7" :exclusions [org.apache.xmlgraphics/batik-bridge]]
[org.apache.xmlgraphics/batik-anim "1.7" :exclusions [org.apache.xmlgraphics/batik-svg-dom]]
[org.apache.xmlgraphics/batik-svg-dom "1.7" :exclusions [org.apache.xmlgraphics/batik-svg-dom]]
@Deraen
Deraen / user.clj
Last active August 29, 2015 14:13
Set c.t.n refresh dirs, boot & lein. Ignores dirs where `.no-reload` file exists.
(ns user
(:require [clojure.tools.namespace.repl :as ns-tools]
[clojure.string :as string]
[clojure.java.io :as io]))
(ns-tools/disable-reload!)
(let [reload-dirs (->> (or (try
(require 'boot.core)
((resolve 'boot.core/get-env) :directories)
@Deraen
Deraen / random.clj
Created January 12, 2015 16:46
Random Clj notes
; Quoting symbols in collection before passing them to eval so that they are quoted when evaluated
(let [test #{'a 'b 'c}] `(println ~@(map #(eval `''~%) test)))
; => (clojure.core/println (quote a) (quote c) (quote b))
@Deraen
Deraen / pikaday.deps.cljs
Last active August 29, 2015 14:14
pikaday.deps.cljs
{:foreign-libs [{:file "cljsjs/common/pikaday.inc.js"
:provides ["org.pikaday"]}
{:file "cljsjs/common/pikaday.inc.js"
:requires ["org.moment"]
:provides ["org.pikaday.with-moment"]}]
:externs ["cljsjs/common/pikaday.ext.js"]}
@Deraen
Deraen / profile.cljs
Last active August 29, 2015 14:16
Silk Om routing
(ns foobar.ui.view.profile ...)
(defmethod r/route-change :profile-view
[data]
(go
(let [resp (<! (http/get "/api/users/current" {:ref "nav"}))]
(swap! app/app assoc :profile (-> (:body resp)
(f/->form-state domain/User))))
data))