Skip to content

Instantly share code, notes, and snippets.

@hogashi
hogashi / kyokankaku-colored-char.js
Created January 13, 2022 07:34
文字を共感覚に沿った色にする
color = {
0: 'black',
1: 'white',
2: 'yellow',
3: 'lightgreen',
4: 'pink',
5: 'blue',
6: 'red',
7: 'lightgreen',
8: 'black',
cat ~/.bash_history | \
tr -d '\r' | \
perl -pe '
chomp;
s/\\/\\\\/g;
s/"/\\"/g;
$_ = qq({\n "length": ) . length($_) . qq(,\n "command": ") . $_ . qq("\n}, );
' | \
perl -pe 's/, $//' | \
awk '
@hogashi
hogashi / 0_which-command-3-char.bash
Last active March 15, 2021 12:15
3文字以下のPATHの通ったコマンドを列挙してみる
#!/bin/bash
which $(
for i in {a..z}; do
echo $i
for j in {a..z}; do
echo $i$j
for k in {a..z}; do
echo $i$j$k
done
#!/bin/bash
COMMAND="$1"
BEFORE_STR="$2"
AFTER_STR="$3"
prt "$COMMAND" "$BEFORE_STR" "$AFTER_STR" $(git grep --name-only "$BEFORE_STR")
@hogashi
hogashi / random-mahjong.ts
Last active June 8, 2020 15:14
ランダム麻雀
const allHais = [
'一萬', '二萬', '三萬', '四萬', '五萬', '六萬', '七萬', '八萬', '九萬',
'一筒', '二筒', '三筒', '四筒', '五筒', '六筒', '七筒', '八筒', '九筒',
'一索', '二索', '三索', '四索', '五索', '六索', '七索', '八索', '九索',
'東 ', '南 ', '西 ', '北 ', '白 ', '発 ', '中 ',
] as const;
type HaiName = typeof allHais[number];
type HaiNameArray = HaiName[];
type HaiNameSetForShow = {
@hogashi
hogashi / github-diff-content-editable-each-line.js
Last active May 23, 2020 10:38
github diff content editable each line js
document.styleSheets[0].insertRule('.blob-code-marker:before { border-right: black 1px dotted; }');
linedata = {};
[
...Array.from(document.querySelectorAll('.blob-code-addition')),
...Array.from(document.querySelectorAll('.blob-code-context'))
].forEach(line => {
lineNumber = line.parentNode.querySelector('.blob-num').getAttribute('data-line-number');
marker = line.querySelector('.blob-code-marker');
@hogashi
hogashi / ghq-look-with-peco-shorthand.bash
Last active May 13, 2020 08:50
ghq look with peco shorthand in bash
## ghq look on ghq list
function glk() {
ARG_STR="$1"
PECO_RESULT=$(ghq list | peco --query "$ARG_STR")
PECO_RESULT=$(echo -n "${PECO_RESULT}" | tr -d '\n' | perl -pe 's/(^ | $)//g')
if [ ! -n "$PECO_RESULT" ]; then
return 1
fi
cat src/* \
| perl -pe 's/[^a-zA-Z]/ /g' \
| perl -pe 's/([a-z])([A-Z])/$1 $2/g' \
| perl -pe 's/([A-Z])([A-Z][a-z])/$1 $2/g' \
| perl -pe 's/ +/\n/g' \
| perl -pe '$_ = lc' \
| sort \
| uniq > words.txt
cat src/* \
| perl -pe 's/[^a-zA-Z]/ /g' \
@hogashi
hogashi / savein-foxy-tooi-like.js
Last active April 12, 2020 13:28
unsupported script: tooi-like foxy script for save-in https://github.com/hogashi/twitterOpenOriginalImage/issues/69
// this is unsupported
// added from https://github.com/hogashi/twitterOpenOriginalImage/blob/master/tooi-forGreaseTamperMonkey.user.js
var collectUrlParams = function (rawUrl) {
if (!/https:\/\/pbs\.twimg\.com\/media/.test(rawUrl)) {
return null;
}
var url = new URL(rawUrl);
var searchSet = {
format: 'jpg',
marp
true
<style> h1, h2 { font-family: "Noto Sans JP"; text-align: center; } h1 {