Skip to content

Instantly share code, notes, and snippets.

View frou's full-sized avatar

Duncan Holm frou

  • Scotland
  • 23:23 (UTC +01:00)
View GitHub Profile
@frou
frou / toggle_semi.ml
Last active June 15, 2024 14:43 — forked from hcarty/toggle_semi.ml
Put this in ~/.config/utop/init.ml to be able to press the F1 key to toggle requiring ;;
#require "lambda-term"
(* REF: https://gist.github.com/hcarty/b2dab5324d0d4344d771 *)
let toggle_implicit_double_semicolon =
let implicit_semis_enabled = ref false in
let parse_fn_stock = UTop.parse_toplevel_phrase.contents in
let parse_fn_dynamic code error_flag =
parse_fn_stock
(if implicit_semis_enabled.contents then code ^ ";;" else code)
error_flag
@frou
frou / DOMStringMap-to-map.cljs
Last active November 29, 2022 14:29 — forked from dwest/DOMStringMap IEncodeClojure
Convert a HTMLElement's dataset property into a ClojureScript map
;; DOMStringMap is the type of `HTMLElement.dataset` and contains the element's `data-*` attributes.
;; Implement the protocol used by the `cljs.core/js->clj` function.
(extend-type js/DOMStringMap
IEncodeClojure
(-js->clj [x {:keys [keywordize-keys]}]
(let [keyfn (if keywordize-keys keyword identity)]
(->> (.entries js/Object x)
(reduce
(fn [m [k v]] (assoc m (keyfn k) v))