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
(function () { | |
'use strict'; | |
/** | |
* wraps a promise in a timeout, allowing the promise to reject if not resolve with a specific period of time | |
* @param {integer} ms - milliseconds to wait before rejecting promise if not resolved | |
* @param {Promise} promise to monitor | |
* @example | |
* promiseTimeout(1000, fetch('https://courseof.life/johndoherty.json')) |
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
$ cat .git/hooks/pre-commit | |
#!/bin/bash | |
FOUND=$(git diff-index --cached -U0 HEAD -- | grep DONOTCOMMIT | wc -l) | |
if [[ $FOUND -gt 0 ]]; then | |
echo "pre-commit hook: DONOTCOMMIT detected, commit not allowed" | |
exit 1 | |
fi |
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 datomic.schema-dump | |
(:require | |
[datomic.api :as d] | |
[clojure.pprint])) | |
(defmethod clojure.pprint/simple-dispatch datomic.db.DbId [v] (pr v)) | |
(defmethod clojure.pprint/simple-dispatch datomic.function.Function [v] (pr v)) | |
(defn database-url [name] | |
(str "datomic:mem://" name)) |
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
; as an introduction, we tried to do string capitalization by hand, | |
; using as many different interesting idioms as possible | |
(defn capitalize-char [c] | |
(if (Char.lower-case? c) | |
(=> c | |
(to-int) | |
(- 32) | |
(from-int)) | |
c)) |
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 my-component [props context updater] | |
(cljs.core/this-as this | |
(js/React.Component.call this props context updater) | |
;; anything else you want to set-up. use goog.object/set on this | |
this)) | |
(gobj/extend | |
(.. my-component -prototype) | |
js/React.Component.prototype) |
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 -Sdeps '{:deps {friendly {:git/url "https://gist.github.com/bhb/2686b023d074ac052dbc21f12f324f18" :sha "c6b0b7cb0a30e2edbf7050c0119ef038cf0f0ac2"}}}' -m friendly | |
user=> (let [:x 5] x) | |
Call to clojure.core/let did not conform to spec: | |
-- Spec failed -------------------- | |
([:x 5] x) | |
^^ | |
should satisfy |
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 com.nextjournal.build-tools.figwheel.dependency | |
(:require [clojure.tools.namespace.track :as ctn.track] | |
[clojure.tools.namespace.dir :as ctn.dir] | |
[clojure.tools.namespace.file :as ctn.file] | |
[clojure.tools.namespace.dependency :as ctn.dep] | |
[clojure.tools.namespace.parse :as ctn.parse] | |
[clojure.tools.namespace.find :as ctn.find] | |
[clojure.java.io :as io] | |
[clojure.tools.reader :as reader]) | |
(:import java.io.PushbackReader)) |
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 class-names [& args] | |
(clojure.string/join " " | |
(mapv name | |
(reduce (fn [arr arg] | |
(cond | |
(or (string? arg) | |
(symbol? arg) | |
(keyword? arg)) (conj arr arg) | |
(vector? arg) (vec (concat arr arg)) | |
(map? arg) (vec (concat arr |
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 kw-cache #js{}) | |
(defn cached-kw [fqn] | |
(if-some [kw (unchecked-get kw-cache fqn)] | |
kw | |
(let [kw (keyword fqn)] | |
(unchecked-set kw-cache fqn kw) | |
kw))) | |
(defn js->clj-fast |
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 app.components.react-bootstrap | |
(:require [cljsjs.react-bootstrap] | |
[reagent.core :as r])) | |
(def Alert (r/adapt-react-class (.-Alert js/ReactBootstrap))) | |
(def Button (r/adapt-react-class (.-Button js/ReactBootstrap))) | |
; ... | |
(def FormControl (r/adapt-react-class (.-FormControl js/ReactBootstrap))) ; WARNING: use FormControlFixed for text input controls instead | |
(defn FormControlFixed |