Skip to content

Instantly share code, notes, and snippets.

View frankitox's full-sized avatar

Franco Biasin frankitox

  • Rosario, Argentina
  • 22:43 (UTC -03:00)
View GitHub Profile
@frankitox
frankitox / with-file.clj
Created January 9, 2021 00:33
Helper to clean generated files
(require '[clojure.java.io :as io])
(defmacro with-file
"bindings => [name init ...]
Evaluates body in a try expression with names bound to the values
of the inits, and a finally clause that calls (io/delete-file name) on each
name in reverse order."
[bindings & body]
(#'clojure.core/assert-args
(vector? bindings) "a vector for its binding"
@frankitox
frankitox / shell-exit-on-error.clj
Created January 11, 2021 01:27
Monad-like helpers to run spire's shell commands emulating `-e` (exit on error)
(require '[spire.module.shell :refer [shell]])
;; >>= :: m a -> (a -> m b) -> m b
(defn >>= [{:keys [result out-lines] :as prev} f]
(if (= result :ok)
(f out-lines)
prev))
;; return :: a -> m a
(defn return [cmd]
@frankitox
frankitox / xmonad.hs
Last active November 8, 2023 15:36
For anyone looking to map the workspaces 1-9 to use shortcuts in a grid (1, 2, 3 | q, w, e | a, s, d)
import XMonad (def, modMask, mod4Mask, xK_q, xK_w, xK_e, xK_a, xK_s, xK_d, borderWidth, layoutHook)
import XMonad.Main (xmonad)
import XMonad.Layout.Grid
import XMonad.Util.EZConfig (additionalKeys)
import XMonad.Util.PureX (defile, greedyView)
-- https://hoogle.haskell.org/
winKey = mod4Mask