Jim Cheung

Tuesday, January 03, 2023

read Nim in Action, however I still don't like types, I can just use python instead

then I decided going back to clojure, it's more fun there

finally there is a tool to manage deps.edn easily: babashka/neil: A CLI to add common aliases and features to deps.edn-based projects

since I've already have babashka installed, I can just download the neil script

then I can create a simple playground by:

$ neil new scratch :name play

then you'll have a very clean project:

├── deps.edn
└── src
    └── play.clj

note, arguments to new can reference: seancorfield/deps-new: A new, simpler alternative to clj-new

this part I wanted for so long, search deps and simply add the latest version:

$ neil dep search json
$ neil add dep cheshire/cheshire

then add nrepl:

$ neil add nrepl
$ clj -M:nrepl

but for more serious use, should create a project with:

$ neil new app :name usrj/playapp

which is a more complete project structure:

├── README.md
├── build.clj
├── deps.edn
├── doc
│   └── intro.md
├── pom.xml
├── resources
├── src
│   └── usrj
│       └── playapp.clj
└── test
    └── usrj
        └── playapp_test.clj

can run the app by:

$ clojure -X:run-x

or build uberjar by:

$ clojure -T:build ci

just like that, no more lein

haven't watched yet, but will watch: Alex Miller Keynote "The Amazing Clojure"

also picking up more clojure stuffs:

Wednesday, January 04, 2023

saw Alex Miller using REBL in his talk

quite interesting, trying it now

Thursday, January 05, 2023

a new free book on babashka: Babashka Babooka: Write Command-Line Clojure

clerk is something I want to try too: Using Clerk for Advent of Code

the setup for REBL:

{:aliases {:rebl {:extra-deps {com.cognitect/rebl          {:mvn/version "0.9.245"}
                               nrepl-rebl/nrepl-rebl       {:mvn/version "0.1.1"}
                               org.openjfx/javafx-fxml     {:mvn/version "19"}
                               org.openjfx/javafx-controls {:mvn/version "19"}
                               org.openjfx/javafx-swing    {:mvn/version "19"}
                               org.openjfx/javafx-base     {:mvn/version "19"}
                               org.openjfx/javafx-web      {:mvn/version "19"}}}
           :nrepl {:extra-deps {nrepl/nrepl {:mvn/version "1.0.0"}}}}

run clojure -M:rebl:nrepl -m nrepl.cmdline --middleware '[nrepl-rebl.core/wrap-rebl]' will open REBL and nREPL serer

Saturday, January 07, 2023

babashka/neil and REBL really improved the development experience

I don't have the same experience with portal or reveal, maybe it's because REBL is using javafx for UI

also nowadays I'll try using babashka tools like babashka.curl and babashka/fs so that part of codes could be run with bb easily.

recently looking into htmx and _hyperscript

reading the book by htmx creator: Building Hypermedia Systems

for clojure there is Biff for htmx and xtdb

also interested in squint-cljs/squint that can compile cljs into js

(require '[squint.compiler :as sq])
(sq/compile-string "(defn foo [] (+ 1 2 3))")

I have few small projects can be replaced with cljs, and it's a very simple build and replace step

a simple boilerplate for clojure web app:

create the app:

$ neil new scratch sux

then add this makefile:

	clj -M:nrepl

	@echo "--- make sure add 'resources' to :path in deps.edn ---"
	neil add nrepl
	neil add build

	neil dep add ring/ring-jetty-adapter
	neil dep add ring/ring-devel
	neil dep add metosin/reitit-ring

	@echo "--- make sure add \":main 'my.app\" to build.clj b/uber call ---"
	clojure -T:build uber

add html/js/css to resources/public/

finally the server:

(ns sux.sux
  (:require [reitit.ring :as ring]
            [ring.adapter.jetty :refer [run-jetty]])

(defn handler [_]
  {:status 200, :body "<b>ok</b>"})

(def app
    [["/ping" {:name ::ping
               :get handler}]])
    (ring/create-resource-handler {:path "/"})

(defn -main []
  (run-jetty #'app {:port 8080, :join? false})
  (println "server running in port 8080"))

  (require '[ring.middleware.reload :refer [wrap-reload]])

  (def dev-server
     (-> #'app wrap-reload)
     {:port 8080, :join? false}))

  (.stop dev-server)

Thursday, January 19, 2023

I'm also using babashka/nbb when I need to call js libraries

read Datasette is my data hammer, and then watched the introductory video

definitely will give it a try, I like the idea of sqlite (single db file) and sqlite-utils demonstrated in the video is a very cool tool:

$ sqlite-utils insert trees.db trees Street_Tree_List.csv --csv

$ sqlite-utils extract trees.db trees qLegalStatus

$ sqlite-utils enable-fts trees.db trees qAddress

and in later version better use insert with -d argument, which auto detect column type

also as mentioned in the article, an url links to the dataset is a killer feature

to package as a docker container:

$ datasette package mydatabase.db

extract to normalize tables, remember just rename the label column to name

useful articles:

I like you can use it in python, can clean the whole dataset without bash

some useful plugins:

$ datasette install datasette-graphql \
    datasette-vega \
    datasette-copyable \ 
    datasette-jupyterlite \

jupyterlite one is must have, can just load the data with:

import pandas, pyodide
import matplotlib.pyplot

df = pandas.read_csv(pyodide.http.open_url(


then play data with pandas

Friday, January 20, 2023

I'm using os x 10.13, these are apps still available for such lower version:

Saturday, January 21, 2023

holiday reading will be Type-Driven Development with Idris and Gentle Introduction to Dependent Types with Idris

and maybe The Little Typer after watched A Little Taste of Dependent Types

got a macro knob pad recently, it has 4 keys and 1 knob, 7 actions per layer, and 4 layers in total

the trick here is:

Blog Archive