This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local function remap(from_key, to_key) | |
return hs.hotkey.new(from_key[1], from_key[2], | |
function() hs.eventtap.keyStroke(to_key[1], to_key[2]) end) | |
end | |
local maps={} | |
local function remap_add(win_filter_name, from_key, to_key) | |
maps[win_filter_name] = maps[win_filter_name] or {} | |
table.insert(maps[win_filter_name], remap(from_key, to_key)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- https://github.com/Hammerspoon/hammerspoon/issues/664 | |
slack_c_n = hs.hotkey.new({"ctrl"}, 'n', function() | |
hs.eventtap.keyStroke({}, 'down') | |
end) | |
slack_c_p = hs.hotkey.new({"ctrl"}, 'p', function() | |
hs.eventtap.keyStroke({}, 'up') | |
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; (keymap-global-set "C-c o" 'browse-url-at-point) | |
(defun rgc/add-stripe (args) | |
"prepend the right stripe path to be able to find the entity | |
you're looking for" | |
(let* ((arg (s-replace-regexp "^https?://" "" (car args))) | |
(path | |
(cond |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def hh [{:a 1, :b 2, :c 3 :aa 4} {:a 1, :b 2, :c 4 :aa 4} {:a 99, :b 2, :c 3 :aa 5}]) | |
(def rname :trial-ups) | |
(def main-f [:b :a]) | |
;; first stab, we pivot over the keys of the "root" entity, | |
;; group by them, and strip the rest out | |
(defn hydrate-with-main-entity-keys [m ks as] | |
(->> (group-by #(select-keys % main-f) hh) | |
(m/map-vals (partial map #(apply dissoc % main-f))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# helping to find dupes. Not complete, | |
# but this can serve as a basis for a pure shellscript dup finder | |
find . -type f -exec du -s {} \; -exec /usr/bin/basename {} \; >/tmp/list.txt | |
cat /tmp/list.txt | cut -f1 -d' ' | paste - - | grep png | sort | uniq| wc -l | |
cat /tmp/list.txt | cut -f1 -d' ' | paste - - | grep png | sort | wc -l |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# fzf is either fzf or a naive version of it | |
# the input is a sed line number, so it can be | |
# single number: 42 | |
# range: 1,10 | |
# separate lines: 10p;50p | |
mute command -v fzf || | |
fzf() { | |
local in=$(cat) | |
for p in "${@}"; do | |
[ "$p" = "-0" ] && [ "$(echo "$in" | wc -l)" -eq 1 ] && [ "" = "$in" ] && return 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data:text/html,<canvas id="v"><script>d=document,d.body.style.margin=0,f=0,c=v.getContext("2d"),v.width=innerWidth,v.height=innerHeight,c.lineWidth=2,x=e=>e.clientX||e.touches[0].clientX,y=e=>e.clientY||e.touches[0].clientY,d.onmousedown=d.ontouchstart=e=>{f=1,e.preventDefault(),c.moveTo(x(e),y(e)),c.beginPath()},d.onmousemove=d.ontouchmove=e=>{f&&(c.lineTo(x(e),y(e)),c.stroke())},d.onmouseup=d.ontouchend=e=>f=0</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mb:maybehelp() { | |
local msg="$1";shift | |
if any equals_help "$@"; then | |
warn "$msg" | |
return 1 | |
fi | |
} | |
mb:maybehelp "mmsg" "$@" || return 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- select internal.array_unique(array['foo','bar'] || array['foo']) | |
create or replace function array_unique (a text[]) returns text[] as $$ | |
select array ( | |
select distinct v from unnest(a) as b(v) | |
) | |
$$ language sql; | |
-- Example usage: | |
-- select ts, op, jsonb_pretty(mb_jsonb_diff(record, old_record)) | |
-- from audit.record_version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn apply-if | |
"if(p(m)) then f(m, ...args) else m | |
Useful for `maybe-*` like updates." | |
[m p f & args] | |
(if (p m) | |
(apply f m args) | |
m)) | |
(defn fork [l c r] |
NewerOlder