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
(use 'net.cgrand.enlive-html) | |
(import 'java.io.StringReader) | |
(defn enlive->hiccup | |
[el] | |
(if-not (string? el) | |
(->> (map enlive->hiccup (:content el)) | |
(concat [(:tag el) (:attrs el)]) | |
(keep identity) | |
vec) |
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 clean-ns [ns] | |
(let [vs (keys (ns-interns ns))] | |
(doseq [v vs] (ns-unmap ns v)) | |
vs)) |
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
(defmacro do-until [& clauses] | |
(when clauses | |
(list | |
`when (first clauses) | |
(if (next clauses) | |
(second clauses) | |
(throw (IllegalArgumentException. | |
"do-until requires an even number of forms"))) | |
(cons 'do-until (nnext clauses))))) |
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
(use 'ring.adapter.jetty) | |
(defn naked-handler [request] | |
{:status 200 | |
:headers {"Content-Type" "text/html"} | |
:body (str request}) | |
(def app #'naked-handler) | |
(defonce server (run-jetty #'app {:port 8080 :join? false})) |
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
var CLOSURE_NO_DEPS = true; | |
var COMPILED = false; | |
var goog = goog || {}; | |
goog.global = this; | |
goog.DEBUG = true; | |
goog.LOCALE = "en"; | |
goog.TRUSTED_SITE = true; | |
goog.provide = function(name) { | |
if (!COMPILED) { | |
if (goog.isProvided_(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
(def db (connect host port | |
{:schema {"app" ^{:strategy_class "NetworkTopologyStrategy" | |
:strategy_options {"dc1" 3, "dc2" : 2}} | |
{"Users" {"name" ^{:index_type :key | |
:index_name "user_name_idx"} | |
[:utf-8] | |
"age" [:long]}}}}))) |
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 hara.concurrent.workflow | |
(:require [hara.common.checks :refer [hash-map? promise?]] | |
[hara.common.primitives :refer [uuid]] | |
[hara.data.nested :refer [merge-nil-nested]] | |
[clojure.set :as set])) | |
(defn create-registry [] | |
(atom {:tickets {} | |
:tasks {} | |
:active #{} |
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
(import [bs4 [BeautifulSoup]] | |
[operator [itemgetter]] | |
requests) | |
(defn project-links [username] | |
(let [[url (+ "https://clojars.org/users/" username)] | |
[res (requests.get url)] | |
[soup (BeautifulSoup res.text)] | |
[links (-> (soup.find "h1") | |
(.find-next "h1") |
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 count-elements [coll1 coll2] | |
(+ (count coll1) (count coll2) 1)) | |
(defn count-elements-tester [f] | |
(let [n (rand-int 6) | |
m (rand-int 6) | |
output (+ n m) | |
inputs [(range n) (range m)] | |
actual (apply f inputs)] | |
(if (= actual output) |
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
(defrecord Simple [value]) | |
(deftype Basic [value]) | |
(with-out-str | |
(time | |
(dotimes [i 100000000] | |
(set! (Basic. i) :value (* 2 i))))) |
OlderNewer