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
redis-cli -n 0 --eval test.lua 0 '*' 10 |
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
redis.replicate_commands() | |
local cr = 0 | |
local b = {} | |
while true do | |
local a = redis.call("SCAN", cr, "MATCH", "????", "COUNT", 10) | |
for i, v in ipairs(a[2]) do | |
local j = cjson.encode({v, v, v}) | |
redis.call("SET", v, j) |
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 | |
function dump_redis_hash_to_json() { | |
# redis の hash をjsonに出力 | |
key=$1 | |
num=$2 | |
output=$3 | |
cr=0 | |
while true; do |
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 | |
while read x; do | |
fold -s1 <<<"$x" | while read y; do | |
[ ! -z $y ] && printf "\x1b[%dm \x1b[0m" $((y+40)) || printf " " | |
done | |
echo | |
done <<EOD | |
00 | |
00330 |
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
$ cat <<EOD | jq -c '.[]' | |
> [ [ 11, 12, 13 ], [ 21, 22, 23 ], [ 31, 32, 33 ] ] | |
> EOD | |
[11,12,13] | |
[21,22,23] | |
[31,32,33] | |
$ | |
$ cat <<EOD | jq -c '.[]' | jq -s 'reduce .[] as $i ([]; .+[$i])' | |
> [ [ 11, 12, 13 ], [ 21, 22, 23 ], [ 31, 32, 33 ] ] | |
> EOD |
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 a.tsv | nkf -Lu | \ | |
while IFS=$'\n' read x; do | |
echo "$x" | tr "\t" "\n" | while read y; do | |
# unquote | |
echo "$(eval echo $y)" | |
done | jo -a | |
done |
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 | |
a=(1 2 3 4 5) | |
b=(a b c d e) | |
paste -d ',' <(printf "%s\n" "${a[@]}") <(printf "%s\n" "${b[@]}") |
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 | |
rm -rf f1 f2 | |
mkfifo f1 | |
mkfifo f2 | |
cat $0 | tee >(tac | cat -n > f1) >(cat -n > f2) >/dev/null | |
paste f1 f2 -d $'\n' |
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
[ | |
{ | |
"id": "1-key", | |
"attr": "1-value" | |
}, | |
{ | |
"id": "2-key", | |
"attr": "2-value" | |
}, | |
{ |
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 | |
function data() { | |
printf "%s\n" $(echo {1..10}{a..c}) | while read x; do | |
NUM=${x:0: -1} | |
CATE=${x: -1} | |
printf "%s\t%s\t%s\n" $NUM $CATE value_$NUM$CATE | |
done | |
} |