Skip to content

Instantly share code, notes, and snippets.

@blacknon
blacknon / test_term_logger.go
Last active January 30, 2023 01:41
Goでターミナルログを記録するサンプルコード
package main
import (
"fmt"
"os"
"time"
"github.com/blacknon/gexpect"
)
@blacknon
blacknon / gist:f19d1e94b5f89f3e1fef520d3ecc7b59
Last active January 30, 2023 01:41
Add time stamp to terminal log of script command
script -fq >(awk '{print strftime("%F %T ") $0}{fflush()}'>> PATH) # Linux
script -Fq >(awk '{print strftime("%F %T ") $0}{fflush()}'>> PATH) # Mac
@blacknon
blacknon / get_ip_address_list.md
Last active January 30, 2023 01:39
Get IP address list from cidr perl oneliner
echo 192.168.100.9/28|perl -aF[./] -lne'for($i=0;$i<4;$i++){$x.=sprintf("%08b",$F[$i])}$y=$F[4];$k=substr($x,0,$y);$m=2**(32-$y);for($j=0;$j<$m;$j++){$a=$k.sprintf("%0".(32-$y)."b",$j);for($n=0;$n<4;$n++){$b.=".".sprintf(oct("0b".substr($a,$n*8,8)))};$b=~s/^\.//g;print $b;$b=""}'
# もうちょっと短くして改行したもの
echo 192.168.100.9/28|perl -aF[./] -E'
$x.=sprintf("%08b",$F[$_])for 0..3;
$y=$F[4];$z=32-$y;
$m=2**$z;
s@s:~$ unzip -l test1/test-1.zip
Archive:  test1/test-1.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
       35  2017-05-12 19:05   aaa.txt
        6  2017-05-12 18:55   bbb.txt
        6  2017-05-12 18:56   ccc.txt
---------                     -------
       47                     3 files