Skip to content

Instantly share code, notes, and snippets.

@radixm46
radixm46 / kea-dhcp.conf
Created July 16, 2024 09:40
kea dhcpでclassless static route配布
// kea dhcpでclassless static route配布
{
"Dhcp4": {
// ....
"subnet4": [
{
"id": 1,
"subnet": "192.168.0.0/24",
"option-data": [
{
(leaf mastodon
:preface
(leaf emojify
:ensure t
:custom `((emojify-emojis-dir . ,(cache-sub-dir "emojify"))))
:ensure t
:custom
(mastodon-instance-url . "https://mstdn.example.com")
(mastodon-active-user . "user-name")
(mastodon-media--enable-image-caching . t)
@radixm46
radixm46 / kmoni.sh
Created April 6, 2024 08:27
強震モニタをweztermに表示するやつ(macOSだと喋る)
#!/usr/bin/env bash
set -euo pipefail
# requirements: bc, curl, wezterm, jq, imagemagick
base='http://www.kmoni.bosai.go.jp'
wdir="$(mktemp --directory -t kmoni)"
rdate="$(date -r $(($(date +%s) - 4)) +%Y%m%d%H%M%S)"
baseimg="base_map_w.gif"
jmasimg="${rdate}.jma_s.gif"
waveimg="${rdate}.eew.gif"
@radixm46
radixm46 / sipsmult.el
Last active October 12, 2023 04:53
Converting PNG to JPG using sips and pbpaste on macOS for multiple paths
#!/usr/bin/env emacs --script
(cond ((eq system-type 'darwin)
(dolist (fpath (split-string (shell-command-to-string "pbpaste") "\n" t))
(let* ((output (replace-regexp-in-string "\\(?:\\.\\w+\\)?$" ".jpg" fpath))
(cmd (format "sips -s format jpeg -s formatOptions 80 \'%s\' --out \'%s\'"
fpath output)))
(when (and (file-exists-p fpath)
(string-match-p "\\.png\\'" fpath))
(princ (format "=> cocnvert: %s\n" fpath))
@radixm46
radixm46 / tiktoken
Created June 21, 2023 23:20
print number of tokens from stdin
#!/usr/bin/env hy
(import sys)
(import tiktoken)
(require hyrule [defmain])
(defmain []
(print
(len (. (tiktoken.encoding_for_model "gpt-4")
(encode (sys.stdin.read))))))
@radixm46
radixm46 / fizzbuzz.el
Created May 15, 2023 03:29
fizzbuzz with emacs lisp
#!/usr/bin/env emacs --script
(defun fizzbuzz (num)
(princ (mapconcat
#'(lambda (i)
(cond
((= 0 (% i 3)
(% i 5)) "FizzBuzz")
((= 0 (% i 3)) "Fizz")
((= 0 (% i 5)) "Buzz")
@radixm46
radixm46 / fizzbuzz.hy
Created May 15, 2023 02:44
fizzbuzz with hylang
#!/usr/bin/env hy
(defn fizzbuzz_match_map [num]
(print (.join
"\n"
(map (fn [i]
(match #((% i 3) (% i 5))
#(0 0) "FizzBuzz"
#(0 _) "Fizz"
#(_ 0) "Buzz"
@radixm46
radixm46 / sipsmult.el
Last active May 12, 2023 05:23
Convert multiple jpg files in clipboard to png
#!/usr/bin/env emacs --script
(if (eq system-type 'darwin)
(dolist (fpath (split-string (shell-command-to-string "pbpaste") "\n" t))
(let* ((output (replace-regexp-in-string "\\(?:\\.\\w+\\)?$" ".jpg" fpath))
(cmd (format "sips -s format jpeg -s formatOptions 80 \'%s\' --out \'%s\'"
fpath output)))
(when (and (file-exists-p fpath)
(string-match-p "\\.png\\'" fpath))
(princ (format "=> cocnvert: %s\n" fpath))
@radixm46
radixm46 / automata-ver1.1a-eyecatch-msg.org
Last active July 19, 2024 16:19
Nier Automata ver1.1a アイキャッチ内のUTF8テキスト

Nier Automata ver1.1a utf-8 messages in eyecatch

Chapter.1 or not to [B]e

echo -e "
e38090e5a0b1e5918ae38091
0d0ae382a2e383b3e38389e383ade382a4e38389e381af
e7949fe381a8e6adbbe38292e7b9b0e3828ae8bf94e38199e5ad98e59ca8e381a7e38182e3828be38082
" `# end of the A part` "0d0a" "
e38090e5a0b1e5918ae380910
d0ae8bcaae5bbbbe381aee980a3e98e96e3818ce38282e3819fe38289e38199e381aee381afe38081e