Skip to content

Instantly share code, notes, and snippets.

View asafch's full-sized avatar

Asaf Chelouche asafch

  • Israel
View GitHub Profile
@asafch
asafch / compute-if-absent.clj
Created August 19, 2020 06:34
Mimic Java's Map::computeIfAbsent in Clojure
(def store (atom {}))
(defn nil-protect [f]
(fn [m k]
(if-let [v' (f k)]
(assoc m k v')
m)))
(defn compute-if-absent [a k f]
(let [m (swap! a (nil-protect f) k)] ; in essence: (f m k)
@asafch
asafch / Default (OS X).sublime-keymap
Last active March 10, 2022 08:02 — forked from nelanka/Default (OS X).sublime-keymap
Sublime Text 3 - User Key Bindings (IntelliJ IDEA Style) - OS X
[
{ "keys": ["super+y"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Line.sublime-macro"} },
{ "keys": ["super+d"], "command": "duplicate_line" },
{ "keys": ["super+`"], "command": "toggle_side_bar" },
{ "keys": ["super+r"], "command": "show_panel", "args": {"panel": "replace", "reverse": false} },
{ "keys": ["super+shift+up"], "command": "swap_line_up" },
{ "keys": ["super+shift+down"], "command": "swap_line_down" },
{ "keys": ["ctrl+tab"], "command": "next_view" },
{ "keys": ["ctrl+shift+tab"], "command": "prev_view" },
{ "keys": ["alt+m"], "command": "markdown_preview", "args": {"target": "browser", "parser":"markdown"} },