Wednesday, December 02, 2020
SensibleSideButtons enables back/forward actions on my Anker mouse under os x
but I ordered a trackball mouse, looking forward to it
installed back x-tile on my pinebook pro, not as awesome as awesomewm but good enough
usually for two opened windows, I will use x-tile h
to tile them horizontally
for 3 windows, it supports triangle-up/down/left/right, then I'll use x-tile y/i
to swap windows
more than 3, I will x-tile q
to quad all windows then use x-tile m
to zoom in and x-tile M
to zoom out
(x-tile *
all mapped to shortcut keys)
couple links about arm cpu:
Friday, December 04, 2020
an interesting article about terminal workflow: My personal workflow for terminal-based coding, writing, research, and more!
I don't use a floating/drop down terminal, so I installed guake
and I like it.
Sunday, December 13, 2020
I also got myself a happy hacking keyboard on black friday sale, professional 2 type-s
for DIP I switched on 2 (mac), 3 (DEL as backspace) and 5 (switch Alt and ◇)
Dockerfile best-practices for writing production-worthy Docker images
it suggests using krallin/tini: A tiny but valid init for containers as ENTRYPOINT
found two useful nc
command from Become shell literate
send:
$ find . ! -path './Content/*' | xargs tar -cv | pv | zstd | nc 204:fbf5:... 12345
receive:
$ nc -vll :: 12345 | zstdcat | pv | tar -xv
- susam/emacs4cl: Tiny ~/.emacs for Common Lisp programming explained line-by-line
- “A damn stupid thing to do”—the origins of C
Friday, December 18, 2020
playing with gron
with my favrouite data source
gron https://old.reddit.com/r/clojure.json | egrep "data.title|data.url |data.num_comments|data.score" | sed -r "s/.children//g" | sed -r "s/data.//g" | gron -u | jq .
I love emacs but usually I'll start with terminal, vim is less thinking tool for me.
I'm practicing vim for simple/toy clojure programs, the setup is minimal:
lein new proj
lein repl
- in vim start with
:Connect
- start coding
I'm using fireplace.vim
and parinfer.vim
, both are just single .vim
files
switching between repl and code file is easier, they're just tmux
panes
some fireplace commands:
cpp
: eval most inner s-expcp%
: eval s-exp under cursorcpr
: reloadrequire
lopen
: check error logsgf
: jump to namespace under cursorK
: read doc on symbol under cursor
another reason why vim is more easy for me is I don't use package manager, I put all plugins in git and on every machine I just clone the repo then everything's ready
for emacs even though I have a package list, but it's much less stable I usually need to resolve broken packages, maybe I should start saving packages to git ...
Sunday, December 20, 2020
everytime I start with deps.edn
, I go back to use lein
, it's just easier for me.
I switched to use bhauman/rebel-readline as my repl, seems no official guide to start a nrepl server, I'll just start it after rebel launched:
(require '[nrepl.server :refer [start-server stop-server]])
(defonce server (start-server :port 7888))
Tuesday, December 22, 2020
scripting with babashka, really fun
to include dependencies is easy, just add add-deps
lines to the script:
(require '[babashka.deps :as deps])
(deps/add-deps '{:deps {medley/medley {:mvn/version "1.3.0"}}})
(require '[medley.core :refer [filter-keys]])
to test in the repl is also easy, usually it's a single clj script, start the repl and load the file:
(load-file "script.clj")
however meander is not supported yet, also arm binary is not available
Wednesday, December 23, 2020
normal diff
doesn't handle long line well, even vimdiff
is not good
found online this produces good result:
$ wdiff a b | colordiff | less -R
also git
produces the same result:
$ git diff --word-diff --no-index -- a b
on my terminal I need to tune the color for the diff, add to ~/.gitconfig
:
[color "diff"]
old = red bold
new = magenta bold
Friday, December 25, 2020
picking up some new clojure tools recently:
I use portal to navigate nested json files:
$ rlwrap bb -cp `clj -Spath -Sdeps '{:deps {djblue/portal {:mvn/version "0.7.0"}}}'`
user=> (require '[portal.api :as p])
user=> (require '[clojure.java.io :as io])
user=> (require '[cheshire.core :as json])
user=> (p/open)
user=> (p/tap)
user=> (def data (json/parse-stream (io/reader "foo.json") true))
user=> (tap> data)
then browser the data in the web ui
to cleanup use
user=> (p/clear)
user=> (p/close)
but for command lines, there's easier way in their README
~/.clojure/deps.edn
:
:portal/cli
{:main-opts ["-m" "portal.main"]
:extra-deps
{djblue/portal {:mvn/version "0.7.0"}
;; optional json support
cheshire/cheshire {:mvn/version "5.10.0"}
;; optional yaml support
clj-commons/clj-yaml {:mvn/version "0.7.0"}}}
.bashrc
:
alias portal='bb -cp `clojure -Spath -M:portal/cli` -m portal.main'
alias edn='portal edn'
alias json='portal json'
alias transit='portal transit'
alias yaml='portal yaml'
then simply
cat foo | json
I can also use portal on pinebook pro (arm) since it doesn't require javafx
Saturday, December 26, 2020
another clojure tool I like:
very useful to navigate/transform nested maps, much better than meander when use in repl but meander describes the structure clearly
again use reddit json to test
(require '[com.rpl.specter :refer [select submap])
(select [:data :children :ALL :data (submap [:title :url :score :num_comments]) json-data)
this video is a good introduction: Understanding Specter: Clojure's missing piece
this wiki shows how powerful the navigator is: List of Navigators
restructured my ~/.clojure/deps.edn
, cleared the dependencies, instead categorize them into aliases
after that I'll start my quick repl with:
$ clojure -A:dev -A:dev/db -M:repl/rebel
dev/db
contains dependencies for database libraries, which I don't often use
babashka can also use dependencies that described in deps.edn
just start it with
bb -cp `clojure -Spath -A:dev` script.clj
the classpath can also put into a enrionment variable
export BABASHKA_CLASSPATH=$(clojure -Spath -A:dev)
then can use normal bb
to run the script however this slows down when open a new terminal session, even worse when the directory has deps.edn
I didn't put it into .bashrc
instead I'll just export the variable to a specific pane only
Sunday, December 27, 2020
to filter a large map part of its values, found couple ways to do the submap?
predicate function:
(defn submap?
[submap m]
(clojure.set/subset? (set submap) (set m)))
(defn submap?
[^java.util.Map submap ^java.util.Map m]
(.containsAll (.entrySet m) (.entrySet submap)))
the 2nd one doesn't work in babashka
for deep version Alex Miller has one here
testing sql under babashka:
$ brew install postgresql
$ pg_ctl -D /usr/local/var/postgres start
$ brew install borkdude/brew/pod-babashka-postgresql
test connection:
(require '[babashka.pods :as pods])
(pods/load-pod "pod-babashka-postgresql")
(require '[pod.babashka.postgresql :as pg])
(def db {:dbtype "postgresql"
:host "localhost"
:dbname "postgres"
:port 5432})
(pg/execute! db ["select version()"])
create a dummy table:
postgres=# create table dummy (id serial not null primary key, data json not null);
feed json data into it:
(doseq [x data]
(pg/execute! db ["insert into dummy (data) values (?::json)" (json/generate-string x)]))
postgres=# select data from dummy where data->>'project' = 'foo' and data->>'tier' = 'bar';
Blog Archive
- Newer Entries
- 2021 January
- 2021 February
- 2021 March
- 2021 April
- 2021 May
- 2021 June
- 2021 August
- 2021 September
- 2021 December
- 2022 March
- 2022 April
- 2022 May
- 2022 June
- 2022 July
- 2022 August
- 2022 September
- 2022 October
- 2022 November
- 2022 December
- 2023 January
- 2023 February
- 2023 March
- 2023 April
- 2023 July
- 2023 August
- 2023 September
- 2023 October
- 2023 November
- 2023 December
- 2024 January
- 2024 February
- 2024 March
- 2024 April
- 2024 May
- 2024 June
- 2024 August
- 2024 September
- 2024 October
- 2024 November
- Older Entries
- 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