Skip to content

Instantly share code, notes, and snippets.

ben6 benwei

  • Taiwan
Block or report user

Report or block benwei

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@benwei
benwei / test_result_on_linux_01-abspath-mk
Last active Mar 21, 2019
test result of 01-abspath-mk.mk
View test_result_on_linux_01-abspath-mk
/build$ make -v
GNU Make 4.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
/build$ lsb_release -a
No LSB modules are available.
View 01-abspath-mk.mk
current_mk_abspathname := $(abspath $(lastword $(MAKEFILE_LIST)))
current_mk_absdir := $(dir $(current_mk_abspathname))
all:
@echo "Makefile absolute pathname: $(current_mk_abspathname)" ; \
echo "Makefile absolute path: $(current_mk_absdir)"
@benwei
benwei / yaml_test1.py
Last active Mar 14, 2019
test to load yaml syntax by pyyaml library
View yaml_test1.py
import yaml
document = """
a: 1
b:
c: 3
View tests.sh
#!/bin/bash
i=1
while [ ! "x$1" = "x" ]; do
echo "argv[$i]=[$1]"
shift
i=$((i + 1))
done
@benwei
benwei / test-cases.sh
Last active Mar 14, 2019
run remote cases by ssh with multiple arguments using shell - https://ben6.blogspot.com/2019/03/run-command-with-multiple-arguments.html
View test-cases.sh
#/bin/bash
# 2019 Ben Wei <ben@juluos.org>
#
# This is a example script for CI tests for blog
# if not defined in environment variable
# you can use the following command to defined it
#
# export TEST_SSH_HOST="your_ssh_host"
@benwei
benwei / bash_arguments_example.sh
Last active Feb 22, 2019
Use bash to implement like C's argc and argv
View bash_arguments_example.sh
#!/usr/bin/env bash
# Copyright (C) 2019 by Ben Wei <ben@juluos.org>
# Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
# OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
# CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
######
# sample code of blog
## tested with bash 4.3.48 x86_64-pc-linux-gnu ubuntu-16.04.4 LTS
@benwei
benwei / Makefile.orangeos-ch1-a
Last active Jan 27, 2019
For testing with orangeos's example chapter1-a
View Makefile.orangeos-ch1-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):
@benwei
benwei / hello_for_redis.lua
Created Sep 17, 2018
using multipe keys and arguments with lua script via redis-cli
View hello_for_redis.lua
-- 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 / Result_test_jq_get_raw_data_of_json_data.txt
Created Sep 12, 2018
JSON get specific field of json data by jq command
View Result_test_jq_get_raw_data_of_json_data.txt
$ echo '{"ip":"8.8.8.8","a":"11"}' | jq -r '. | {"ip"} | .[]'
8.8.8.8
@benwei
benwei / display_line_of_files.sh
Last active Sep 11, 2018
[ben notes] Display total line number of each file
View display_line_of_files.sh
ls *.py | while read fn ; do line_num=`cat "$fn" | wc -l`; echo "\"$fn\",$line_num" ; done
You can’t perform that action at this time.