Skip to content

Instantly share code, notes, and snippets.

Avatar

Damian Hryniewicz werenall

  • Opole, Poland
View GitHub Profile
@werenall
werenall / tangle.sh
Created December 1, 2022 12:05
Bash function to tangle Org Mode
View tangle.sh
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
# USAGE:
# $ tangle README.org
@werenall
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
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"
"myproject/migrations/002-rename-foo-column"
"myproject/migrations/003-add-foreign-keys"]}
;;... ...}
View central-element.css
.canvas {
width: 600px;
display: flex;
}
.canvas__left {
display: flex;
flex: 1;
flex-shrink: 0;
}
.canvas__right {
@werenall
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 []
[:div.app-container
{:on-click #(tooltip/destroy-on-click-out (.. % -target))}
[main]])
@werenall
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
.-classList
(.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
werenall / tooltip.cljs
Created May 3, 2019 10:09
Atom-based tooltip
View tooltip.cljs
(let [display-tooltip? (r/atom false)]
(fn []
[:div.tooltip-controller
[:button
{:on-click #(swap! display-tooltip? not)}
"spawn tooltip"]
(when @display-tooltip?
[:div.tooltip.tooltip--bottom
[:button {:on-click #(reset! display-tooltip? false)} "x"]
[:p "Hello there!"]])]))
View keybase.md

Keybase proof

I hereby claim:

  • I am werenall on github.
  • I am werenall (https://keybase.io/werenall) on keybase.
  • I have a public key ASDLJxc_verqripryeV1ReE_Z86hTaPpDVj6VrDKhYIyYQo

To claim this, I am signing this object:

@werenall
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]