Skip to content

Instantly share code, notes, and snippets.

View benwei's full-sized avatar

ben6 benwei

View GitHub Profile
@benwei
benwei / cwc_l.sh
Created July 16, 2013 10:43
one line to list line count of c file
#!/bin/sh
find -name "*.c" | while read fn ; do wc -l $fn ; done
@benwei
benwei / dump_ssl_heartbeat_enabled_header.sh
Created November 21, 2015 13:13
dump ssl_heartbeat enable
openssl s_client -connect $your_ssl_website -tlsextdebug 2>&1 | grep 'server extension'
@benwei
benwei / check_threads_status_in_a_process.txt
Last active November 28, 2017 03:41
How to check thread load within a process in embedded linux system?
How to check threads status within a process in embedded linux system?
Author: Ben Wei 2017-11-28
system linux kernel 3.10.73+
# ps aux | grep pulseaudio | grep -v grep
pulse 142 7.5 4.3 44312 4664 ? S<sl Nov24 406:35 /usr/bin/pulseaudio --daemonize=no
## use top command with -H, you can browse the thread load in the file
# top -H -p 142
@benwei
benwei / trim_sp_txtfiles.sh
Created April 13, 2018 14:12
trim space chars in txt filename in current directory
find *.txt | grep " " | while read fn ; do xfn=`echo $fn | tr -d ' '`; mv "$fn" "$xfn" ; done
@benwei
benwei / gen_md5sum_of_folder.sh
Created August 29, 2018 01:18
Generate single check sum of a directory's contents
#!/bin/sh
target="$1"
if [ -z "$target" ]; then
echo "syntax: <folder-name>"
exit 1
fi
find $target -type f -exec md5sum {} + | cut -d" " -f1 | sort | md5sum | cut -d" " -f1
exit $?
@benwei
benwei / output of jq
Created September 5, 2018 10:57
test json with jq command
# jq tool: https://github.com/stedolan/jq
$ echo '[{"a":"2"}]' | jq '.[]'
{
"a": "2"
}
$ echo '[{"a":"2"}]' | jq '.[] | .["a"]'
"2"
# view with online tool jqplay
## https://jqplay.org/s/OrtlyrkIyg
@benwei
benwei / display_line_of_files.sh
Last active September 11, 2018 03:49
[ben notes] Display total line number of each file
ls *.py | while read fn ; do line_num=`cat "$fn" | wc -l`; echo "\"$fn\",$line_num" ; done
@benwei
benwei / Result_test_jq_get_raw_data_of_json_data.txt
Created September 12, 2018 06:10
JSON get specific field of json data by jq command
$ echo '{"ip":"8.8.8.8","a":"11"}' | jq -r '. | {"ip"} | .[]'
8.8.8.8
@benwei
benwei / hello_for_redis.lua
Created September 17, 2018 09:43
using multipe keys and arguments with lua script via redis-cli
-- redis-cli --eval hello.lua Tester " devops" , Argument1 " argument2"
-- KEYS[1] == "Tester"
-- KEYS[2] == " devops"
-- ARGV[1] == "Argument1"
-- ARGV[2] == " argument2"
local msg = "Hello, world," .. KEYS[1] .. KEYS[2] .. "!" .. ARGV[1] .. ARGV[2]
return msg
@benwei
benwei / Makefile.orangeos-ch1-a
Last active January 27, 2019 09:16
For testing with orangeos's example chapter1-a
# 2019-01-25 Ben Wei <ben@juluos.org>
IMAGE=a.img
BINFILE=boot.bin
all: $(IMAGE) $(BINFILE)
$(BINFILE): boot.asm
nasm boot.asm -f bin -o $(BINFILE)
dd if=$(BINFILE) of=./$(IMAGE) bs=512 count=1
$(IMAGE):