Skip to content

Instantly share code, notes, and snippets.

@auramo
auramo / gist:a2e515973b4168396dd1
Last active March 15, 2017 11:03
ClojureScript Protocol and Deftype View example
(defprotocol View
"View abstraction"
(render [this some-param] "Renders view")
(destroy [_] "Destroys view, runs cleanup"))
(deftype ProjectView [data]
View
(render [this some-param] [:h1 (str "Hello " (:name data) " some param we passed in " some-param)])
(destroy [_] (println "Cleaning up")))
(ns example.core
(:require [reagent.core :as reagent :refer [atom]]))
(enable-console-print!)
(defonce atom1 (atom 1))
(defonce atom2 (atom 2))
(defn handle-file [root stat next]
(println "handle file")
(ns example.core
(:require [reagent.core :as reagent :refer [atom]]))
(enable-console-print!)
(defonce atom1 (atom 1))
(defonce atom2 (atom 2))
(defn handle-file [root stat next]
(println "handle file")
@auramo
auramo / gist:aea73858ca3a000d44a6
Created March 23, 2015 07:01
clojurescript compilation exception
Exception in thread "main" java.lang.Exception: Unsupported binding form: :as, compiling:(cljs/closure.clj:1127:1)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6567)
at clojure.lang.Compiler.analyze(Compiler.java:6361)
at clojure.lang.Compiler.analyze(Compiler.java:6322)
at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5708)
at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5139)
at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3751)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6558)
at clojure.lang.Compiler.analyze(Compiler.java:6361)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6548)
var myUtil = (function() {
function doStuffToDate(date) {}
...
return { doStuffToDate: doStuffToDate, //other public funcs }
})();
myUtil.doStuffToDate(date); //use
var dstd = myUtil.doStuffToDate; //"import"
//You can also "inline" the implementations if they're short
var initGlobalize = function() {
function init(callbacks) {
$.when(
$.get("/cldr/main/fi/ca-gregorian.json"),
$.get("/cldr/main/fi/currencies.json"),
$.get("/cldr/main/fi/numbers.json"),
$.get("/cldr/supplemental/currencyData.json"),
$.get("/cldr/supplemental/likelySubtags.json"),
$.get("/cldr/supplemental/timeData.json"),
$.get("/cldr/supplemental/weekData.json")
function argumentsMapExample() {
_.map(arguments, function(arg) { console.log(arg); })
}
@auramo
auramo / gist:7ebc10d971802106d15a
Created July 10, 2014 11:29
Javascript JQuery Deferred promise ajax stuff
function bindBarCodeValidation() {
$('#shoppingcart').debounced('input keyup', 'input[name="barcode"]', onSchedule, onFire, 500, rowIdentity);
function onSchedule() {
$(this).addClass('input-loader');
return true;
}
function onFire() { validateBarcode($(this)); }
> android:run
[info] Updating {file:/Users/auramo/src/allacca/}allacca...
[info] Resolving jline#jline;2.11 ...
[info] Done updating.
[info] Collecting resources
[info] Performing full resource merge
[info] Generating R.java
[info] Packaging resources: resources-debug.ap_
[info] Rebuilding all classes because R.java has changed
[info] Regenerating TR.scala because R.java has changed
Warning: org.scalatest.tools.StatusJPanel: can't find referenced class javax.swing.JLabel
Warning: org.scalatest.tools.StatusJPanel: can't find referenced class javax.swing.JLabel
Warning: org.scalatest.tools.StatusJPanel: can't find referenced class javax.swing.JLabel
Warning: org.scalatest.tools.StatusJPanel: can't find referenced class javax.swing.JLabel
Warning: org.scalatest.tools.StatusJPanel: can't find referenced class javax.swing.JLabel
Warning: org.scalatest.tools.StatusJPanel: can't find referenced class javax.swing.JLabel
Warning: org.scalatest.tools.StatusJPanel: can't find referenced class javax.swing.JLabel
Warning: org.scalatest.tools.StatusJPanel: can't find referenced class javax.swing.JLabel
Warning: org.scalatest.tools.StatusJPanel: can't find referenced class javax.swing.JLabel
Warning: org.scalatest.tools.StatusJPanel: can't find referenced class javax.swing.JLabel