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 c26 | |
(:require [cljc.java-time.local-date :as ld] | |
[clojure.math :as math] | |
[clojure.test :refer [are testing]])) | |
(def years-bc 1166) | |
(def seasons ["Chaos" "Discord" "Confusion" "Bureaucracy" "The Aftermath"]) | |
(def weekdays ["Sweetmorn" "Boomtime" "Pungenday" "Prickle-Prickle" "Setting Orange"]) | |
(def apostles ["Mungday" "Mojoday" "Syaday" "Zaraday" "Maladay"]) |
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 c20 | |
(:require | |
[next.jdbc :as jdbc] | |
[honey.sql :as sql] | |
[tick.core :as t] | |
[next.jdbc.date-time] | |
[clojure.test :refer [is use-fixtures deftest]])) | |
(def db-spec | |
{:dbtype "postgres" |
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 c13 | |
(:require | |
[clojure.string :as str] | |
[clojure.spec.alpha :as s] | |
[clojure.test :refer [testing is]] | |
[clojure.test.check :as check] | |
[clojure.test.check.generators :as gen] | |
[clojure.test.check.properties :as prop] | |
[com.gfredericks.test.chuck.generators :as gen'])) |
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 c11 | |
(:require | |
[clojure.spec.alpha :as s] | |
[clojure.walk :as walk] | |
[clojure.math :as math] | |
[clojure.test :as t])) | |
(def ops #{\* \/ \+ \- \^}) | |
(defn coerce [token] |
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 c6 | |
(:require | |
[camel-snake-kebab.core :as csk] | |
[clojure.data.json :as json] | |
[clojure.string :as str] | |
[clojure.test :refer [are is testing]] | |
[babashka.fs :as fs] | |
[babashka.http-client :as http] | |
[malli.core :as m] | |
[malli.dev.pretty :as pretty] |
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
#!/usr/bin/env bb | |
(ns c2 | |
(:require [babashka.fs :as fs])) | |
(def start (first *command-line-args*)) | |
(defn line-prefix [levels] | |
(apply str | |
(for [[global-level written] (map-indexed vector levels) | |
:let [global-level (inc global-level) |
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
const delay = (ms) => new Promise((res) => setTimeout(res, ms)); | |
const createWindowedFetch = (windowSize = 1000, reqPerWindow = 30) => { | |
const slots = [0]; | |
const start = new Date().getTime(); | |
let lastSlot = start; | |
return async (url, requestInit) => { | |
let firstFreeSlotIndex = slots.findIndex( | |
(allocated) => allocated < reqPerWindow |
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
function forEachInList(list, fn) { | |
if (!list) return null; | |
let current = list; | |
let i = 0; | |
while(true) { | |
fn(current.data, i, current, list); | |
if (!current.next) break; | |
current = current.next; | |
i++; | |
} |
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
function forEachInList(list, fn) { | |
let current = list; | |
let i = 0; | |
while(true) { | |
fn(current.data, i, current.node, list); | |
if (!current.next) break; | |
current = current.next; | |
i++; | |
} | |
} |
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
(defn sleep [s] | |
(-> (asyncio/sleep s) | |
(pp/then (fn [_] s)))) | |
(defn fun [] | |
(pp/let [x (sleep 1) | |
z (pp/resolved 5) | |
y (sleep 2)] | |
(+ x y z))) |
NewerOlder