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
(def data (zip/xml-zip | |
(xml/parse | |
(io/input-stream (io/resource "public/img/test.xml"))))) | |
(defn edit-text [loc] | |
(zip/edit | |
loc | |
(fn [l] (assoc-in l [:content] [(zip-xml/text loc)])))) |
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
clj-demgen.main> (cemerick.piggieback/cljs-repl (cljs.repl.rhino/repl-env)) | |
To quit, type: :cljs/quit | |
nil | |
cljs.user> (require '[cljs-time.core :as date]) | |
nil | |
cljs.user> (require '[cljs-time.format :as date-format])j | |
nil | |
cljs.user> (date-format/unparse (date-format/formatters :basic-date-time) | |
(date/today-at 12 00)) | |
org.mozilla.javascript.EcmaError: TypeError: Cannot call method "call" of null (rhino.clj#41) |
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 clj-demgen.util.fn-called | |
(:require [clojure.test :as t :refer [is deftest]])) | |
(defn fn-called? [f thunk] | |
(let [called (atom false)] | |
(with-redefs-fn {f (fn [& args] | |
(reset! called true))} | |
thunk) | |
@called)) |
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
(defproject awsome-todo "0.1.0-SNAPSHOT" | |
:description "FIXME: write this!" | |
:url "http://example.com/FIXME" | |
:license {:name "Eclipse Public License" | |
:url "http://www.eclipse.org/legal/epl-v10.html"} | |
:min-lein-version "2.5.3" | |
:dependencies [[org.clojure/clojure "1.7.0"] | |
[org.clojure/clojurescript "1.7.170"] |
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
(defn add-osx-watcher [f path] | |
(let [watcher (WatchService/newWatchService) | |
w (WatchableFile. (clojure.java.io/file path))] | |
(.register w | |
watcher | |
(into-array WatchEvent$Kind [StandardWatchEventKind/ENTRY_CREATE | |
StandardWatchEventKind/ENTRY_DELETE | |
StandardWatchEventKind/ENTRY_MODIFY])) | |
(wait-for-events watcher f))) |
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
curl -X POST -H "Content-type: multipart/form-data; boundary=--ABC" --data-binary @a.txt http://localhost:3000/ |
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
Transform | |
[{:role "SITE-ADMIN" :infocenter_id 2} | |
{:role "SITE-ADMIN" :infocenter_id 3}] | |
into | |
{:2 :SITE-ADMIN | |
:3 SITE-ADMIN} | |
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
(let [form (if (:privacy_policy ic-config) | |
(update-in form [:validations] | |
conj [:required [:privacy-policy] "Bitte Stimmen Sie der Datenschutzerklärung zu."]) | |
form)] | |
(if (:opt_in ic-config) | |
(update-in form [:validations] | |
conj [:required [:opt-in] "Bitte stimmen Sie dem Opt-In zu."]) | |
form)) |
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
(if foo-2 | |
(update-in (if foo-1 | |
(update-in coll conj foo1-related) | |
coll) | |
conj foo2-related)) |
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
(defn wrap-strip-context-path | |
"Strip context-path from all routes" | |
[handler] | |
(fn [in-req] | |
(cond (empty? @config/context-paths) | |
(handler in-req) | |
:else | |
(let [context (first (filter (complement nil?) | |
(map #(re-find (re-pattern %) | |
(:uri in-req)) |
NewerOlder