This file contains hidden or 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 git-log-stat-since | |
| [&opt date] | |
| (let [d (os/date) | |
| date (or date | |
| (string/format "%i-%02i-%02i" (d :year) | |
| (inc (d :month)) # 0-indexed | |
| (inc (d :month-day)) # 0-indexed | |
| )) | |
| p (os/spawn ["git" "log" "--stat" (string `--since="` date ` 00:00"`)] | |
| :p |
This file contains hidden or 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
| #!/bin/zsh | |
| # exit when a command fails | |
| set -e | |
| mkdir -p bin | |
| cc -dynamiclib lib.c -o ./bin/lib.dylib | |
| cc reload_dylibs.c -o bin/main && ./bin/main |
This file contains hidden or 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 push | |
| [l v] | |
| [;l v]) | |
| (defn pop | |
| [l] | |
| (if (empty? l) | |
| l | |
| (tuple/slice l 0 -2))) |
This file contains hidden or 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 class AssertionError extends Error { | |
| constructor(message) { | |
| super(message) | |
| this.name = "AssertionError" | |
| } | |
| } | |
| export const assert = (pred, msg = "") => { | |
| if (typeof pred === "function") { | |
| if (pred()) return true |
This file contains hidden or 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 exec = require("node:util").promisify(require("node:child_process").exec) | |
| const get = (l, n) => (l == null ? null : l.length <= n ? null : l[n]) | |
| const lid_open = async () => { | |
| const { stdout: res } = await exec( | |
| "ioreg -r -k AppleClamshellState -d 4 | grep AppleClamshellState | head -1" | |
| ) | |
| const re = /.*"AppleClamshellState" = (No|Yes).*/ | |
| return get(re.exec(res), 1) == "No" |
OlderNewer