diff --git a/README.md b/README.md index a1e17bef..418f2036 100644 --- a/README.md +++ b/README.md @@ -401,7 +401,7 @@ handling of SIGINT and SIGPIPE. This can be done by setting - [Recursive document transformations with Pandoc and Clojure](https://play.teod.eu/document-transform-pandoc-clojure/) by Teodor Heggelund - [Blambda!](https://jmglov.net/blog/2022-07-03-blambda.html) by Josh Glover - [Babashka CLI](https://blog.michielborkent.nl/babashka-cli.html): turn Clojure functions into CLIs! -- [Breakneck Babashka on K8s](Breakneck Babashka on K8s) by Heow Goodman +- [Breakneck Babashka on K8s](https://www.linkedin.com/pulse/breakneck-babashka-k8s-heow-goodman/) by Heow Goodman - [Recursive document transformations with Pandoc and Clojure](https://play.teod.eu/document-transform-pandoc-clojure/) - [Detecting inconsistent aliases in a clojure codebase](https://www.youtube.com/watch?v=bf8KLKkCH2g) by Oxalorg - [I, too, Wrote Myself a Static Site Generator](https://dawranliou.com/blog/i-too-wrote-myself-a-static-site-generator/) by Daw-Ran Liou diff --git a/examples/README.md b/examples/README.md index 0f851994..53064d50 100644 --- a/examples/README.md +++ b/examples/README.md @@ -38,6 +38,8 @@ - [Simple logger](#simple-logger) - [Using GZip streams (memo utility)](#using-gzip-streams-to-make-a-note-utility) - [Pretty-printing mySQL results](#pretty-printing-mysql-results) + - [Single page application with Babashka + htmx](#single-page-application-with-babashka--htmx) + - [Wikipedia translation](#wikipedia-translation) Here's a gallery of useful examples. Do you have a useful example? PR welcome! @@ -390,7 +392,7 @@ Example usage: $ examples/http-server.clj ``` -See [file-server.clj](file-server.clj). +See [http-server.clj](http-server.clj). ## Torrent viewer @@ -555,3 +557,14 @@ Example of a todo list SPA using Babashka and htmx See [htmx_todoapp.clj](htmx_todoapp.clj) Contributed by [@prestancedesign](https://github.com/prestancedesign). + +## Wikipedia translation + +[wiki-translate.clj](wiki-translate.clj) uses Wikipedia to translate words from English to Dutch (other languages are available). + +``` shell +$ bb wiki-translate.clj window +"Venster (muur) – Dutch" +``` + +Shared by Janne Himanka on Clojurians Slack diff --git a/examples/wiki-translate.clj b/examples/wiki-translate.clj new file mode 100644 index 00000000..1558705b --- /dev/null +++ b/examples/wiki-translate.clj @@ -0,0 +1,11 @@ +#!/usr/bin/env bb +;; by Janne Himanka shared on Clojurians Slack +(require '[babashka.curl :as curl]) + +(let [url (str "https://en.wikipedia.org/wiki/" (first *command-line-args*)) + page (:body (curl/get url))] + (cond + (re-find #"Disambiguation" page) + (doseq [item (map last (re-seq #"