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:
play
├── 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:
playapp/
├── CHANGELOG.md
├── LICENSE
├── 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
:
dev:
clj -M:nrepl
init:
@echo "--- make sure add 'resources' to :path in deps.edn ---"
neil add nrepl
neil add build
deps:
neil dep add ring/ring-jetty-adapter
neil dep add ring/ring-devel
neil dep add metosin/reitit-ring
uber:
@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]])
(:gen-class))
(defn handler [_]
{:status 200, :body "<b>ok</b>"})
(def app
(ring/ring-handler
(ring/router
[["/ping" {:name ::ping
:get handler}]])
(ring/routes
(ring/create-resource-handler {:path "/"})
(ring/create-default-handler))))
(defn -main []
(run-jetty #'app {:port 8080, :join? false})
(println "server running in port 8080"))
(comment
(require '[ring.middleware.reload :refer [wrap-reload]])
(def dev-server
(run-jetty
(-> #'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:
- Refactoring databases with sqlite-utils extract
- Apply conversion functions to data in SQLite columns with the sqlite-utils CLI tool
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 \
datasette-nteract-data-explorer
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(
"http://localhost:8001/your.csv")
)
df.plot()
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:
- Apptivate: I have a micro keypad with knob, but the configurator is not easy to use, I need some simply shortkeys for apps. this tool can set shortkey to an application easily.
- Flycut: the only clipboard manager I could find for 10.13
- f.lux: used many years, still working fine
- SensibleSideButtons: make mouse buttons just work under os x
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:
LT(kc)
(turn on layer when held, kc when tapped) to get an extra actionOSL(layer)
(momentarily activates layer until a key is pressed)TO(layer)
(turns on layer)| 0 | LT(1, KC_ESC) | OSL(2) | F14 | F15 | RGB | LCTL(KC_F15) | LCTL(KC_F16) | | 1 | - | F16 | F17 | RGB- | - | Vol+ | Vol- | | 2 | TO(3) | F13 | F18 | F19 | Mute | LCTL(KC_TAB) | LCTL(LSFT(KC_TAB)) | Emacs Layer | 3 | LCTL(KC_G) | LGUI(KC_0) | KLGUI(KC_1) | LGUI(KC_B) | TO(0) | LGUI(KC_3) | LGUI(KC_2) |
Blog Archive
- Older Entries
- 2022 December
- 2022 November
- 2022 October
- 2022 September
- 2022 August
- 2022 July
- 2022 June
- 2022 May
- 2022 April
- 2022 March
- 2021 December
- 2021 September
- 2021 August
- 2021 June
- 2021 May
- 2021 April
- 2021 March
- 2021 February
- 2021 January
- 2020 December
- 2020 November
- 2020 October
- 2020 September
- 2020 August
- 2019 December
- 2019 November
- 2019 October
- 2019 July
- 2019 May
- 2019 April
- 2019 March
- 2019 February
- 2019 January
- 2018 December
- 2018 November
- 2018 October
- 2018 September
- 2018 August
- 2018 July
- 2018 June
- 2018 May
- 2018 April
- 2018 March
- 2018 February
- 2018 January
- 2017 December
- 2017 November
- 2017 October
- 2017 September
- 2017 August
- 2017 July
- 2017 June
- 2017 May
- 2017 April
- 2017 March
- 2017 February
- 2017 January
- 2016 December
- 2016 November
- 2016 October
- 2016 September
- 2016 August
- 2016 July
- 2016 June
- 2016 May
- 2016 April
- 2016 March
- 2016 February
- 2016 January
- 2015 December
- 2015 November
- 2015 October
- 2015 September
- 2015 August
- 2015 July
- 2015 June
- 2015 May
- 2015 April
- 2015 March
- 2015 February
- 2015 January
- 2014 December
- 2014 November
- 2014 October
- 2014 September
- 2014 August
- 2014 March
- 2014 February
- 2014 January
- 2013 December
- 2013 October
- 2013 July
- 2013 June
- 2013 May
- 2013 March
- 2013 February
- 2013 January
- 2012 December
- 2012 November
- 2012 October
- 2012 September
- 2012 August