<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Clojure on Ken Huang</title>
    <link>https://blog.kenhuang.io/tags/clojure/</link>
    <description>Recent content in Clojure on Ken Huang</description>
    <generator>Hugo</generator>
    <language>en</language>
    <managingEditor>whatacold@gmail.com (Ken Huang)</managingEditor>
    <webMaster>whatacold@gmail.com (Ken Huang)</webMaster>
    <lastBuildDate>Tue, 10 Mar 2026 23:16:20 +0800</lastBuildDate>
    <atom:link href="https://blog.kenhuang.io/tags/clojure/rss.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Your Screenshots Deserve Better. Introducing Backdrop.</title>
      <link>https://blog.kenhuang.io/blog/2026-03-10-backdrop-intro/</link>
      <pubDate>Tue, 10 Mar 2026 22:49:27 +0800</pubDate><author>whatacold@gmail.com (Ken Huang)</author>
      <guid>https://blog.kenhuang.io/blog/2026-03-10-backdrop-intro/</guid>
      <description>&lt;p&gt;&#xA;Have you ever been there? You&amp;#39;ve just finished a brilliant piece of code, designed a slick UI, or found the perfect example for a tutorial. You take a screenshot to share your work, but when you look at it… it&amp;#39;s just… plain.&lt;/p&gt;&#xA;&lt;p&gt;&#xA;You could share it as is, but it lacks professionalism. Or, you could spend the next 15 minutes wrestling with a heavy-duty design tool, carefully placing it on a background, adding a shadow, and rounding the corners, all for a single image.&lt;/p&gt;</description>
    </item>
    <item>
      <title>🥷 Clojure Pro Tip 5: Hiccup Raw</title>
      <link>https://blog.kenhuang.io/blog/2025-05-15-clojure-tip-hiccup-raw/</link>
      <pubDate>Thu, 15 May 2025 12:49:27 +0800</pubDate><author>whatacold@gmail.com (Ken Huang)</author>
      <guid>https://blog.kenhuang.io/blog/2025-05-15-clojure-tip-hiccup-raw/</guid>
      <description>&lt;p&gt;&#xA;In case you don’t know it, we can use raw strings, like embedding JS code, in hiccup.&lt;/p&gt;&#xA;&lt;p&gt;&#xA;I just found out we can use &lt;a href=&#34;https://weavejester.github.io/hiccup/hiccup2.core.html#var-raw&#34;&gt;raw&lt;/a&gt; to prevent strings from getting escaped. I used to have to define a dedicated app.js for that, which would need an extra HTTP request.&lt;/p&gt;&#xA;&lt;figure&gt;&#xA;&lt;img src=&#34;https://blog.kenhuang.io/img/clojure-hiccup-raw.jpg&#34; alt=&#34;Hiccup raw in action&#34; title=&#34;Click to enlarge the image&#34;/&gt;&#xA;&lt;figcaption&gt;&#xA;Hiccup raw in action&#xA;&lt;/figcaption&gt;&#xA;&lt;/figure&gt;&#xA;&lt;p&gt;&#xA;Looking back, I should’ve found this at the very beginning, as it’s just mentioned on &lt;a href=&#34;https://github.com/weavejester/hiccup&#34;&gt;its GitHub homepage&lt;/a&gt;, but somehow I missed it.&lt;/p&gt;</description>
    </item>
    <item>
      <title>🥷 Clojure Pro Tip 4: Cider ClojureDocs</title>
      <link>https://blog.kenhuang.io/blog/2025-04-29-clojure-tip-cider-clojuredocs/</link>
      <pubDate>Tue, 29 Apr 2025 12:49:27 +0800</pubDate><author>whatacold@gmail.com (Ken Huang)</author>
      <guid>https://blog.kenhuang.io/blog/2025-04-29-clojure-tip-cider-clojuredocs/</guid>
      <description>&lt;p&gt;&#xA;Sometimes, we may want a few examples of a Clojure API for inspiration while developing, especially when reading other people&amp;#39;s or open source code.&lt;/p&gt;&#xA;&lt;p&gt;&#xA;With &lt;a href=&#34;https://cider.mx/&#34;&gt;Cider&lt;/a&gt; in &lt;a href=&#34;https://www.gnu.org/software/emacs/&#34;&gt;Emacs&lt;/a&gt;, we can run &lt;code class=&#34;verbatim&#34;&gt;M-x cider-doc&lt;/code&gt; to see the docstring for the symbol. We can even use &lt;code class=&#34;verbatim&#34;&gt;M-x cider-clojuredocs&lt;/code&gt; for some examples if the symbol is from the language core.&lt;/p&gt;&#xA;&lt;figure&gt;&#xA;&lt;img src=&#34;https://blog.kenhuang.io/img/clojure-cider-clojuredocs.jpg&#34; alt=&#34;Running M-x cider-clojuredocs&#34; title=&#34;Click to enlarge the image&#34;/&gt;&#xA;&lt;figcaption&gt;&#xA;Running M-x cider-clojuredocs&#xA;&lt;/figcaption&gt;&#xA;&lt;/figure&gt;&#xA;&lt;p&gt;&#xA;I happened to find this command recently. I bet I was not the only one who didn&amp;#39;t know it, thus I&amp;#39;m sharing.&lt;/p&gt;</description>
    </item>
    <item>
      <title>🥷 Clojure Pro Tip 3: the Thread-As Macro</title>
      <link>https://blog.kenhuang.io/blog/2025-04-23-clojure-tip-thread-as/</link>
      <pubDate>Wed, 23 Apr 2025 12:49:27 +0800</pubDate><author>whatacold@gmail.com (Ken Huang)</author>
      <guid>https://blog.kenhuang.io/blog/2025-04-23-clojure-tip-thread-as/</guid>
      <description>&lt;p&gt;&#xA;So you&amp;#39;re more than excited to find out how Clojure&amp;#39;s thread macros can make code clean and concise, you just love it! But at some point you&amp;#39;ll be trapped a bit as the threaded argument&amp;#39;s positions are inconsistent using &lt;a href=&#34;https://clojuredocs.org/clojure_core/clojure.core/-%3E&#34;&gt;-&amp;gt;&lt;/a&gt; or &lt;a href=&#34;https://clojuredocs.org/clojure_core/clojure.core/-%3E%3E&#34;&gt;-&amp;gt;&amp;gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&#xA;Luckily, you can use &lt;a href=&#34;https://clojuredocs.org/clojure_core/clojure.core/as-%3E&#34;&gt;as-&amp;gt;&lt;/a&gt; to place the argument wherever you like:&lt;/p&gt;&#xA;&lt;figure&gt;&#xA;&lt;img src=&#34;https://blog.kenhuang.io/img/clojure-thread-as.jpg&#34; alt=&#34;Lambda vs. thread-as&#34; title=&#34;Click to enlarge the image&#34;/&gt;&#xA;&lt;figcaption&gt;&#xA;Lambda vs. thread-as&#xA;&lt;/figcaption&gt;&#xA;&lt;/figure&gt;</description>
    </item>
    <item>
      <title>🥷 Clojure Pro Tip 2: group-by</title>
      <link>https://blog.kenhuang.io/blog/2025-04-18-clojure-group-by/</link>
      <pubDate>Fri, 18 Apr 2025 12:49:27 +0800</pubDate><author>whatacold@gmail.com (Ken Huang)</author>
      <guid>https://blog.kenhuang.io/blog/2025-04-18-clojure-group-by/</guid>
      <description>&lt;p&gt;&#xA;It&amp;#39;s amazingly easy to group things in Clojure. The language core provides a &lt;a href=&#34;https://clojuredocs.org/clojure_core/clojure.core/group-by&#34;&gt;group-by&lt;/a&gt; function directly. Together with many built-in functions or key functions, it creates a ton of possibilities, and we can also bake our grouping function if none is satisfying.&lt;/p&gt;&#xA;&lt;figure&gt;&#xA;&lt;img src=&#34;https://blog.kenhuang.io/img/clojure-group-by.jpg&#34; alt=&#34;group-by&#34; title=&#34;Click to enlarge the image&#34;/&gt;&#xA;&lt;figcaption&gt;&#xA;group-by&#xA;&lt;/figcaption&gt;&#xA;&lt;/figure&gt;&#xA;&lt;p&gt;&#xA;Example from &lt;a href=&#34;https://github.com/functional-koans/clojure-koans&#34;&gt;Clojure Koans&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>🥷 Clojure Pro Tip 1: the Discard Reader Symbol</title>
      <link>https://blog.kenhuang.io/blog/2025-04-05-clojure-tip-discard-reader-symbol/</link>
      <pubDate>Sat, 05 Apr 2025 12:49:27 +0800</pubDate><author>whatacold@gmail.com (Ken Huang)</author>
      <guid>https://blog.kenhuang.io/blog/2025-04-05-clojure-tip-discard-reader-symbol/</guid>
      <description>&lt;p&gt;&#xA;In Clojure, we can use &lt;a href=&#34;https://clojuredocs.org/clojure.core/comment&#34;&gt;comment&lt;/a&gt; (aka Rich Comment Blocks) for tests or experiments in development. However, since a comment evaluates to nil, you may run into surprising results or even errors if you misuse it.&lt;/p&gt;&#xA;&lt;figure&gt;&#xA;&lt;img src=&#34;https://blog.kenhuang.io/img/clojure-discard-reader-symbol.jpg&#34; alt=&#34;Comment vs. Discard&#34; title=&#34;Click to enlarge the image&#34;/&gt;&#xA;&lt;figcaption&gt;&#xA;Comment vs. Discard&#xA;&lt;/figcaption&gt;&#xA;&lt;/figure&gt;&#xA;&lt;p&gt;&#xA;In these scenarios, you may tend to use &lt;code class=&#34;verbatim&#34;&gt;;&lt;/code&gt; to comment them out, but a better choice is to use the &lt;a href=&#34;https://clojure.org/guides/weird_characters#_discard&#34;&gt;discard reader symbol &lt;code class=&#34;verbatim&#34;&gt;#_&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Rewrite of a Flask Web App in Clojure</title>
      <link>https://blog.kenhuang.io/blog/2025-02-22-flask-clojure-rewrite/</link>
      <pubDate>Sat, 22 Feb 2025 22:46:05 +0800</pubDate><author>whatacold@gmail.com (Ken Huang)</author>
      <guid>https://blog.kenhuang.io/blog/2025-02-22-flask-clojure-rewrite/</guid>
      <description>&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;&#xA;&lt;h2 id=&#34;headline-1&#34;&gt;&#xA;Intro&#xA;&lt;/h2&gt;&#xA;&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;&#xA;&lt;p&gt;&#xA;A few years ago, I made a simple web app in &lt;a href=&#34;https://flask.palletsprojects.com/en/stable/&#34;&gt;Flask&lt;/a&gt; to deal with some text processing problems from my daily work. It has two main features:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Feature #1: generating &lt;code class=&#34;verbatim&#34;&gt;compile_commands.json&lt;/code&gt; for GNU Makefile projects written in C/C++ using the output of the &lt;code class=&#34;verbatim&#34;&gt;make&lt;/code&gt; command. Because, unlike CMake, the make command can&amp;#39;t generate it.&lt;/li&gt;&#xA;&lt;li&gt;Feature #2: extract text using Python regex. It&amp;#39;s handy when I feel like sed/awk/grep&amp;#39;s line-oriented processing isn&amp;#39;t enough for the task at hand.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;em&gt;BTW, I&amp;#39;m improving my English by watching YouTube videos every single day; If you&amp;#39;re also learning English, or any languages, LanguagePuppy can definitely help you. It&amp;#39;s a Chrome extension I developed using Clojure. Check it out:&lt;/em&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Constructing Clojure Maps Conditionally</title>
      <link>https://blog.kenhuang.io/blog/2025-01-05-construct-a-map-clojure/</link>
      <pubDate>Sun, 05 Jan 2025 10:40:07 +0800</pubDate><author>whatacold@gmail.com (Ken Huang)</author>
      <guid>https://blog.kenhuang.io/blog/2025-01-05-construct-a-map-clojure/</guid>
      <description>&lt;p&gt;&#xA;I was wondering how to construct a multi-key map conditionally while I was coding in Clojure. Ideally, I would like to build it &amp;#34;in one pass&amp;#34; like &lt;code class=&#34;verbatim&#34;&gt;{:bar 2 (when true :baz 3)}&lt;/code&gt;, but from what I had collected from Blue Sky, it seemed that&amp;#39;s impossible, or it&amp;#39;s just not an idiomatic way to program like that in Clojure. (Or, is this just a side effect of writing too much imperative code?)&lt;/p&gt;</description>
    </item>
    <item>
      <title>Getting Started with Cider for Clojure Programming</title>
      <link>https://blog.kenhuang.io/blog/2024-12-22-getting-started-with-cider/</link>
      <pubDate>Sun, 22 Dec 2024 17:17:15 +0800</pubDate><author>whatacold@gmail.com (Ken Huang)</author>
      <guid>https://blog.kenhuang.io/blog/2024-12-22-getting-started-with-cider/</guid>
      <description>&lt;p&gt;&#xA;Here is the outline for my cider tutorial on YouTube, covering basic things you need to know to get started with cider, and starting exploring the fun of clojure programming with the REPL-driven programming approach.&lt;/p&gt;&#xA;&lt;p&gt;&#xA;&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;&#xA;      &lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/evmRpr_DEBQ?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;&#xA;    &lt;/div&gt;&#xA;&lt;/p&gt;&#xA;&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;&#xA;&lt;h2 id=&#34;headline-1&#34;&gt;&#xA;Jack In to a REPL&#xA;&lt;/h2&gt;&#xA;&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;&#xA;&lt;dl&gt;&#xA;&lt;dt&gt;&#xA;C-c M-j (cider-jack-in-clj)&#xA;&lt;/dt&gt;&#xA;&lt;dd&gt;start a nREPL and jack in.&#xA;&#xA;It works in a project or with a &lt;strong&gt;sole .clj file&lt;/strong&gt;.&lt;/dd&gt;&#xA;&lt;dt&gt;&#xA;M-x cider-connect-clj&#xA;&lt;/dt&gt;&#xA;&lt;dd&gt;run the command and then fill in hostname and port.&#xA;&#xA;It could be useful in some cases. e.g. on Windows, I can start the nREPL manually and then connect to it separately.&lt;/dd&gt;&#xA;&lt;/dl&gt;&#xA;&lt;/div&gt;&#xA;&lt;/div&gt;&#xA;&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;&#xA;&lt;h2 id=&#34;headline-2&#34;&gt;&#xA;Evaluate Things&#xA;&lt;/h2&gt;&#xA;&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;&#xA;&lt;dl&gt;&#xA;&lt;dt&gt;&#xA;C-M-x (cider-eval-defun-at-point)&#xA;&lt;/dt&gt;&#xA;&lt;dd&gt;evaluate current top-level form.&lt;/dd&gt;&#xA;&lt;dt&gt;&#xA;C-x C-e (cider-eval-last-sexp)&#xA;&lt;/dt&gt;&#xA;&lt;dd&gt;evaluate the preceding form.&lt;/dd&gt;&#xA;&lt;dt&gt;&#xA;C-c C-k (cider-load-buffer)&#xA;&lt;/dt&gt;&#xA;&lt;dd&gt;evaluate/load the current buffer.&lt;/dd&gt;&#xA;&lt;dt&gt;&#xA;C-c C-p (cider-pprint-eval-last-sexp)&#xA;&lt;/dt&gt;&#xA;&lt;dd&gt;Pprint the result in a dedicated buffer.&#xA;&#xA;Great thing to do when the result is too large to fit in the echo area.&lt;/dd&gt;&#xA;&lt;/dl&gt;&#xA;&lt;p&gt;Note: I prefer to use the same key bindings as for Elisp, given that&#xA;cider might bind a few keys to a single command!&lt;/p&gt;</description>
    </item>
    <item>
      <title>A Few Quick Notes About babashka/fs</title>
      <link>https://blog.kenhuang.io/blog/2024-12-07-babashka-fs-notes/</link>
      <pubDate>Sat, 07 Dec 2024 22:24:41 +0800</pubDate><author>whatacold@gmail.com (Ken Huang)</author>
      <guid>https://blog.kenhuang.io/blog/2024-12-07-babashka-fs-notes/</guid>
      <description>&lt;p&gt;&#xA;Recently I&amp;#39;ve used &lt;a href=&#34;https://github.com/babashka/fs/blob/master/API.md&#34;&gt;babashka/fs&lt;/a&gt; a little bit, here are some quick notes for it:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Path vs File.&#xA;&#xA;Use Path whenever possible, according to &lt;a href=&#34;https://stackoverflow.com/a/26658436&#34;&gt;this SO answer to &amp;#34;Java: Path vs File&amp;#34;&lt;/a&gt;.&#xA;&#xA;This is actually Java related.&lt;/li&gt;&#xA;&lt;li&gt;It&amp;#39;s ok to use a &lt;code class=&#34;verbatim&#34;&gt;path&lt;/code&gt; as a key for a clojure map.&#xA;&#xA;At my first try, I somehow came to the conclusion that it&amp;#39;s not ok, while I was refactoring the &lt;a href=&#34;https://github.com/scicloj/clay/blob/main/src/scicloj/clay/v2/live_reload.clj&#34;&gt;live reload&lt;/a&gt; for clay. And later I found that it&amp;#39;s totally fine to use it as a key. 😞&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;a href=&#34;https://github.com/babashka/fs/blob/master/API.md#babashka.fs/path&#34;&gt;fs/path&lt;/a&gt; to construct file/directory paths, for example, &lt;code class=&#34;verbatim&#34;&gt;(fs/path &amp;#34;/tmp&amp;#34; &amp;#34;foo&amp;#34; &amp;#34;bar&amp;#34; &amp;#34;baz.clj&amp;#34;)&lt;/code&gt; will result in a path object for &lt;code class=&#34;verbatim&#34;&gt;/tmp/foo/bar/baz.clj&lt;/code&gt; on linux.&#xA;&#xA;If you&amp;#39;re coming from Python, it might remind you of &lt;a href=&#34;https://docs.python.org/3/library/os.path.html&#34;&gt;os.path.join(path, *paths)&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code class=&#34;verbatim&#34;&gt;fs/createdirs&lt;/code&gt; for &lt;code class=&#34;verbatim&#34;&gt;mkdir -p&lt;/code&gt;, though its name is a bit misleading, I first thought it&amp;#39;s for creating a few dirs.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;fs/with-temp-dir&lt;/code&gt; is convenient for &lt;a href=&#34;https://github.com/scicloj/clay/blob/main/test/scicloj/clay/v2/live_reload_test.clj&#34;&gt;creating tests&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;</description>
    </item>
    <item>
      <title>Doing Unit test in Clojure Is Easy</title>
      <link>https://blog.kenhuang.io/blog/2024-11-27-clojure-unit-test/</link>
      <pubDate>Thu, 28 Nov 2024 23:10:56 +0800</pubDate><author>whatacold@gmail.com (Ken Huang)</author>
      <guid>https://blog.kenhuang.io/blog/2024-11-27-clojure-unit-test/</guid>
      <description>&lt;p&gt;&#xA;While refactoring the &lt;a href=&#34;https://github.com/scicloj/clay/blob/main/src/scicloj/clay/v2/live_reload.clj&#34;&gt;live reload&lt;/a&gt; feature of &lt;a href=&#34;https://github.com/scicloj/clay&#34;&gt;Clay&lt;/a&gt;, I realized I&amp;#39;d better break long functions into smaller and functional ones (as many as I can), which is also a &lt;a href=&#34;https://guide.clojure.style/#be-functional&#34;&gt;common practice&lt;/a&gt; in the clojure community.&lt;/p&gt;&#xA;&lt;p&gt;&#xA;Small pure functions not only are easy to verify on the development process (using a REPL), but also are easy to test. And unit tests are easy to write in clojure, just use &lt;code class=&#34;verbatim&#34;&gt;deftest&lt;/code&gt; from &lt;code class=&#34;verbatim&#34;&gt;clojure.test&lt;/code&gt;, a very basic one looks like this:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Clj-async-profiler Rocks</title>
      <link>https://blog.kenhuang.io/blog/2024-11-28-beholder-clj-async-profiler/</link>
      <pubDate>Thu, 28 Nov 2024 22:23:32 +0800</pubDate><author>whatacold@gmail.com (Ken Huang)</author>
      <guid>https://blog.kenhuang.io/blog/2024-11-28-beholder-clj-async-profiler/</guid>
      <description>&lt;p&gt;&#xA;While developing the live reload feature for &lt;a href=&#34;https://scicloj.github.io/clay/&#34;&gt;Clay&lt;/a&gt;, a minimalistic Clojure tool for data visualization and literate programming, I found that it constantly takes ~1 minute for &lt;a href=&#34;https://github.com/nextjournal/beholder&#34;&gt;beholder&lt;/a&gt; to watch a directory. After some code inspect, I was still having no idea why it happened.&lt;/p&gt;&#xA;&lt;p&gt;&#xA;So I decided to use a profiler to find out what&amp;#39;s going one under the hood, and Google immediately took me to &lt;a href=&#34;https://clojure-goes-fast.com/kb/profiling/clj-async-profiler/&#34;&gt;clj-async-profiler&lt;/a&gt;. It&amp;#39;s easy to set up following its &lt;a href=&#34;https://clojure-goes-fast.com/kb/profiling/clj-async-profiler/basic-usage/&#34;&gt;basic usage docs&lt;/a&gt;:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Adding Clojure Dependencies from the Command Line</title>
      <link>https://blog.kenhuang.io/blog/2024-11-09-clj-deps-cmdline/</link>
      <pubDate>Sat, 09 Nov 2024 21:02:56 +0800</pubDate><author>whatacold@gmail.com (Ken Huang)</author>
      <guid>https://blog.kenhuang.io/blog/2024-11-09-clj-deps-cmdline/</guid>
      <description>&lt;p&gt;&#xA;While debugging a &lt;a href=&#34;https://github.com/scicloj/clay/issues/176&#34;&gt;live reload issue&lt;/a&gt; of Clay a few days ago, I learned from &lt;a href=&#34;https://github.com/kloimhardt&#34;&gt;Markus Agwin&lt;/a&gt; that we can actually add dependencies on the fly from the command line, just like this: &lt;code class=&#34;verbatim&#34;&gt;clj -Sdeps &amp;#34;{:deps {org.scicloj/clay {:mvn/version \&amp;#34;2-beta21\&amp;#34;}}}&amp;#34;&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&#xA;Even better, we can add dependency from a Git repo and specify the commit hash: &lt;code class=&#34;verbatim&#34;&gt;clj -Sdeps &amp;#34;{:deps {io.github.scicloj/clay {:git/url \&amp;#34;https://github.com/scicloj/clay.git\&amp;#34; :git/sha \&amp;#34;35a46541db66ae6b4e1af628b7c24c42d3be418f\&amp;#34;}}}&amp;#34;&lt;/code&gt;, which is really helpful for experimenting and verifying things.&lt;/p&gt;&#xA;&lt;p&gt;&#xA;Some clj links (&lt;code class=&#34;verbatim&#34;&gt;clj --help&lt;/code&gt; has a pointer for these URLs):&lt;/p&gt;</description>
    </item>
    <item>
      <title>Bitten by Lazy Sequence of map</title>
      <link>https://blog.kenhuang.io/blog/2024-11-10-clojure-lazy-seq-case/</link>
      <pubDate>Sat, 09 Nov 2024 21:02:56 +0800</pubDate><author>whatacold@gmail.com (Ken Huang)</author>
      <guid>https://blog.kenhuang.io/blog/2024-11-10-clojure-lazy-seq-case/</guid>
      <description>&lt;p&gt;&#xA;While impletenting the live reload feature for &lt;a href=&#34;https://github.com/scicloj/clay&#34;&gt;Clay&lt;/a&gt; a few weeks ago, unfortunately, I was bitten by the laziness of &lt;a href=&#34;https://clojuredocs.org/clojure.core/map&#34;&gt;map&lt;/a&gt;. It seems quite obvious we all know that its result is a lazy sequence, but I just can&amp;#39;t help fall into the &amp;#34;trap&amp;#34;.&lt;/p&gt;&#xA;&lt;p&gt;&#xA;At that time I was adding a vector to keep track of all &lt;a href=&#34;https://github.com/nextjournal/beholder&#34;&gt;beholder&lt;/a&gt; instances watching file changes in user specified directories. So then when it&amp;#39;s time to stop all the watchers, I used something like to achieve the goal:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Anonymous Functions in Thread Macros</title>
      <link>https://blog.kenhuang.io/blog/2024-11-08-clojure-thread-macro-anonymous-function/</link>
      <pubDate>Fri, 08 Nov 2024 21:02:56 +0800</pubDate><author>whatacold@gmail.com (Ken Huang)</author>
      <guid>https://blog.kenhuang.io/blog/2024-11-08-clojure-thread-macro-anonymous-function/</guid>
      <description>&lt;p&gt;&#xA;While adding &lt;a href=&#34;https://github.com/scicloj/clay/pull/165&#34;&gt;the live reload feature&lt;/a&gt; to Clay, I encountered a problem&#xA;of applying anonymous functions to thread macros. For example, below&#xA;is a simple snippet trying to wrap the input directory as a vector&#xA;with the help of thread macro, but surprisingly, it errors out. After&#xA;some searching, I figured out that I need to put the anonymous&#xA;function into another pair of parentheses:&lt;/p&gt;&#xA;&lt;div class=&#34;src src-clojure&#34;&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-clojure&#34; data-lang=&#34;clojure&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nb&#34;&gt;-&amp;gt; &lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;/tmp/&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;o&#34;&gt;#&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;if &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nb&#34;&gt;vector? &lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;%&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;nv&#34;&gt;%&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;%&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;]))&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;;; =&amp;gt; Syntax error (ClassCastException) compiling fn* at (simple4all.clj:19:1).&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;;;    class java.lang.String cannot be cast to class clojure.lang.ISeq (java.lang.String is in module java.base of loader &amp;#39;bootstrap&amp;#39;; clojure.lang.ISeq is in unnamed module of loader &amp;#39;app&amp;#39;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nb&#34;&gt;-&amp;gt; &lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;/tmp/&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;#&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;if &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nb&#34;&gt;vector? &lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;%&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;nv&#34;&gt;%&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;%&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;])))&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;;; =&amp;gt; [&amp;#34;/tmp/&amp;#34;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;&#xA;Paul has a nice explanation on &lt;a href=&#34;https://stackoverflow.com/a/7838577&#34;&gt;Stack Overflow&lt;/a&gt;, &lt;a href=&#34;https://clojuredocs.org/clojure.core/-%3E&#34;&gt;thread macros&lt;/a&gt; need the function forms to be lists, but anonymous functions are already lists, so the first expression, &lt;code class=&#34;verbatim&#34;&gt;&amp;#34;/tmp/&amp;#34;&lt;/code&gt; in this example, will just be inserted into that list, just as illustrated below:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Starting a Clojure nREPL Manually for Cider</title>
      <link>https://blog.kenhuang.io/blog/2024-11-08-cider-clojure-repl-cmdline/</link>
      <pubDate>Fri, 08 Nov 2024 00:02:56 +0800</pubDate><author>whatacold@gmail.com (Ken Huang)</author>
      <guid>https://blog.kenhuang.io/blog/2024-11-08-cider-clojure-repl-cmdline/</guid>
      <description>&lt;p&gt;&#xA;While troubleshooting and fixing a &lt;a href=&#34;https://github.com/scicloj/clay/issues/176&#34;&gt;live reload bug&lt;/a&gt; in &lt;a href=&#34;https://github.com/scicloj/clay&#34;&gt;Clay&lt;/a&gt; today, which required to start a minimal Clojure environment, I figured out how to start a nREPL from the command line.&lt;/p&gt;&#xA;&lt;p&gt;&#xA;Instead of using &lt;code class=&#34;verbatim&#34;&gt;M-x cider-jack-in-clj&lt;/code&gt; directly from Emacs, actually we can manully bring up an nREPL with this: &lt;code class=&#34;verbatim&#34;&gt;clj -Sdeps &amp;#34;{:deps {org.scicloj/clay {:mvn/version \&amp;#34;2-beta21\&amp;#34;} cider/cider-nrepl {:mvn/version \&amp;#34;0.50.2\&amp;#34;}}}&amp;#34; -m nrepl.cmdline --middleware &amp;#34;[cider.nrepl/cider-middleware]&amp;#34;&lt;/code&gt; (The clay part is only necessary for this debugging), and then connect to this nREPL using the Emacs command &lt;code class=&#34;verbatim&#34;&gt;M-x cider-connect-clj&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Clojure reduce: one case for text processing</title>
      <link>https://blog.kenhuang.io/blog/2021-09-19-clojure-reduce-text-processing/</link>
      <pubDate>Sun, 19 Sep 2021 10:39:23 +0800</pubDate><author>whatacold@gmail.com (Ken Huang)</author>
      <guid>https://blog.kenhuang.io/blog/2021-09-19-clojure-reduce-text-processing/</guid>
      <description>&lt;p&gt;&#xA;As a practice, I managed to illustrate &lt;strong&gt;Clojure files&lt;/strong&gt; using &lt;a href=&#34;https://blog.kenhuang.io/blog/2021-08-07-illustrate-clojure-snippet/&#34;&gt;illustrate.clj&lt;/a&gt;, but my original idea was to annotate org-mode files of blogs. It&amp;#39;s not uncommon that a blog post has some code snippets.&lt;/p&gt;&#xA;&lt;p&gt;&#xA;But it missed the feature until last night, as I wasn&amp;#39;t sure how to implement it appropriately before and didn&amp;#39;t have enough time.&lt;/p&gt;&#xA;&lt;p&gt;&#xA;For example, I may have an org-mode like this:&lt;/p&gt;&#xA;&lt;div class=&#34;src src-org&#34;&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-org&#34; data-lang=&#34;org&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;sum of two numbers:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c&#34;&gt;#+begin_src &lt;/span&gt;&lt;span class=&#34;cs&#34;&gt;clojure&lt;/span&gt;&lt;span class=&#34;c&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c&#34;&gt;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nb&#34;&gt;+ &lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c&#34;&gt;#+end_src&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;&#xA;I want to have a result comment (&lt;code class=&#34;verbatim&#34;&gt;(;; =&amp;gt; 3)&lt;/code&gt;) after each top-level form after using &lt;code class=&#34;verbatim&#34;&gt;illustrate.clj&lt;/code&gt;:&#xA;sum of two numbers:&lt;/p&gt;</description>
    </item>
    <item>
      <title>illustrate.clj to Illustrate Clojure Snippet</title>
      <link>https://blog.kenhuang.io/blog/2021-08-07-illustrate-clojure-snippet/</link>
      <pubDate>Sat, 07 Aug 2021 18:49:25 +0800</pubDate><author>whatacold@gmail.com (Ken Huang)</author>
      <guid>https://blog.kenhuang.io/blog/2021-08-07-illustrate-clojure-snippet/</guid>
      <description>&lt;p&gt;&#xA;To get my hands dirty with Clojure, I am trying to find or implement Clojure&amp;#39;s string functions in the sense of Python. Python has powerful string APIs, and I also want to see how powerful Clojure could be in this field. That would be interesting.&lt;/p&gt;&#xA;&lt;p&gt;&#xA;As shown in the &lt;a href=&#34;https://clojure.org/api/cheatsheet&#34;&gt;cheatsheet&lt;/a&gt;, Clojure has implemented most of them, and there are some that I have to implement myself, like &lt;a href=&#34;https://blog.kenhuang.io/blog/2021-07-25-clojure-string-title-case/&#34;&gt;title-case&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&#xA;Along the way, I found it was a little cumbersome to append the evaluation result and the result of calling them, for example,&lt;/p&gt;</description>
    </item>
    <item>
      <title>String Title Case in Clojure</title>
      <link>https://blog.kenhuang.io/blog/2021-07-25-clojure-string-title-case/</link>
      <pubDate>Sun, 25 Jul 2021 11:51:39 +0800</pubDate><author>whatacold@gmail.com (Ken Huang)</author>
      <guid>https://blog.kenhuang.io/blog/2021-07-25-clojure-string-title-case/</guid>
      <description>&lt;p&gt;&#xA;These days I like to write scripts for some tasks in Python instead of shell. One important reason I think that&amp;#39;s because Python is powerful at string manipulation.&lt;/p&gt;&#xA;&lt;p&gt;&#xA;Recently I&amp;#39;m learning Clojure, and I&amp;#39;m trying to find similar ways in Clojure, one of them is &lt;code class=&#34;verbatim&#34;&gt;s.title()&lt;/code&gt; for getting a title-cased version of a string. For example,&lt;/p&gt;&#xA;&lt;div class=&#34;src src-text&#34;&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&amp;gt;&amp;gt;&amp;gt; &amp;#39; Hello world&amp;#39;.title()&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&amp;#39; Hello World&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;&#xA;How to do that in Clojure? To make the problem simple, let&amp;#39;s assume that the input string only has letters and spaces, that is, &lt;code class=&#34;verbatim&#34;&gt;[a-zA-Z ]&lt;/code&gt; in regex pattern.&lt;/p&gt;</description>
    </item>
    <item>
      <title>String Manipulation in Clojure</title>
      <link>https://blog.kenhuang.io/blog/2021-07-22-clojure-string-manipulation/</link>
      <pubDate>Thu, 22 Jul 2021 23:29:11 +0800</pubDate><author>whatacold@gmail.com (Ken Huang)</author>
      <guid>https://blog.kenhuang.io/blog/2021-07-22-clojure-string-manipulation/</guid>
      <description>&lt;p&gt;&#xA;Python string APIs are powerful and concise, that is an important reason I use it to do a lot of scripting these days, &lt;code class=&#34;verbatim&#34;&gt;join&lt;/code&gt;, &lt;code class=&#34;verbatim&#34;&gt;split&lt;/code&gt;, &lt;code class=&#34;verbatim&#34;&gt;strip&lt;/code&gt;, to name a few.&lt;/p&gt;&#xA;&lt;p&gt;&#xA;Since I am learning Clojure recently, I am wondering, how is string manipulation like in Clojure and how to implement equivalent ones?&lt;/p&gt;&#xA;&lt;p&gt;&#xA;I think it&amp;#39;s an excellent opportunity to get familiar with Clojure. Before diving into the implementation, how to declare a multi-line string?&lt;/p&gt;</description>
    </item>
    <item>
      <title>A Random Password Generator in Babashka</title>
      <link>https://blog.kenhuang.io/blog/2021-07-11-babashka-random-password-generator/</link>
      <pubDate>Sun, 11 Jul 2021 09:18:41 +0800</pubDate><author>whatacold@gmail.com (Ken Huang)</author>
      <guid>https://blog.kenhuang.io/blog/2021-07-11-babashka-random-password-generator/</guid>
      <description>&lt;p&gt;&#xA;I&amp;#39;m used to learning by practicing, so when I learned Clojure, I always kept an eye on chances to write code in it.&lt;/p&gt;&#xA;&lt;p&gt;&#xA;Scripting is an excellent field to practice, but the experience is not so good. On the one hand, it&amp;#39;s too hacky to wrap Clojure code in a shell script with the shell bang. On the other hand, the startup time of JVM is too long to hurt the user experience.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
