- Organizing larger applications
- Domain logic shouldn’t include handlers for bad/unclean data.
- validateur, bouncer, clj-schema for checking data going into the pipeline.
- domain-specific, semantic checks
- TODO: Any better ways for doing this conditional validation.
- Need to factor out common data cleaning utils into shared library.
This file contains hidden or 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
| ;; I wrote this in the Eurostar on my way back from the last lambdanext.eu clojure course. | |
| (ns comprehensions | |
| (:refer-clojure :exclude [for doseq]) | |
| (:require [clojure.core.reducers :as r])) | |
| ;; borrowed from clojure.core | |
| (defmacro ^{:private true} assert-args | |
| [& pairs] | |
| `(do (when-not ~(first pairs) |
This file contains hidden or 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
| (ns n01se.externs-for-cljs | |
| (:require [clojure.java.io :as io] | |
| [cljs.compiler :as comp] | |
| [cljs.analyzer :as ana])) | |
| (defn read-file [file] | |
| (let [eof (Object.)] | |
| (with-open [stream (clojure.lang.LineNumberingPushbackReader. (io/reader file))] | |
| (vec (take-while #(not= % eof) | |
| (repeatedly #(read stream false eof))))))) |
This file contains hidden or 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
| (ns async-test.core | |
| (:require [cljs.core.async :refer [chan]] | |
| [clojure.string :as string]) | |
| (:require-macros | |
| [cljs.core.async.macros :as m :refer [go alt! alts!]])) | |
| (def c (chan)) | |
| (def loc-div (.getElementById js/document "location")) | |
| (.addEventListener js/window "mousemove" |
This file contains hidden or 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
| ;; based on http://talks.golang.org/2012/concurrency.slide#50 | |
| (ns robpike | |
| (:require [cljs.core.async :as async :refer [<! >! chan close!]]) | |
| (:require-macros [cljs.core.async.macros :as m :refer [go alt!]])) | |
| (defn timeout [ms] | |
| (let [c (chan)] | |
| (js/setTimeout (fn [] (close! c)) ms) | |
| c)) |
This file contains hidden or 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
| (time | |
| (def data-thread | |
| (let [c (chan) | |
| res (atom [])] | |
| ;; fetch em all | |
| (doseq [i (range 10 100)] | |
| (thread (>!! c (blocking-get (format "http://fssnip.net/%d" i))))) | |
| ;; gather results | |
| (doseq [_ (range 10 100)] | |
| (swap! res conj (<!! c))) |
This file contains hidden or 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
| input { | |
| stdin {} | |
| file { | |
| type => "iis" | |
| path => "C:/inetpub/logs/LogFiles/W3SVC*/*.log" | |
| } | |
| } | |
| filter { |
This file contains hidden or 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
| (ns logic-ast.core | |
| (:refer-clojure :exclude [==]) | |
| (:require [clojure.java.io :as io] | |
| [clojure.pprint :as pp] | |
| [cljs.env :as env] | |
| [cljs.analyzer.utils :as u] | |
| [cljs.analyzer :as ana] | |
| [clojure.core.logic | |
| :refer [run run* conde == fresh lcons partial-map defne] :as l] | |
| [clojure.core.logic.pldb :as pldb])) |
This file contains hidden or 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
| (ns react-cljs.core | |
| (:require-macros [reactjs.macros :refer [pure]]) | |
| (:require React [reactjs.core :as r])) | |
| (enable-console-print!) | |
| (declare render-ui) | |
| (defn render-counter [id state cb] | |
| (pure state |
This file contains hidden or 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 a]) | |
| (def xform (comp (map inc) | |
| (filter even?) | |
| (dedupe) | |
| (flatmap range) | |
| (partition-all 3) | |
| (partition-by #(< (apply + %) 7)) | |
| (flatmap flatten) | |
| (random-sample 1.0) |
OlderNewer