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 'faces) | |
(require 'color) | |
(require 'dash) | |
(unless (require 'xterm-color nil t) | |
(require 'ansi-color)) | |
(defvar rainbow-keys-font-lock-keywords | |
'((":\\([-a-zA-Z0-9\\$\\?\\_\\*\\!\\.]+\\)/\\([-a-zA-Z0-9\\$\\?\\_\\*\\!]+\\)" | |
(2 (colorize-ns-keyword 2))) |
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 compound.core | |
(:refer-clojure :exclude [get-in update-in assoc-in])) | |
(def ^:private index-permutations | |
(memoize | |
(fn permutations [coll] | |
(if (= 1 (count coll)) | |
(list coll) | |
(for [head coll | |
tail (permutations (disj (set coll) head))] |
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 compound.core | |
(:require [clojure.spec :as s] | |
[clojure.set :as set] | |
[clojure.test :as test :refer [deftest is]])) | |
(defn find-index-def [index-defs index] | |
(some #(when (= (:index %) index) %) index-defs)) | |
(defn index-unique | |
"Like set/index, but for unique indexes, so the vals are just maps, not |
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 compound.core) | |
(def ^:private meta-index-defs | |
[{:id :id | |
:index-fn :id | |
:unique? true} | |
{:id :unique? | |
:index-fn :unique? | |
:unique? false}]) |
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 compound.core | |
(:require [clojure.spec.alpha :as s])) | |
(s/def ::address | |
int?) | |
(s/def ::compound | |
(s/cat :m map? :v vector?)) |
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
(rf/reg-event-fx | |
:auth | |
(fn [{:keys [db]} _] | |
{:POST | |
{:url "https://api.intra.42.fr/oauth/token" | |
:on-success [:auth/response-received] | |
:on-fail :auth-nok | |
:params | |
{:grant_type "client_credentials" | |
:client_id "secret" |
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
(rf/reg-fx | |
:POST | |
;; on-success is a reframe event vector [:foo/bar ...] | |
(fn [{:keys [url params on-success on-fail]}] | |
(take! (http/post url {:form-params params}) | |
;; conj the results into it so the response gets put into the event | |
;; like this: | |
;; [:foo/bar <result>] | |
#(re-frame.core/dispatch (conj on-success %))) |
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 compound9.core | |
(:refer-clojure :exclude [get])) | |
(defmulti add | |
(fn [index-primary indexes index-def items] | |
(clojure.core/get index-def :compound.index/type))) | |
(defmulti remove | |
(fn [index-primary indexes index-def items] | |
(clojure.core/get index-def :compound.index/type))) |
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 compound.indexes | |
(:require [clojure.set :as set])) | |
(defprotocol IIndexPrimary | |
(-get-primary [this ks]) | |
(-add [this items]) | |
(-remove [this ks])) | |
(defprotocol IIndexSecondary | |
(-get-secondary [this ks]) |
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
# Show the process that is listening on the port | |
portpid () { | |
lsof -i 4tcp:$1 -sTCP:LISTEN -Fp | cut -c 2- | |
} | |
# thanks @bronsa |