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 micrograd | |
"autograd engine for scalar values and operations in the style of | |
https://github.com/karpathy/micrograd | |
but with immutable values.") | |
; Wrap a scalar `data` with some additional context | |
(defrecord Value [data grad children op op-deriv]) |
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 deploy | |
(:require [clojure.java.io :as io]) | |
(:import (software.amazon.awscdk App CfnOutput$Builder Stack) | |
(software.amazon.awscdk.services.apigatewayv2.alpha AddRoutesOptions HttpApi$Builder HttpMethod) | |
(software.amazon.awscdk.services.apigatewayv2.authorizers.alpha HttpIamAuthorizer) | |
(software.amazon.awscdk.services.apigatewayv2.integrations.alpha HttpAlbIntegration) | |
(software.amazon.awscdk.services.ec2 Vpc$Builder) | |
(software.amazon.awscdk.services.ecs Cluster$Builder ContainerImage) | |
(software.amazon.awscdk.services.ecs.patterns ApplicationLoadBalancedFargateService$Builder ApplicationLoadBalancedTaskImageOptions) | |
(software.amazon.awscdk.services.iam AnyPrincipal) |
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
;;; Transducers, but with state stored inside the "result" instead of in atoms | |
;;; / volatiles. | |
(defn map1 [f] | |
(fn [[rf idx]] | |
[(fn | |
([] (rf)) | |
([result] (rf result)) | |
([result input] (rf result (f input)))) | |
(inc idx)])) |
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
#!/usr/bin/env bb | |
; =========================================================================== ; | |
; FILE: hack-captive-portal.bb ; | |
; USAGE: sudo bb hack-captive-portal.bb ; | |
; ; | |
; DESCRIPTION: This script helps to pass through the captive portals in ; | |
; public Wi-Fi networks. It hijacks IP and MAC from somebody ; | |
; who is already connected and authorized on captive portal. ; | |
; Tested in Ubuntu 16.04 with different captive portals in ; | |
; airports and hotels all over the world. ; |
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 stock-chart-example | |
"Clojurescript + Reagent port of react-financial-charts StockChart.tsx | |
candles example[1][2]. | |
Assumes a project generated via https://github.com/bhauman/figwheel-main-template | |
with Reagent included, and https://github.com/react-financial/react-financial-charts | |
required via https://figwheel.org/docs/npm.html. | |
See also | |
- The BasicCandlestick.tsx[3] example |
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 deploy | |
(:import (software.amazon.awscdk App CfnOutput$Builder Stack) | |
(software.amazon.awscdk.services.apigatewayv2.alpha AddRoutesOptions HttpApi$Builder HttpMethod) | |
(software.amazon.awscdk.services.apigatewayv2.authorizers.alpha HttpIamAuthorizer) | |
(software.amazon.awscdk.services.apigatewayv2.integrations.alpha HttpAlbIntegration) | |
(software.amazon.awscdk.services.ec2 Vpc$Builder) | |
(software.amazon.awscdk.services.ecs Cluster$Builder ContainerImage) | |
(software.amazon.awscdk.services.ecs.patterns ApplicationLoadBalancedFargateService$Builder ApplicationLoadBalancedTaskImageOptions) | |
(software.amazon.awscdk.services.iam AnyPrincipal))) |
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 env | |
"Clojure hack to overwrite the JVM's System/getenv map for environment variables without touching the actual environment. Definitely not safe." | |
(:import (java.util Collections Map))) | |
(defn -unsafe-set-env [new-env] | |
(try | |
(let [clazz (Class/forName "java.lang.ProcessEnvironment")] | |
(doseq [field ["theEnvironment" "theCaseInsensitiveEnvironment"]] | |
(let [env-field (doto (.getDeclaredField clazz field) (.setAccessible true))] | |
(.putAll ^Map (.get env-field nil) new-env)))) |
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 poisson | |
"Return a function that samples from a Poisson distribution using Knuth's | |
algorithm[^1], given `lambda`, the expected number of occurrences per | |
interval. | |
[^1]: https://en.wikipedia.org/wiki/Poisson_distribution#Random_drawing_from_the_Poisson_distribution" | |
([lambda] | |
(poisson lambda (Random.))) | |
([lambda ^Random r] | |
(let [l (Math/exp (- lambda))] |
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 load-class | |
(:import (java.lang.reflect Array) | |
(java.io FileInputStream))) | |
;; ClassLoader/defineClass is protected, and calling it from the proxy requires | |
;; reflection. | |
(def ^:private classloader-define-class | |
(let [primitive-bytes (.getClass (Array/newInstance Byte/TYPE 0)) | |
args [String primitive-bytes Integer/TYPE Integer/TYPE]] | |
(doto |
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 web3 | |
"Call an Ethereum smart contract (Uniswap v2) from Clojure. | |
Requires https://github.com/clj-python/libpython-clj for python interop. Also | |
make sure to $ pip install web3." | |
(:require [libpython-clj2.python :as py] | |
[libpython-clj2.require :refer [require-python]])) | |
(comment ;; deps.edn |
NewerOlder