Skip to content

Instantly share code, notes, and snippets.

(defun read-journal (path)
(with-temp-buffer
(insert-file-contents (concat "~/notes/journal/" path))
(split-string (buffer-string) "\n" t)))
(defun read-first-three-lines (list)
(cond ((>= (length list) 4) (subseq list 1 3))
((>= (length list) 1) (nthcdr 1 list))
(t list)))
@yang-wei
yang-wei / note.md
Last active April 2, 2024 22:27
Clojure Thread-first vs Thread-last Macros

Repost from:

http://yangweilim.com/blog/2015/11/18/clojure-thread-first-vs-thread-last-macros/

In this post, I am going to show you {when|how} to use Clojure marcos, ->> aka thread-last and -> aka thread-first. In some case, -> and ->> may perform the same operation if you do not pay enough attention. So I will also show you what's the difference between them. Note that doc -> and docs ->> din't make sense for me at first, so if same thing happened to you I hope that this post will make it clear.

If I am coding a function in Clojure, I would not think to write in macro firstly(maybe I am still new to it?). Macros like -> and ->> only come in my mind when it comes to refactoring. They are not neccessary in our program but they will make it elegant.

To explain how both of these macros work, let's us solve a quiz together.

[Write a function which calculates factorials.](http://www.4clojure.com/prob

@mattiaslundberg
mattiaslundberg / arch-linux-install
Last active March 29, 2024 08:38
Minimal instructions for installing arch linux on an UEFI system with full system encryption using dm-crypt and luks
# Install ARCH Linux with encrypted file-system and UEFI
# The official installation guide (https://wiki.archlinux.org/index.php/Installation_Guide) contains a more verbose description.
# Download the archiso image from https://www.archlinux.org/
# Copy to a usb-drive
dd if=archlinux.img of=/dev/sdX bs=16M && sync # on linux
# Boot from the usb. If the usb fails to boot, make sure that secure boot is disabled in the BIOS configuration.
# Set swedish keymap