Skip to content

Instantly share code, notes, and snippets.

;;=============== play with flow ==============
(require '[clojure.core.async :as async]
'[clojure.core.async.flow :as flow]
'[clojure.pprint :as pp]
'[clojure.datafy :as d]
'[clojure.walk :as w])
(set! *warn-on-reflection* true)
(defn monitoring [{:keys [report-chan error-chan]}]
@leonoel
leonoel / prepl.clj
Last active February 21, 2024 16:47
Example of clojure prepl usage with missionary
(ns prepl
(:require [clojure.core.server :as s]
[missionary.core :as m])
(:import (java.io PipedReader PipedWriter)
(java.util.concurrent Executors)))
(defn remote "
Returns a function taking a `java.io.PipedWriter` and returning a flow connecting to a remote prepl on given `host` and
`port`, sending the content of the pipe to the remote peer and emitting received evaluation results. The pipe is closed
on flow cancellation.
@SMUsamaShah
SMUsamaShah / list_of_p2p_file_sharing.md
Last active May 15, 2025 00:44
List of P2P file sharing tools

Browser Based

  1. Web Wormhole https://webwormhole.io/ https://github.com/saljam/webwormhole
  2. ToffeeShare https://toffeeshare.com/
  3. FilePizza https://file.pizza/
  4. ShareDrop sharedrop.io https://github.com/szimek/sharedrop (SOLD, not recommended, use one of the forks)
    1. A clone SnapDrop snapdrop.net https://github.com/RobinLinus/snapdrop (SOLD, not recommended, use one of the forks)
      1. A fork PairDrop https://pairdrop.net/ https://github.com/schlagmichdoch/pairdrop
  5. Instant.io https://instant.io/
  6. FileTC https://file.tc/
@onetom
onetom / dialog.clj
Created June 30, 2023 17:49
Pop up an Apple Script Yes/No dialog from Clojure
(ns dialog
"Display a Yes/No dialog, which appears on the very top of every app and grabs
the focus and also gives it back to the REPL, after making the choice, unlike
a Swing dialog, for example.
It's useful for confirming irreversible operations, like file or DB deletion.
It uses AppleScript, so it only works on macOS and on a local REPL."
(:require
[clojure.java.shell :as shell]))
@matthewdowney
matthewdowney / micrograd.clj
Created May 3, 2023 18:17
karpathy's micrograd values in Clojure
(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])
@chase-lambert
chase-lambert / chatgpt-cli.clj
Last active June 7, 2023 08:35
chatGPT API cli
#!/usr/bin/env bb
;; You need to have an OpenAI API key and set it like:
;; export OPENAI_API_KEY=<your key> in your .bashrc
;;
;; Make sure you have babashka installed
;; https://github.com/babashka/babashka#installation
;;
;; One way to run this is to install bbin
;; https://github.com/babashka/bbin
@ssrihari
ssrihari / clojure-learning-list.md
Last active May 16, 2025 11:33
An opinionated list of excellent Clojure learning materials

An opinionated list of excellent Clojure learning materials

These resources (articles, books, and videos) are useful when you're starting to learn the language, or when you're learning a specific part of the language. This an opinionated list, no doubt. I've compiled this list from writing and teaching Clojure over the last 10 years.

  • 🔴 Mandatory (for both beginners and intermediates)
  • 🟩 For beginners
  • 🟨 For intermediates

Table of contents

  1. Getting into the language
// I had been intending for people to just play around with this for fun and for personal use,
// but I've been advised to remove the first portion due to regulatory uncertainty.
// This way people can still use the merge check however they want.
/** @notice Determine whether we're running in Proof of Work or Proof of Stake
@dev Post-merge, the DIFFICULTY opcode gets renamed to PREVRANDAO,
and stores the prevRandao field from the beacon chain state if EIP-4399 is finalized.
If not the difficulty must be be 0 according to EIP-3675, so both possibilities are checked here. */
function haveWeMergedYet() public view returns (bool) {
@alpox
alpox / example.clj
Last active November 21, 2023 20:29
Clojure -> Python Async
(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)))
(defn async-iteration [from-process
to-process
output-channel
& {:keys [values-selector some? init]
:or {values-selector vector
some? some?}}]
(async/go
(async/>! to-process init)
(loop [value (async/<! from-process)]
(if (some? value)