Skip to content

Instantly share code, notes, and snippets.

View werenall's full-sized avatar

Damian Hryniewicz werenall

  • Opole, Poland
View GitHub Profile
werenall / frivolous-secret-santa.clj
Last active December 14, 2023 13:52
Secret santa
View frivolous-secret-santa.clj
(defn- rand-🎁
[🎅 🎁-pool exclusions]
(let [potential-🎁 (-> 🎁-pool
(disj 🎅)
(set/difference (get exclusions 🎅)))]
(first (shuffle potential-🎁))))
(defn frivolously-draw-secret-santa
"Tries to randomize 🎅s hoping that with power of Christmas everything will just work.
Will give up after some retrials."
werenall /
Created December 1, 2022 12:05
Bash function to tangle Org Mode
function tangle {
path=$(realpath $1)
emacs --batch --eval "(require 'org)" --eval '(org-babel-tangle-file "'$path'")'
# consider putting it in .bash_profile along with the line below:
export -f tangle
# $ tangle
werenall / local.edn
Created April 9, 2020 14:02
Noop duct logger
View local.edn
... ...
:mocks.boundary.adapter.logger/noop {}
:duct.middleware.web/log-requests {:logger #ig/ref :mocks.boundary.adapter.logger/noop}
... ...
werenall / config.edn
Last active December 20, 2019 12:15
This gist is a draft of a module that would wrap duct configuration for ragtime migrations. I get a feeling that writing it by hand takes way too much space in config. Of course there are still some loose ends. For one, it could be more explicit about the ordering of migrations.
View config.edn
{;;... ...
:duct.migrator/ragtime {:database #ig/ref :duct.database/sql
:logger #ig/ref :duct/logger
:strategy :raise-error
:migrations-paths ["myproject/migrations/001-create-initial-schema"
;;... ...}
werenall / client.cljs
Last active June 24, 2019 16:10
Tooltips managed by re-frame's appdb
View client.cljs
(ns myapp.client
(:require [myapp.client.todo :as todo]))
(defn app []
{:on-click #(tooltip/destroy-on-click-out (.. % -target))}
View central-element.css
.canvas {
width: 600px;
display: flex;
.canvas__left {
display: flex;
flex: 1;
flex-shrink: 0;
.canvas__right {
werenall / tooltip-react-lifecycle.cljs
Created May 3, 2019 10:40
Tooltip using React's lifecycle methods
View tooltip-react-lifecycle.cljs
(defn find-tooltip-controller-class [node]
(or (some-> node
(.contains "js-tooltip-controller"))
(some-> (.-parentNode node) (find-tooltip-controller-class))))
(defn tooltip [display-tooltip?]
(let [click-handler (fn [e]
(.stopPropagation e)
(when-not (find-tooltip-controller-class (.. e -target))
werenall / tooltip.cljs
Created May 3, 2019 10:09
Atom-based tooltip
View tooltip.cljs
(let [display-tooltip? (r/atom false)]
(fn []
{:on-click #(swap! display-tooltip? not)}
"spawn tooltip"]
(when @display-tooltip?
[:button {:on-click #(reset! display-tooltip? false)} "x"]
[:p "Hello there!"]])]))

Keybase proof

I hereby claim:

  • I am werenall on github.
  • I am werenall ( on keybase.
  • I have a public key ASDLJxc_verqripryeV1ReE_Z86hTaPpDVj6VrDKhYIyYQo

To claim this, I am signing this object:

werenall / gist:e546aac5a6c4dae10b731c8a990401d4
Created February 18, 2018 15:26
Calculate something in a checkup and eventually return that calculation
View gist:e546aac5a6c4dae10b731c8a990401d4
;; Instead of doing
(if (and (some? "checking if displaying it should even be considered")
(some->> txt (vector :div))
(some->> txt (vector :div)))
;; => [:div txt]
;; Consider doing
(and (some? "checking if displaying it should even bbe considered")
(some->> txt (vector :div))
;; => [:div txt]