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 fennel (require :fennel)) | |
(local pp fennel.view) | |
;; CAGS | |
(local mod-map {:a :ctrl :s :alt :d :cmd :f :shift | |
:j :rightshift :k :rightcmd :l :rightalt ";" :rightctrl}) | |
(local flags-map {:deviceLeftAlternate :alt | |
:deviceLeftCommand :cmd | |
:deviceLeftControl :ctrl |
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
export EDITOR=vim | |
export ZSH="$HOME/.oh-my-zsh" | |
ZSH_THEME="nicoulaj" | |
plugins=(asdf aws docker direnv fasd fzf git helm history jq kubectl macos) | |
source $ZSH/oh-my-zsh.sh | |
export FZF_DEFAULT_OPTS="--bind ctrl-k:kill-line,ctrl-b:preview-page-up,ctrl-f:preview-page-down" | |
export _FASD_BACKENDS="native spotlight" | |
export PATH="$PATH:$HOME/Library/Android/sdk/platform-tools" |
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
const utcDate = new Date("2022-06-15T05:00:00Z"); | |
console.log("utcDate", utcDate, utcDate.toString()); | |
const utcDate2 = set(utcDate, { hours: 1 }); // Always set in curren time | |
console.log("utcDate2", utcDate2, utcDate2.toString()); | |
const zonedDate = utcToZonedTime(utcDate, "Asia/Jakarta"); // 5 + 7 = 12 in current timezone (pretend to be in local) | |
console.log("zoneDate", zonedDate, zonedDate.toString()); | |
const zonedDate2 = set(zonedDate, { hours: 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
# remote-random | |
cat *.json | jq -s -r 'sort_by(.country) | .[] | "remote \(.ip) 1193 # \(.country)-\(.city)"' | |
# remote | |
cat *.json | jq -s -r "sort_by(.country) | .[] | \"cat ~/.config/default.ovpn | sed 's/remote XXX/remote \(.ip) 1193 # \(.country)-\(.city)/' > '\(.country)-\(.city)-\(.ip).ovpn'\"" |
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
;; evaluate this to remove all IDs that are neither: a target, has attachment(s) nor timestamp (synced with caldav) | |
;; assume everything is in `~/org', including archived files | |
;; require `rg', `jq' and `awk' | |
(let* ((default-directory (expand-file-name "~/org")) | |
(ids (-> (shell-command-to-string | |
"rg -a -g '*.org*' --json '^:ID:\s*([A-Za-z00-9\-])+\s*$' | jq -r '.data.submatches | select(.) | .[].match.text' | awk '{ print $2 }' | sort") | |
(string-trim) | |
(split-string "\n"))) | |
(targets (-> (shell-command-to-string | |
(format "rg -a -g '*.org*' --json '\\[id:(%s)]' | jq -r '.data.submatches | select(.) | .[].match.text[4:-1]' | sort" (string-join ids "|"))) |
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
< Citations.jsonl | curl -vv -H 'Content-Type: application/octet-stream' http://127.0.0.1:5001/hatchi-mobile/us-central1/maintainance\?secret\=$SECRET\&action\=importCol\&col\=Citations\&withSubCollections\=1 --data-binary @- ; \ | |
< Concours.jsonl | curl -vv -H 'Content-Type: application/octet-stream' http://127.0.0.1:5001/hatchi-mobile/us-central1/maintainance\?secret\=$SECRET\&action\=importCol\&col\=Concours\&withSubCollections\=1 --data-binary @- ; \ | |
< Conseils.jsonl | curl -vv -H 'Content-Type: application/octet-stream' http://127.0.0.1:5001/hatchi-mobile/us-central1/maintainance\?secret\=$SECRET\&action\=importCol\&col\=Conseils\&withSubCollections\=1 --data-binary @- ; \ | |
< Devises.jsonl | curl -vv -H 'Content-Type: application/octet-stream' http://127.0.0.1:5001/hatchi-mobile/us-central1/maintainance\?secret\=$SECRET\&action\=importCol\&col\=Devises\&withSubCollections\=1 --data-binary @- ; \ | |
< Dictionnary_mot_interdit.jsonl | curl -vv -H 'Content-Type: application/octet-stream' http://127.0.0.1:5001/ha |
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
(defun merge-lists (&rest lists) | |
"Merge list, keep elements' order the same as where they are in the original lists. | |
E.g `(merge-list '(1 2) '(3 4 5))' should returns `(1 3 2 4 5)'." | |
(let ((copy (mapcar 'copy-sequence lists)) | |
(result)) | |
(while copy | |
(dolist (lst copy) | |
(when-let ((elt (pop lst))) ; pop doesn't change `lst' | |
(push elt result))) |
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
api.driver.cloud.private | |
api.driver.cloud.transalliance.eu | |
|~ "(?i)error" | |
|= `ms {` | |
| pattern `<ts> stdout F <method> <url> <code> <ms>ms {` |
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
;; -- Coroutinize | |
(fn coroutinize [f ...] | |
"Coroutinize a function `f' allow to to call functions with a callback within its body naturally | |
via coroutine, eliminate the callback hell. | |
These function often need to be evaluated in main thread or where `coroutine.resume' is not | |
availabe (Hammerspoon). The functions should to be wraped within `(fn [resolve] (f ... resolve))' | |
and yielded.They will be evaluated (in main thread) and come back via `coroutine.yield' |
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
sudo sed -i '' '2i\ | |
auth sufficient pam_tid.so | |
' /etc/pam.d/sudo |
NewerOlder