Skip to content

Instantly share code, notes, and snippets.

@visibletrap
visibletrap / deps.edn
Last active February 25, 2018 18:48
clj -Sdeps '{:deps {gist-visibletrap/git-6c21d7956211bcd30fc0a83ccea89455 {:git/url "https://gist.github.com/visibletrap/6c21d7956211bcd30fc0a83ccea89455" :sha "ac630e7d1d2f8e4174cc011386f66cecee4377d7"}}}' -m cljs.main -re node -m hello-cljs
{:paths ["."]
:deps {org.clojure/clojurescript
{:git/url "https://github.com/clojure/clojurescript"
:sha "3f4084efcb5cd92cceb8ca30765144691d8cfd7e"}}}
@visibletrap
visibletrap / deps.edn
Last active February 23, 2018 09:53
$ clojure -Sdeps '{:deps {gist-test {:git/url "https://gist.github.com/vi…/af6ba33c6a44bf97b7b013cd7441fbce" :sha "0adfc540f25ec7a9c7fc7972935025e10b5238ac"}}}' -m gist-test
{:paths ["."]
:deps {org.clojure/math.combinatorics {:mvn/version "0.1.4"}}}
{"white" #{"anti-flash" "antique" "beige" "blond" "cornsilk" "cosmic latte" "cream" "eggshell"
"floral" "ghost" "honeydew" "isabelline" "ivory" "lavender blush" "lemon chiffon"
"linen" "magnolia" "mint cream" "navajo" "old lace" "papaya whip" "peach" "pearl"
"seashell" "snow" "splashed" "vanilla" "white" "smoke"}
"yellow" #{"amber" "apricot" "arylide" "aureolin" "beige" "buff" "chartreuse" "citrine" "cream"
"dark goldenrod" "ecru" "flax" "gold" "gold (metallic)" "goldenrod" "harvest gold"
"jasmine" "jonquil" "khaki" "lemon chiffon" "lion" "maize" "mikado" "mustard" "naples"
"navajo white" "old gold" "olive" "papaya whip" "saffron" "school bus" "selective"
"stil de grain" "straw" "sunglow" "vanilla" "yellow"}
"gray" #{"ash" "battleship" "black" "blue-gray" "cadet" "charcoal" "cool" "davy's" "gray"
(defn collify [x-or-coll]
(if (coll? x-or-coll)
x-or-coll
[x-or-coll]))
(defn keyword->symbol [k]
(symbol (name k)))
(defmacro expand-set-values
[attributes]
@visibletrap
visibletrap / one-two-three.clj
Last active December 7, 2017 05:32
Input is a file contains html of comment section of this post https://www.facebook.com/roofimon.class/posts/10154689730497047
; :dependencies [[hickory "0.7.1"]]
(require '[clojure.pprint :refer [print-table]]
'[clojure.string :as string]
'[hickory.core :refer [as-hickory parse]]
'[hickory.select :as s])
(def choices #{"1 2 3" "2 3 1" "3 1 2" "1 3 2" "3 2 1" "2 1 3"})
(def meanings
(ns sof.async
(:require [ring.adapter.jetty :as jetty]
[clj-http.client :as client]
[ring.middleware.json :refer [wrap-json-response]]
[ring.util.response :refer [response]]))
(defn handler [request respond raise]
(client/get "http://example.com"
{:async? true}
(fn [response] (respond {:body "something"}))
@visibletrap
visibletrap / model.clj
Created September 19, 2017 16:21
ui/run-game
(ns clojure-playground.tap.model)
(def empty-board
[[:_ :_ :_]
[:_ :_ :_]
[:_ :_ :_]])
(def win-patterns
[[[0 0] [1 0] [2 0]]
[[0 1] [1 1] [2 1]]
(ns indent-tree.core
(:require [clojure.string :as string]))
(defn resolve-insert-path [full-tree level]
(:path
(reduce (fn [{:keys [path tree] :as current} n]
(let [after-last-child-pos (count (second tree))]
(if (= n 1)
(-> current
(update :path into [1 after-last-child-pos])
(ns notebook.core
(:require [clj-http.client :as http]
[clojure.data.json :as json]
[clojure.string :as string]))
(set! *print-length* -1)
(def notebooks (json/read-str (:body (http/get "https://notebookspec.com/api/notebook"))
:key-fn keyword))
(ns codebattle101
(:require [clojure.math.combinatorics :as math]))
(defn find-better [target best [a b] input-list]
(let [ab (* a b)]
(loop [[current-min-diff :as current-best] best
l 0
r (count input-list)]
(let [pos (quot (+ l r) 2)
c (get input-list pos)