Skip to content

Instantly share code, notes, and snippets.

@radixm46
radixm46 / renameGitBranch.md
Created March 6, 2018 00:12 — forked from naosim/renameGitBranch.md
ローカルとリモートのブランチ名を変更する

#ローカルとリモートのブランチ名を変更する

以下、ブランチ名を hoge から foo に変更する例

  • ローカルのブランチ名変更
git branch -m hoge foo
  • リモートのブランチを消す
@radixm46
radixm46 / jmaforecst.py
Last active February 24, 2021 16:18
acquire weather forecst overview as json from jma.go.jp and print on shell
#!/usr/bin/env python3
import json
import textwrap
from urllib import request, error
LOCATION_CODE = 130000
JMA_URI = (
f"https://www.jma.go.jp/bosai/forecast/data/overview_forecast/{LOCATION_CODE}.json"
)
@radixm46
radixm46 / pandoc_conv2docx.sh
Last active August 7, 2021 06:21
convert .tex from emacs org mode to docx with crossref(yaml), bibliography(bib) and csl using pandoc
#!/bin/bash
# convert .tex exported from emacs to .docx
# works with below:
# - pandoc 2.9.2.1
# - pandoc-citeproc 0.17
# - pandoc-crossref v0.3.6.2
cd $(dirname $0)/src
exp_docx_path=../docx/$(date +%Y%m%d%H%M).docx
@radixm46
radixm46 / hos_babel.sh
Last active January 3, 2022 14:32
From a scene in Patlabor the Movie
#!/usr/bin/env bash
set -euo pipefail
(
trap 'tput cnorm;tput init; exit' SIGINT SIGTERM
# preparation
clear
tput civis
sleep 1.5
# vertical pos
v() {
@radixm46
radixm46 / parsers.conf
Created August 22, 2022 17:14
unbound log parsers for fluent-bit
# for log-time-ascii: no
[PARSER]
Name unbound
Format regex
Regex ^\[(?<time>[\d]*)\] (?<process>[\D]*)\[(?<pid>[\d]*):(?<tid>[\d]*)\] (?<message_type>[\D]*): (?<message>.*)
Time_Key time
# for log-time-ascii: yes
[PARSER]
Name unbound_utc
@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
@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 / 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 / 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 / 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))))))