Skip to content

Instantly share code, notes, and snippets.

View nha's full-sized avatar
🐢
https://turtlequeue.com

nha

🐢
https://turtlequeue.com
View GitHub Profile
(defn send-repl [& [obj]]
(let [in-in (java.io.PipedInputStream.)
in-out (java.io.PipedOutputStream. in-in)
out-in (java.io.PipedInputStream.)
out-out (java.io.PipedOutputStream. out-in)
err-in (java.io.PipedInputStream.)
err-out (java.io.PipedOutputStream. err-in)]
(tap> {:repl/in (clojure.java.io/writer in-out)
:repl/out (clojure.java.io/reader out-in)
(defonce ^Logger logger (doto (Logger/getLogger "clojure")
(.setUseParentHandlers false)
(.addHandler
(doto (ConsoleHandler.)
(.setLevel Level/ALL)
(.setFormatter
(proxy [SimpleFormatter] []
(format [^LogRecord record]
(let [sb (StringBuilder.)]
(.append sb "#:log{")
@kiranshila
kiranshila / big_flash.md
Created August 14, 2020 04:28
Expanding Espruino's js_code partition for larger ESP32s

Motivation

Recently, I have been playing around with the Esprit project which is an attempt to run ClojureScript on microcontrollers using the Espruino microcontroller-based JS interpreter. As per Mike's talk here, the real trick is to setup Espruino such that it has enough space to hold cljs.core and all your program code. This ends up at least around 900KB.

Now for those unfamiliar, the ESP32 is configured with a partition table - allocating different sections of memory to the program code, non-volatile storage, the bootloader, etc. These partitions can be arbitrarily resized. Additionally, one can make partitions that don't mean anything to the ESP32, but can yield pointers in the C code that help manage the separate parts of memory.

As modern ESP32s ship with TONS of flash, we want to make the partition that Espruino calls js_code as large as possible to take full advant

@devstopfix
devstopfix / ants.clje
Last active May 14, 2020 15:53
Rich Hickey's ants simulator ported to Clojure on the BEAM
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Ant sim ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright (c) 2008 Rich Hickey. All rights reserved.
; The use and distribution terms for this software are covered by the
; Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
; which can be found in the file CPL.TXT at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
;
; Original Clojure JVM code :- https://gist.github.com/michiakig/1093917
@aroemers
aroemers / app.clj
Last active January 15, 2021 20:25
Component-lite
(ns app
(:require [lifecycle :refer [combine parallel]]))
(defn components [app-config]
(combine (parallel (users-db/component)
(tasks-db/component))
(rest-api/component app-config)))
@sijie
sijie / geo-replication-demo-without-a-global-zookeeper.md
Last active September 5, 2023 14:01
Geo Replication Demo without a global zookeeper

This doc demonstrates how to do geo-replication across multiple pulsar clusters without a global configuration store (zookeeper).

This demo is using docker-compose to start 3 pulsar clusters. Each pulsar cluster has 1 zk, 1 bk, and 1 broker. The docker compose file can be found at https://gist.github.com/sijie/63737459112471a82957ae20bd78adb5.

The information of all the three clusters is listed in the following table:

zk configuration store broker
beijing zk-beijing zk-beijing broker-beijing
@swannodette
swannodette / transitive_foreign.md
Last active June 1, 2020 14:22
Transitive Foreign Dependencies
NOTE: This proposal is dead. A simpler solution was arrived at via the new `:bundle` target.

ClojureScript Support for Foreign Libraries via NPM

Problem Description

The current Webpack solution works reasonable well for application oriented development, but does not address the wider issue of developing ClojureScript libraries that depend on the wider JavaScript ecosystem where the artifacts do not reside in Java-centric distrubtion like Maven (i.e. NPM). Currently a ClojureScript library cannot express these kinds of foreign library dependencies at all. Thus users must constantly redefine basic dependencies from NPM such as React, boilerplate Webpack configuration, boilerplate import/export files, and thus cannot create and share reusable ClojureScript components that depend on this vast ecosystem.

@ericnormand
ericnormand / 00_script.clj
Last active January 6, 2024 07:13
Boilerplate for running Clojure as a shebang script
#!/bin/sh
#_(
#_DEPS is same format as deps.edn. Multiline is okay.
DEPS='
{:deps {clj-time {:mvn/version "0.14.2"}}}
'
#_You can put other options here
OPTS='
@kachayev
kachayev / aleph-planning.md
Last active December 12, 2022 16:28
A few thoughts on Aleph development

Aleph, Async, HTTP, Clojure

I've been working with Aleph rougly for last 5 years, actively contributing to the library for last 2 (or so). I also put some effort into spreading the word about it, including educational tech talks, like "Deep HTTP Dive Throught Aleph & Netty". But the more I talk to people the more confusion I find, mostly about how Aleph works and what can you expect when adding it to your stack. Clojurists Together has recently announced Aleph to get Q1 funding, I think it's a good time to share my priorities and thoughts on development plans that were mentioned in the blog post. Hope the community would find it interesting and helpful.

Aleph describes itself as "asynchronous communication for Clojure" library. And you should probably pay a good portion of your attention to the first word: "asynchronous".

@dominictarr
dominictarr / readme.md
Created November 26, 2018 22:39
statement on event-stream compromise

Hey everyone - this is not just a one off thing, there are likely to be many other modules in your dependency trees that are now a burden to their authors. I didn't create this code for altruistic motivations, I created it for fun. I was learning, and learning is fun. I gave it away because it was easy to do so, and because sharing helps learning too. I think most of the small modules on npm were created for reasons like this. However, that was a long time ago. I've since moved on from this module and moved on from that thing too and in the process of moving on from that as well. I've written way better modules than this, the internet just hasn't fully caught up.

@broros

otherwise why would he hand over a popular package to a stranger?

If it's not fun anymore, you get literally nothing from maintaining a popular package.

One time, I was working as a dishwasher in a restu