Please see the regular repo.
This file contains 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
;; parser combinators | |
(defn pred->parser | |
[pred] | |
(fn [[x & remaining :as input]] | |
(if (pred x) | |
[x remaining] | |
[::invalid input]))) | |
(defn alt |
This file contains 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
;; walk tree-ish vector with Zippers in recursive fashion | |
(defn walktree | |
[t] | |
(letfn [(inner [loc numbers] | |
(let [node (z/node loc) | |
numbers (conj numbers (if (sequential? node) (first node) node)) | |
loc (z/edit loc #(if (number? %) | |
(inc %) | |
(into [(inc (first %))] (rest %))))] |
This file contains 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
user> (def data {:x 110 ::old {:x 100}}) | |
#'user/data | |
user> (update-in data [::old] merge {:x 110 :z 5}) | |
{:user/old {:z 5, :x 110}, :x 110} | |
user> (-> data | |
(update-in [::old] merge {:x 110 :z 5}) | |
(merge {:x 200})) | |
{:user/old {:z 5, :x 110}, :x 200} | |
user> (defn update-keep-old | |
[m k v] |
This file contains 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 servint.core | |
(:require [org.httpkit.server :as server] | |
[org.httpkit.client :as client] | |
[clojure.core.async :as async :refer [go >! <!]] | |
[compojure.core :refer [defroutes GET]] | |
[compojure.route :as route] | |
[compojure.handler :as handler])) | |
;; A complete webapp that demonstrates how to asynchronously | |
;; query web services |
This file contains 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 snippets.decision-table) | |
;; a naive decision table implementation | |
(defn decision-table | |
[predicates actions & values] | |
{:preds predicates | |
:actions actions | |
:rows (partition-all (+ (count predicates) (count actions)) values)}) |
This file contains 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 snippets.mapping | |
(:require [clojure.string :as s])) | |
(defn as-vector | |
"Returns a vector from x | |
42 -> [42] | |
'(1 2 3) -> [1 2 3] | |
[:foo :bar] -> [:foo :bar]" | |
[x] |
This file contains 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 dbgists.core | |
"Demonstrates working with a DB connection." | |
(:require [clojure.java.jdbc :as jdbc]) | |
(:import [com.jolbox.bonecp BoneCPDataSource])) | |
;; to start H2 DB | |
#_ (do (require '[dbgists.h2 :as h2]) | |
(h2/start-db)) |
This file contains 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
;; put this into profiles.clj in ~/.lein folder | |
{:user {:jvm-opts ^:replace ["-Xmx6G" | |
"-XX:-OmitStackTraceInFastThrow"] | |
:repl-options {:timeout 180000} | |
:plugins [[cider/cider-nrepl "0.49.0"] | |
[refactor-nrepl "3.10.0"] | |
[jonase/eastwood "0.3.14"] | |
[lein-ancient "1.0.0-RC3"] | |
[lein-try "0.4.3"] | |
[lein-cloverage "1.0.13"] |
This file contains 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 helloweb.core | |
(:require [org.httpkit.server :as httpkit] | |
[compojure.handler :as handler] | |
[ring.util.response :refer [redirect response]] | |
[ring.util.codec :refer [url-encode]] | |
[hiccup.page :refer [html5]] | |
[hiccup.form :as f] | |
[compojure.core :refer [defroutes GET POST]] | |
[compojure.route :as route])) |