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/bash | |
if [[ "$#" -ne 2 ]]; then | |
echo "ERROR: Invalid number of arguments" >&2; | |
echo >&2; | |
echo "Usage: ./listfiles.sh <directory> <outfile>" >&2; | |
exit 1; | |
fi | |
TARGET_DIR="$1"; |
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/sh | |
confirm() { | |
local prompt="$1"; | |
local default; | |
case "$2" in | |
true | True | yes) | |
default="True"; | |
;; | |
false | False | no) |
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
from decimal import Decimal | |
from enum import IntEnum | |
from numbers import Real | |
class ByteUnit(IntEnum): | |
BYTE = 1 | |
KILLIBYTE = 1024**1 | |
MEGABYTE = 1024**2 | |
GIGABYTE = 1024**3 |
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
"""Converts firefox's JSON bookmarks format to the CSV format raindrop.io expects | |
See here for docs on raindrop: https://help.raindrop.io/import/#csv | |
""" | |
from __future__ import annotations | |
from typing import ( | |
ClassVar, Iterable, NewType, Any, Iterator | |
) | |
from enum import Enum, nonmember as enum_nonmember |
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
# Website: https://attractivechaos.github.io/klib/ | |
# Source: https://github.com/attractivechaos/klib | |
# | |
# Meson Wrap Gist: | |
# Meson Wrap Version: 1 | |
[wrap-git] | |
url = https://github.com/attractivechaos/klib.git | |
revision = head | |
patch_directory = klib |
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
(import sh) | |
(import spork) | |
(def- metric-prefixes ["K" "M" "G" "T" "P" "E"]) | |
(defn- makeunit [&named name base-prefix binary] | |
(default binary false) | |
(assert (keyword? name)) | |
(assert (not (empty? (string name)))) | |
(assert (string? base-prefix)) |
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 std = @import("std"); | |
fn sdk_root() []const u8 { | |
return std.fs.path.dirname(@src().file) orelse "."; | |
} | |
fn dep_root_working() []const u8 { | |
const sdk_root_val = comptime blk: { break :blk sdk_root(); }; | |
return sdk_root_val ++ "/deps/mpack"; | |
} |
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/bash | |
# Available as github gist: https://gist.github.com/Techcable/b83df781602857dd2f6cf0074e50ba77 | |
set -e | |
if [[ $# -eq 1 ]]; then | |
OUT_FILE="$(realpath "$1")"; | |
else | |
echo "ERROR: Invalid arguments" >&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
# See also andrewchambers/janet-sh for a more complete (and awesome) solution: | |
# https://acha.ninja/blog/dsl_for_shell_scripting/ | |
# | |
# Source: https://github.com/janet-lang/jpm/blob/07b0c18daf75cfdf098eff5526a17ad0436e3dc0/jpm/shutil.janet#L123-L137 | |
(defn exec-slurp | |
"Read stdout of subprocess and return it trimmed in a string." | |
[& args] | |
(when (dyn :verbose) | |
(flush) | |
(print ;(interpose " " args))) |
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 primes-before | |
"Gives all the primes < limit" | |
[limit] | |
(assert (int? limit)) | |
# Janet has a buffer type (mutable string) which has easy methods for use as bitset | |
(def buf-size (math/ceil (/ (+ 1 limit) 8))) | |
(def is-prime (buffer/new-filled buf-size (bnot 0))) | |
(buffer/bit-clear is-prime 0) | |
(buffer/bit-clear is-prime 1) | |
(for n 0 (math/ceil (math/sqrt limit)) |