This file contains 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
## original: | |
## https://twitter.com/hid_tori/status/1221415626465349635 | |
## https://twitter.com/hid_tori/status/1221415683289780225 | |
## https://twitter.com/hid_tori/status/1221415737375412224 | |
## https://twitter.com/hid_tori/status/1221415770795728898 | |
cat sudoku | node -e 'console.log((f=>(u=>u(u))(x=>f(y=>x(x)(y))))(f=>a=>((a,b)=>a.map(x=>x[3]).includes("*")?f(a.map(x=>x[3]!=="*"?x:[...x.slice(0,4),[...Array(9)].map((v,i)=>String(i+1)).filter(y=>!b[0][x[0]].concat(b[1][x[1]]).concat(b[2][x[2]]).includes(y))]).map(x=>x.length===4?x:x[4].length===1?[x[0],x[1],x[2],x[4][0]]:x.slice(0,4))):a)(a,a.reduce((x,y)=>(x[0][y[0]].push(y[3]),x[1][y[1]].push(y[3]),x[2][y[2]].push(y[3]),x),[...Array(3)].map(x=>[...Array(9)].map(y=>[]))).map(x=>x.map(y=>y.filter(z=>z!=="*")))))(require("fs").readFileSync("/dev/stdin","utf8").trim().split("\n").map((v,i)=>[i,v]).map(x=>[x[0],[...x[1].split("").entries()]]).flatMap(x=>x[1].map(y=>[x[0],...y])).map(x=>[x[0],x[1],Math.floor(x[0]/3)%3*3+Math.floor(x[1]/3),x[2]])).reduce((x,y)=>(x[ |
This file contains 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 | |
# From: https://twitter.com/grethlen/status/906154326975905793 | |
sudo ping -i 0 -c 1400 pong4.kooshin.net \ | |
| grep -oP "icmp_seq=\K\d+" \ | |
| cat - <(seq 1 1400) \ | |
| sort -n \ | |
| uniq -c \ | |
| awk '{printf $1}' \ | |
| fold -w70 \ |
This file contains 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 | |
###文献リスト### | |
cat ../rpim_book.bbl | | |
grep '^\\bibitem' | | |
sed 's/bibitem/cite/' | | |
awk '{print "s/\\"$1"/["NR"]/g"}' > ./cite.sed | |
cat ../rpim_book.bbl | | |
sed 's/bibitem/cite/' | |
This file contains 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
# ruby | |
$ time bash -c 'ruby -e "print 12345**54321"' >/dev/null | |
bash -c 'ruby -e "print 12345**54321"' > /dev/null 0.57s user 0.37s system 91% cpu 1.027 total | |
# bc | |
$ time bash -c 'echo "12345^54321" | bc' >/dev/null | |
bash -c 'echo "12345^54321" | bc' > /dev/null 3.15s user 0.06s system 81% cpu 3.942 total | |
# python | |
$ time bash -c 'echo "print pow(12345,54321)" | python' >/dev/null |
This file contains 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
887c887 | |
< sp->dval = ((double) value) / RAND_MAX; | |
--- | |
> sp->dval = ((double) value) / (unsigned long)(MAWK_RAND_MAX); |
This file contains 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
seq 1 99999999999 | awk '{ | |
for(i=1;i<=11;i++){ | |
a=int($0/(10^(i-1))); | |
b=a-int(a/10)*10; | |
if(i<=6){ | |
sum+=b*(i+1) | |
} else { | |
sum+=b*(i-5) | |
} | |
}; |
This file contains 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
#!/usr/bin/env ruby | |
# encoding: ascii-8bit | |
# | |
# 端末の漢字コード設定判別のサンプルスクリプト | |
# | |
# コンセプトとしてはUTF-8, EUC-JP, Shift_JISのどれと解釈しても正しい、 | |
# しかしどのエンコーディングとして解釈したかで端末での表示幅が変わる | |
# バイト列を送信し、その時のカーソル位置で端末がどのエンコーディング | |
# として解釈したかを判別する。 | |
# |
This file contains 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
# @name get_termsize.rb | |
# @desc 端末のサイズ(列数,行数)を取得 | |
=begin | |
man | |
http://linuxjm.sourceforge.jp/html/LDP_man-pages/man4/tty_ioctl.4.html | |
/usr/include/sys/termios.h |
This file contains 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
#!/usr/local/bin/gosh | |
(use gauche.parseopt) | |
(use gauche.process) | |
(use srfi-1) | |
(use srfi-13) | |
(define (usage cmd) | |
(print "usage: " cmd " [option] ... input") | |
(print " options:") |
NewerOlder