commit 5e8f809ec5d14c3cca1264e85eb927269862e38c from: Omar Polo date: Sat Jun 27 19:28:16 2020 UTC switching from boot to deps.edn, posts as edn and new post! commit - be1f925848a678ff434ab43ba621b2e2b47fcf0a commit + 5e8f809ec5d14c3cca1264e85eb927269862e38c blob - 661187a97f5941c91bfdf7e31d3250443dc2b265 blob + 73e86db20370c388c6629efb4f2ba2ec88af36d9 --- .gitignore +++ .gitignore @@ -1,2 +1,3 @@ resources/out/ .nrepl-port +.cpcache blob - 8f63bd2d6ce044fb73997c7e5b73efa685e87a33 (mode 644) blob + /dev/null --- build.boot +++ /dev/null @@ -1,12 +0,0 @@ -(set-env! - :resource-paths #{"src" "resources"} - :dependencies '[[hiccup "1.0.5"] - [ring "1.8.0"] - [commonmark-hiccup "0.1.0"] - [org.clojure/data.xml "0.2.0-alpha6"]]) - -(task-options! - pom {:project 'blog - :version "0.1.0"}) - -(require '[blog.core :refer :all]) blob - /dev/null blob + d664601d24d43daa0c7fda126953e2e1fae551a8 (mode 644) --- /dev/null +++ deps.edn @@ -0,0 +1,9 @@ +{:deps {hiccup {:mvn/version "1.0.5"} + ring {:mvn/version "1.8.0"} + commonmark-hiccup {:mvn/version "0.1.0"} + org.clojure/data.xml {:mvn/version "0.2.0-alpha6"}} + + :paths ["src" "resources"] + + :aliases + {:act {:main-opts ["-m" "blog.core"]}}} blob - /dev/null blob + 68083c5d48208c7b9594e6d76b52e1b843cfc95e (mode 644) --- /dev/null +++ resources/posts/enjoying-cdpath.md @@ -0,0 +1,99 @@ +If you use the shell a lot, you may find this advice useful, in case +you didn't already knew it. There's an environment variable called +CDPATH, used by most shell I know and others cli tools, whose *raison +d'ĂȘtre* is to simplify `cd`-ing around. + +As various environmental variables in UNIX, its value is a list of +directories separated by colons, just like PATH. For instance, this +is what I currently have in my `~/.kshrc`: + +```sh +export CDPATH=.:$HOME/w:/usr/ports +``` + +With that in place, no matter where my current working directory is, I +can `cd games/godot` to jump to `/usr/ports/games/godot`! + +A note of warning: `.` (the dot aka your current working directory) +should be present in your `$CDPATH`, otherwise you won't be able to +`cd` into directories not found in your `$CDPATH` (you can use `cd +./$somedir`, but isn't probably what you want). + +## Programs that I know respect `$CDPATH` + +Since the entry would be too short otherwise, here's some programs +that I know respect `$CDPATH`, and how they behave. + +### ksh (OpenBSD pdksh) + +Just as I showed you up there. When you `cd` into a directory inside +your `$CDPATH` it will print your new current working directory: + + $ cd games/godot + /usr/ports/games/godot + +It will not, however, autocomplete. + +### bash + +It will behave just as ksh. + +### zsh + +`zsh` respects `$CDPATH`. It does not seem to do completions tho :( + +### rc + +9ports rc does not seem to inherit `$CDPATH`, but you can set it +(unsurprisingly) with + + cdpath=(. /usr/ports) + +in your `~/lib/profile`. Other versions of `rc` (I'm talking about the +one you get with the `rc` package on FreeBSD) do inherit it, so double +check! + +Additionally, `rc` prints the `pwd` only if you're `cd`-ing into +something that's not within `.` (the current directory). So: + + % pwd + /home/op + % echo $cdpath + . /usr/ports + % cd bin # won't print /home/op/bin + % cd games + /usr/ports/games + % + +### csh & tcsh + + set cdpath = (. /usr/ports) + +for the rest, behaves exactly like `rc`. I don't really use csh, nor +tcsh, so I can't make further comments. + +### fish + +I've installed fish just for this post. It does respect `$CDPATH` +and, unlike other shells, is also able to do proper autocompletion +out-of-the-box. + +### vi (nvi) + +`vi` will inherit your `$CDPATH` (make sure you're `export`ing it!). +You can also `:set cdpath=...` if you wish. You cannot edit a file +like `:e games/godot/Makefile` and assume vi will open +`/usr/ports/games/godot/Makefile` though, you need first to `:cd +games/godot` and then `:e Makefile`! + +### bonus: emacs + +Emacs vanilla `M-x cd` respects your `$CDPATH`, you just have to +delete the default text in the minibuffer. It also does proper +autocompletion! Additionally, `eshell` respects `$CDPATH` too! Not +all emacs packages will, unfortunately. For instance, `ivy` doesn't +seem to care about it. + +On the other hand, with emacs you have other ways to quickly jump +around. Other than bookmarks (that I don't use), you have packages +like `projectile` that lets you jump between "projects" easily. blob - /dev/null blob + d505f771870d8ee2852d6d1cc57cc65315993c0c (mode 644) --- /dev/null +++ resources/posts.edn @@ -0,0 +1,96 @@ +[{:title "enjoying CDPATH" + :slug "enjoying-cdpath" + :date "2020/06/27" + :tags #{:sh} + :short "changing directory like a ninja."} + #_ {:title "sickforth episode 1: parsing" + :slug "sickforth-episode-01-parsing" + :date "2020/06/23" + :tags #{:compilers :sickforth} + :short "You've got to start from somewhere"} + #_ {:title "sickforth episode 0: introduction" + :slug "sickforth-episode-00-intro" + :date "2020/06/23" + :tags #{:compilers :sickforth} + :short "Let's write a compiler for an (arbitrary) subset of Forth!"} + #_ {:title "building FreeBSD packages with Synth" + :slug "building-freebsd-packages-with-synth" + :date "2020/06/13" + :tags #{:FreeBSD} + :short "Build with ease. Scripts included!"} + {:title "Threading macros for elisp" + :slug "elisp-threading-macros" + :date "2020/06/04" + :tags #{:elisp} + :short "(-> '->> symbol-name (concat \" is so cool\"))" + :toot "https://europecom.net/notice/9vm27kyIDp6oe8h3su"} + {:title "Updating the ssh key to ed25519" + :slug "upgrading-ssh-key-ed25519" + :date "2020/06/03" + :tags #{:ssh} + :short "no TL;DR this time"} + {:title "Logstash + jdbc = role does not exists" + :slug "logstash-jdbc-role-does-not-exists" + :date "2020/05/10" + :tags #{:logstash :postgresql} + :short "TL;DR use the connection string properly"} + {:title "Finite State Machine in Godot" + :slug "finite-automata-godot" + :date "2020/04/29" + :tags #{:godot} + :short "Did I mention how I love finite automata?"} + {:title "cgit & gitolite" + :slug "cgit-gitolite" + :date "2020/04/22" + :tags #{:git} + :short "Custom git server with web interface & users management"} + {:title "$HOME as a git repo" + :slug "home-as-git-repo" + :date "2020/04/02" + :tags #{:git} + :short "How do you track dotfiles?"} + {:title "Multiplexing data in sh(1)" + :slug "sh-multiplexing-data" + :date "2019/10/17" + :tags #{:sh} + :short "please put something clever here"} + {:title "Poor man's unbound dashboard" + :slug "poor-mans-unbound-dashboard" + :date "2019/10/16" + :tags #{:OpenBSD :tmux} + :short "A little bit of bash, fifos, tmux & ttyplot"} + {:title "Core naming in linux" + :slug "core-naming-on-linux" + :date "2019/10/15" + :tags #{:OpenBSD :linux} + :short "Porting BSD behaviours to linux"} + {:title "CSS sprites with awk and ImageMagick" + :slug "css-sprites-awk-imagemagick" + :date "2019/08/08" + :tags #{:css :awk} + :short "I like to automatize things"} + {:title "Using the C preprocessors for CSS generation" + :slug "cpp-css" + :date "2019/03/30" + :tags #{:css} + :short "old tools for new websites"} + {:title "F* on OpenBSD" + :slug "fstar-openbsd" + :date "2019/03/25" + :tags #{:fstar :OpenBSD} + :short "It just works"} + {:title "Abbreviations in vi(1)" + :slug "abbreviations-vi" + :date "2018/09/14" + :tags #{:vi} + :short "type even less"} + {:title "Improving maildir opening time in mutt" + :slug "maildir-mutt-time" + :date "2018/09/14" + :tags #{:mutt} + :short "header_cache is just awesome"} + {:title "Spell checking in vi(1)" + :slug "spell-checking-vi" + :date "2018/09/08" + :tags #{:vi} + :short "Aspell plays nice with vi."}] blob - 20d905d919dc8b342b19e5c891765351c67501a7 blob + 44c5d148b84b8e7956a8513d9c8212fe0cc1fcf0 --- src/blog/core.clj +++ src/blog/core.clj @@ -1,15 +1,16 @@ (ns blog.core - (:require [blog.time :as time] - [blog.templates :as templates] - [blog.rss :as rss] - [boot.core :as core] - [boot.task.built-in :as task] - [ring.adapter.jetty :as jetty] - [ring.middleware.resource :refer [wrap-resource]] - [ring.middleware.content-type :refer [wrap-content-type]] - [clojure.java.io :as io] - [clojure.java.shell :refer [sh]]) - (:import (java.io File))) + (:require + [blog.rss :as rss] + [blog.templates :as templates] + [blog.time :as time] + [clojure.edn :as edn] + [clojure.java.io :as io] + [clojure.java.shell :refer [sh]] + [ring.adapter.jetty :as jetty] + [ring.middleware.content-type :refer [wrap-content-type]] + [ring.middleware.resource :refer [wrap-resource]]) + (:import (java.io File)) + (:gen-class)) (defn copy-file [src dst] (with-open [in (io/input-stream (io/file src)) @@ -35,7 +36,14 @@ (doseq [t (:tags m)] (swap! per-tag update t conj p)))) -(load "posts") +(defn load-posts! [] + (reset! per-tag {}) + (reset! posts []) + (doseq [p (-> "posts.edn" + io/resource + slurp + edn/read-string)] + (add-post! p))) (defn create-dirs! [] (doseq [d ["resources/out" @@ -111,7 +119,7 @@ (copy-file "resources/favicon.ico" "resources/out/favicon.ico") (copy-file "resources/css/style.css" "resources/out/css/style.css")) -(core/deftask build +(defn build "Build the blog" [] (create-dirs!) @@ -127,7 +135,7 @@ (def j (atom nil)) -(core/deftask serve +(defn serve "Serve a preview" [] (reset! @@ -138,23 +146,34 @@ {:port 3000 :join? false}))) -(core/deftask clean +(defn clean "clean the output directory" [] (sh "rm" "-rf" "resources/out/")) -(core/deftask deploy +(defn deploy "Copy the files to the server" [] - (sh "openrsync" "-r" "--delete" "resources/out/" "op:sites/www.omarpolo.com/")) + (sh "rsync" "-r" "--delete" "resources/out/" "op:sites/www.omarpolo.com/")) (defn stop-jetty [] (.stop @j) (reset! j nil)) +(defn -main [& actions] + (load-posts!) + (doseq [action actions] + (case action + "clean" (clean) + "build" (build) + "deploy" (deploy) + + (println "unrecognized action" action)))) + (comment - (build) + (load-posts!) (clean) + (build) (serve) (stop-jetty) ) blob - 839cc8f21ad85e99f06478709af4f9b0dda0bb60 (mode 644) blob + /dev/null --- src/blog/posts.clj +++ /dev/null @@ -1,111 +0,0 @@ -(add-post! {:title "Threading macros for elisp" - :slug "elisp-threading-macros" - :date "2020/06/04" - :tags #{:elisp} - :short "(-> '->> symbol-name (concat \" is so cool\"))" - :toot "https://europecom.net/notice/9vm27kyIDp6oe8h3su"}) - -(add-post! {:title "Updating the ssh key to ed25519" - :slug "upgrading-ssh-key-ed25519" - :date "2020/06/03" - :tags #{:ssh} - :short "no TL;DR this time"}) - -(add-post! {:title "Logstash + jdbc = role does not exists" - :slug "logstash-jdbc-role-does-not-exists" - :date "2020/05/10" - :tags #{:logstash :postgresql} - :short "TL;DR use the connection string properly"}) - -(add-post! {:title "Finite State Machine in Godot" - :slug "finite-automata-godot" - :date "2020/04/29" - :tags #{:godot} - :short "Did I mention how I love finite automata?"}) - -(add-post! {:title "cgit & gitolite" - :slug "cgit-gitolite" - :date "2020/04/22" - :tags #{:git} - :short "Custom git server with web interface & users management"}) - -(add-post! {:title "$HOME as a git repo" - :slug "home-as-git-repo" - :date "2020/04/02" - :tags #{:git} - :short "How do you track dotfiles?"}) - -(comment - (add-post! {:title "Blogging with clojure" - :slug "blogging-with-clojure" - :date "2020/03/27" - :tags #{:clojure} - :short "Build static blogs with clojure & boot"})) - -(comment - (add-post! {:title "Build a personal FreeBSD repository" - :slug "freebsd-repository-with-synth" - :date "2020/03/24" - :tags #{:FreeBSD} - :short "Build with ease. Scripts included!"})) - -(comment - (add-post! {:title "A tale of three editors" - :slug "tale-of-three-editors" - :date "2019/10/04" - :tags #{:emacs :vi :acme} - :short "The gigantic, the fake minimal and the glorious. Or escaping the emacs-verse if you prefer."})) - -(add-post! {:title "Multiplexing data in sh(1)" - :slug "sh-multiplexing-data" - :date "2019/10/17" - :tags #{:sh} - :short "please put something clever here"}) - -(add-post! {:title "Poor man's unbound dashboard" - :slug "poor-mans-unbound-dashboard" - :date "2019/10/16" - :tags #{:OpenBSD :tmux} - :short "A little bit of bash, fifos, tmux & ttyplot"}) - -(add-post! {:title "Core naming in linux" - :slug "core-naming-on-linux" - :date "2019/10/15" - :tags #{:OpenBSD :linux} - :short "Porting BSD behaviours to linux"}) - -(add-post! {:title "CSS sprites with awk and ImageMagick" - :slug "css-sprites-awk-imagemagick" - :date "2019/08/08" - :tags #{:css :awk} - :short "I like to automatize things"}) - -(add-post! {:title "Using the C preprocessors for CSS generation" - :slug "cpp-css" - :date "2019/03/30" - :tags #{:css} - :short "old tools for new websites"}) - -(add-post! {:title "F* on OpenBSD" - :slug "fstar-openbsd" - :date "2019/03/25" - :tags #{:fstar :OpenBSD} - :short "It just works"}) - -(add-post! {:title "Abbreviations in vi(1)" - :slug "abbreviations-vi" - :date "2018/09/14" - :tags #{:vi} - :short "type even less"}) - -(add-post! {:title "Improving maildir opening time in mutt" - :slug "maildir-mutt-time" - :date "2018/09/14" - :tags #{:mutt} - :short "header_cache is just awesome"}) - -(add-post! {:title "Spell checking in vi(1)" - :slug "spell-checking-vi" - :date "2018/09/08" - :tags #{:vi} - :short "Aspell plays nice with vi."})