Dependency:
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
(comment | |
;; Starting the REPL with `clojure -J-Djdk.tracePinnedThreads=full -J--enable-preview ...` | |
(.start (Thread/ofVirtual) | |
(fn [] | |
(doall | |
;; LazySeq: | |
(map | |
(fn [n] | |
(Thread/sleep 1) |
This describes how I setup Atom for an ideal Clojure development workflow. This fixes indentation on newlines, handles parentheses, etc. The keybinding settings for enter (in keymap.cson) are important to get proper newlines with indentation at the right level. There are other helpers in init.coffee and keymap.cson that are useful for cutting, copying, pasting, deleting, and indenting Lisp expressions.
The Atom documentation is excellent. It's highly worth reading the flight manual.
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 example | |
(:require [clara.rules :refer :all])) | |
(def view-counts | |
{123 1000}) | |
(def view-event | |
{:type :view-event | |
:video 123}) |
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
(require '[datomic.api :as d] | |
'[clojure.string :as str]) | |
(defn normalize-query | |
"Turns a vector formatted Datomic datalog query into a map formatted | |
one." | |
[query] | |
(let [pairs (partition-by keyword? query)] | |
(assert (even? (count pairs))) | |
(into |
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 io-map | |
([number-of-threads f seq] | |
(let [executor (java.util.concurrent.Executors/newFixedThreadPool number-of-threads) | |
results (.invokeAll executor (map (fn [x] #(f x)) seq)) | |
result (doall (map deref results))] | |
(.shutdown executor) | |
result)) | |
([f seq] (io-map 50 f seq))) |
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
#!/bin/bash | |
temp_dir=`mktemp -d -t repo` | |
echo $temp_dir | |
git clone --bare $1 $temp_dir | |
cd $temp_dir |
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
#!/bin/bash | |
# 25 minutes | |
sleep 1500 && osascript -e 'tell app "System Events" to display dialog "Pomodoro: 25 minutes are over"' & |
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 sortable-table.core | |
(:require [reagent.core :as reagent :refer [atom]])) | |
(def data | |
(atom | |
{:header ["Id" "Name" "City"] | |
:rows [["1" "Joe" "New York"] | |
["2" "Harry" "Boston"] | |
["3" "Alicia" "Miami"]]})) |
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 [[1 2] [11 22] [111 222]]) | |
(defn combine [a b] | |
(mapcat | |
(fn [x] | |
(map | |
(fn [y] | |
(flatten [x y])) | |
b)) | |
a)) |
NewerOlder