Skip to content

Instantly share code, notes, and snippets.

@timmc
timmc / essentially.clj
Last active June 23, 2020 15:25
originally refheap.com/97879
(defmacro essentially
"Like letfn, but with the bindings at the end. Connotes that the
bindings are not important for the core logic, just for logging,
metrics, debugging etc. Recommend using footnote-looking bindings such
as *0, *1, *2 or even Unicode daggers if you are super-brave.
This is like Haskell's `where`. Thanks to amalloy for the pointer; no
blame attaches to him, though."
[& args]
`(letfn ~(last args)
~@(butlast args)))
@jaawerth
jaawerth / init.fnl
Last active December 4, 2023 09:37
hammerspoon (Macos automation) using fennel
; gist doesn't know what fennel is so let's say clj
; vi: ft=clojure
(set hs.logger.defaultLogLevel "info")
(local {:application app :hotkey hotkey} hs)
; use the SpoonInstall Spoon easy installing+loading of Spoons
(hs.loadSpoon :SpoonInstall)
(local install (. spoon :SpoonInstall))
; for window sizing, use the WIndowHalfsAndThirds Spoon until I can write something custom
@christoph-frick
christoph-frick / Awesome-Fennel.md
Last active March 1, 2024 19:42
Use fennel to write the awesome-wm config

How to write an awesome-wm config with Fennel

Awesome-WM is a X11 window manager, that is configured via Lua. Fennel is a Lisp for Lua. This shows a general setup of how to write your awesome-wm config using fennel directly without the compilation step (which would also work, but is not needed).

General setup

Fetch a recent Fennel version (the

@mfikes
mfikes / tree-seq.clj
Last active May 22, 2020 21:03
Directly-reducible PoC in Clojure
(defn nth' [coll n]
(transduce (drop n) (completing #(reduced %2)) nil coll))
(defn tree-seq'
[branch? children root]
(eduction (take-while some?) (map first)
(iterate (fn [[node pair]]
(when-some [[[node' & r] cont] (if (branch? node)
(if-some [cs (not-empty (children node))]
[cs pair]
@aphyr
aphyr / .conky-prs
Last active August 29, 2015 14:11
Pull request status on desktop via conky
use_xft yes
xftalpha 0.8
text_buffer_size 2048
own_window yes
own_window_argb_visual no
own_window_argb_value 0
own_window_transparent yes
own_window_type override
own_window_hints below,sticky,skip_taskbar,skip_pager
@timmc
timmc / ramdisk-target.sh
Last active October 12, 2017 19:39
Mount a ramdisk over target
#!/bin/bash
# Overwrite ./target with a tmpfs ramdisk. Prompts for sudo.
function usage() {
echo 'Usage: `ramdisk-target.sh recreate|restore`'
}
if [ ! -f "project.clj" ]; then
echo "Not in Clojure project."
exit 2
anonymous
anonymous / hmac-sha-256
Created December 16, 2013 05:06
(ns hmac
(:import (javax.crypto Mac) (javax.crypto.spec SecretKeySpec))
)
(defn secret-key-inst [key mac]
(SecretKeySpec. (.getBytes key) (.getAlgorithm mac))
)
(defn sign[key string]
"Returns the signature of a string with a given key, using a SHA-256 HMAC."