Skip to content

Instantly share code, notes, and snippets.

View bash-history-length-json.bash
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 Mar 15, 2021
3文字以下のPATHの通ったコマンドを列挙してみる
View 0_which-command-3-char.bash
#!/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
View prt-git.bash
#!/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 Jun 8, 2020
ランダム麻雀
View random-mahjong.ts
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
github diff content editable each line js
View 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
ghq look with peco shorthand in bash
View ghq-look-with-peco-shorthand.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
View commands.bash
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' \
View savein-foxy-tooi-like.js
// 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',
View marp-template.md
marp
true
<style> h1, h2 { font-family: "Noto Sans JP"; text-align: center; } h1 {
View orca-19W11-048367.orca
.......................................................................
.......................................................................
........1..............................................................
.......................................................................
.......................................................................
.........B.............................................................
.........102GSE........................................................
.............SE.E.E.E.E.E.E;04C........................................
.......................................................................
...............;04F96..................................................