<file_sep>#!/usr/bin/python

import re, os, sys, glob, fnmatch


#doubleHome = os.path.dirname(os.path.dirname(os.path.dirname(os.environ["ROOTFS"])))

matches = []
for root, dirnames, filenames in os.walk('.'):
    for filename in fnmatch.filter(filenames, '*.pri'):
        fullName = os.path.join(root, filename)
        found = False
        with open(fullName) as fl:
            if 'nano_441' in fl.read():
                matches.append(fullName)
                print fullName
            else:
                print '   skip ', fullName

for filename in matches:
    bkName = filename+'.bak'
    os.system('mv '+filename+' '+bkName)
    with open(bkName) as inF:
        with open(filename, 'w') as outF:
            lines = inF.readlines()
            for line in lines:
                line = line.replace("/home/manu/cross/nano_441", "$ROOTFS")
                outF.write(line)

<file_sep># delete config.cache
# sudo apt install '.*libxcb.*' libxrender-dev libxi-dev libfontconfig1-dev libudev-dev libxkbcommon-dev
# apt download libgles2-mesa-dev libegl1-mesa-dev
# mkdir GLES EGL
# cd GLES; ar x ../libgles2*.deb; tar xf data.tar.xz
# cd EGL; ar x ../libegl1*.deb; tar xf data.tar.xz
# need to copy KHR as well
# copy to /usr/include
# sudo usermod -a -G input manu //reboot takes effect logout?
# then
# add .bashrc
# *** modify qtbase/mkspecs/devices/linux-jetson-tx1-g++/qmake.conf
# QMAKE_INCDIR_POST /usr/include becomes to /usr/include/drm since pkg-config disabled automatically and need drm for egldevice
# change to eglfs_kms_egldevice
# see ../qmake.conf
# ***
#QT_PATH=/usr/local/qt5
#export PATH=${QT_PATH}/bin:$PATH
#export LD_LIBRARY_PATH=${QT_PATH}/lib:${LD_LIBRARY_PATH}


#nano works
./configure -shared -c++std c++14 -opensource -release -recheck-all --confirm-license -device linux-jetson-tx1-g++ -device-option CROSS_COMPILE=aarch64-linux-gnu- -prefix /usr/local/qt5 -extprefix /usr/local/qt5 -hostprefix /usr/local/qt5 -skip webview -skip qtwebengine -opengl es2

#nano fail
./configure -shared -c++std c++14 -opensource -release -recheck-all --confirm-license -device linux-jetson-tx1-g++ -device-option CROSS_COMPILE=aarch64-linux-gnu- -nomake examples -nomake tests -prefix /usr/lib/qt5.14.1 -skip webview -skip qtwebengine -opengl es2

#x86
./configure -shared -c++std c++14 -opensource -release -recheck-all --confirm-license -device linux-jetson-tx1-g++ -device-option CROSS_COMPILE=/home/manu/bin/gcc-linaro-6.5.0-2018.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- -sysroot /home/manu/jetson -nomake examples -nomake tests -prefix /usr/local/qt5 -extprefix /home/manu/Downloads/qt-everywhere-src-5.14.1/NanoR32.3.1/qt5 -hostprefix /home/manu/Downloads/qt-everywhere-src-5.14.1/NanoR32.3.1/qt5-host -skip webview -skip qtwebengine -opengl es2

#not this
./configure -shared -c++std c++14 \
 -opensource -release --confirm-license -no-pkg-config \
 -device linux-jetson-tx1-g++ \
 -device-option CROSS_COMPILE=/home/manu/bin/gcc-linaro-6.5.0-2018.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- \
 -sysroot /home/manu/jetson \
 -nomake examples -nomake tests \
 -prefix /usr/local/qt5 \
 -extprefix /home/manu/Downloads/qt-everywhere-src-5.14.1/NanoR32.3.1/qt5 \
 -hostprefix /home/manu/Downloads/qt-everywhere-src-5.14.1/NanoR32.3.1/qt5-host \
 -skip webview -skip qtwebengine -opengl es2

./configure -shared -c++std c++14 \
 -opensource -release --confirm-license -no-pkg-config \
 -device linux-jetson-tx1-g++ \
 -device-option CROSS_COMPILE=/home/manu/bin/gcc-linaro-6.5.0-2018.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- \
 -sysroot /home/manu/Downloads/nano-rootfs \
 -nomake examples -nomake tests \
 -prefix /usr/local/qt5 \
 -extprefix /home/manu/Downloads/qt-everywhere-src-5.14.1/JetsonNano/qt5 \
 -hostprefix /home/manu/Downloads/qt-everywhere-src-5.14.1/JetsonNano/qt5-host \
 -skip webview -skip qtwebengine -opengl es2

./configure -shared -c++std c++14 \
 -opensource -release --confirm-license -no-pkg-config \
 -device linux-jetson-tx1-g++ \
 -device-option CROSS_COMPILE=/home/manu/bin/gcc-linaro-5.5.0-2017.10-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- \
 -sysroot /home/manu/Downloads/nano-rootfs \
 -nomake examples -nomake tests \
 -prefix /usr/local/qt5 \
 -extprefix /home/manu/Downloads/qt-everywhere-src-5.14.1/JetsonNano/qt5 \
 -hostprefix /home/manu/Downloads/qt-everywhere-src-5.14.1/JetsonNano/qt5-host \
 -skip webview -skip qtwebengine -opengl es2


<file_sep>$myID = 'TREE'
$myPW = '<PASSWORD>'
$myLink = "dinbendon.net"

require 'watir-webdriver'

#give options default value
$options = {'debug' => 0}


#
# output message if message level is no less than current setting
#
def dbg(msg, msgLevel = 1)
	if $options['debug'] >= msgLevel then
		puts "#{msg}"
	end
end


def fire(link)
	bw = Watir::Browser.new :chrome
	bw.goto link
	
	bw.body.div(:id => 'main').table.table(:class => 'lists').tbody.wait_until_present
	tbody1 = bw.body.div(:id => 'main').table.table(:class => 'lists').tbody
	if NIL == tbody1 then
		puts "No tbody found"
		return
	end
	tbody1.text_field(:name => 'username').set $myID
	tbody1.text_field(:name => 'password').set $myPW
	#puts "#{tbody1.trs[2].inspect}, #{tbody1.trs[2].text}"
	#puts "#{tbody1.trs[2].text}".match('\d+')
	add1 = "#{tbody1.trs[2].text}".match(/(\d+)([^\d]*)(\d+)/)[1]
	add2 = "#{tbody1.trs[2].text}".match(/(\d+)([^\d]*)(\d+)/)[3]
	rlt = add1.to_i + add2.to_i
	dbg "#{add1} + #{add2} = #{rlt}"
	input = tbody1.text_field(:name => 'result')
	input.hover
	input.set rlt
	dbg "#{tbody1.trs[4].inspect}"
	dbg "#{tbody1.trs[4].td.inspect}"
	dbg "#{tbody1.trs[4].tds[1].input.inspect}"
	#this fails tbody1.trs[4].text_field(:name => 'submit').click
	tbody1.trs[4].tds[1].input.click
end


###
# main

fire $myLink
<file_sep>#!/bin/bash

my_array=(abc def ghi)

for ((i=0; i<${#my_array[@]}; i++ )); do echo ${my_array[$i]}; done
echo ${my_array[*]}

for ((i=0; i<${#my_array[@]}; i++ )); do echo ${my_array[i]}; done
<file_sep>#!/bin/bash
# run after
# docker exec -it mj /bin/bash

tasks=(
	"check_space"
	"clean_yyyymm"
	"copy_to_release"
	"edge_be"
	"edge_branch"
	"edge_fe"
	"edge_pipe"
	"edge_v20"
	"q8_buildroot"
	"q8_branch"
	"q8_client"
	"q8_pipe"
	"q8_server"
	"q8_webui"
	"q8_v02"
	"release_to_version"
)

#replaced by edge_pipe "edge_sys"
#replaced by edge_pipe "edge_system"

#edge_sys and edge_system deprecate

for ((i=0; i<${#tasks[@]}; i++)); do
	echo Getting task ${tasks[i]}
	java -jar jenkins-cli.jar -auth manu:manu -s http://localhost:8080 get-job ${tasks[i]} > ${tasks[i]}.xml
done
<file_sep>#!/bin/bash

OK=0
CANCEL=1
ESC=255
BACKTITLE="Cody Blog - Example"

Menu(){
    while :
    do {
        Selection=$(dialog --title "CodyBlog - Menu" --clear \
            --backtitle "$BACKTITLE" \
            --cancel-label "Exit" \
            --menu "Choose one" 12 45 5 \
            1 "Test 01" \
            2 "Test 02" \
            2>&1 > /dev/tty)

        result=$?
        if [ $result -eq $OK ]; then
            Select $Selection
        elif [ $result -eq $CANCEL ] || [ $result -eq $ESC ]; then
            Exit
        fi
    } done
}

Select(){
    Choice=$1

    case $Choice in
        1)  # Option 1
            Option1
            ;;
        2)  # Option 2
            Option2
            ;;
    esac
}

Option1(){
    while :
    do {
        exec 3>&1
        Input=$(dialog --title "$Title" --clear \
            --backtitle "$BACKTITLE" \
            --form "Please input:" 10 70 5  \
            "Input1:" 1  2 "" 1  14  48  0 \
            "Input2:" 2  2 "" 2  14  48  0 \
            2>&1 1>&3)
        result=$?
        exec 3>&-

        IFS=$'\n'
        Values=($Input)
        unset IFS

        if [ $result -eq $CANCEL ] || [ $result -eq $ESC ]; then
            break
        elif [ $result -eq $OK ]; then
            MsgBox "${Values[0]}" "${Values[1]}"
            if [ $result -eq $OK ]; then
                break
            fi
        fi
    } done
}

Option2(){
    while :
    do {
        Number=$(dialog --title 'Option 2' --clear \
        --backtitle "$BACKTITLE" \
        --radiolist 'Select Item:' 15 70 2 \
        1 Radiolist1 off \
        2 Radiolist2 on \
        2>&1 > /dev/tty)
        result=$?
        
        if [ $result -eq $CANCEL ] || [ $result -eq $ESC ]; then
            break
        elif [ $result -eq $OK ]; then
            MsgBox "$Number"
            break
        fi
    } done
}

MsgBox(){
    Input1=$1
    Input2=$2

    Msg="$Input1\n"
    Msg="${Msg}$Input2"

    dialog --title "MsgBox" --clear \
    --backtitle "$BACKTITLE" \
    --yesno "$Msg" 10 70

    result=$?
}

Exit(){
    clear
    echo "Program Terminated."
    exit
}

Menu
<file_sep># Download base image manu-jenkins:0000
# docker build -t manu-jenkins:0100 .
# RUN:
#  docker run -d --name mj --user root -p 8080:8080 -p 50000:50000 -v /var/run/docker.sock:/var/run/docker.sock -v <host_jenkins_home>:/var/jenkins_home manu-jenkins:0100
# Check password: in /var/jenkins_home/secrets/initialAdminPassword
#  docker exec -it mj /bin/bash
# NOTE:
#  jenkins shell use sh (dash), at top of script use "#!/bin/bash" without any blank to make .bashrc working
# 00 is major 00 is minor
# 01 is major 00 is minor
# must have USER root to avoid apt-key or something fail
#
# Suggested modules:
# 1. Copy Artifact
# 2. Pipeline Utility Steps
FROM manu-jenkins:0000
LABEL maintainer="<EMAIL>"
LABEL version="01.00"
LABEL description="jenkins for Q8Vista"
USER root
ENV VER=1.14.15
ENV APP="make autoconf automake autopoint bison flex gperf libtool libtool-bin libtool lzip p7zip-full intltool-debian intltool libgtk2.0-dev python ruby npm wget cpio rsync bc gcc-mingw-w64 g++-mingw-w64 libssl-dev libelf-dev gtk-doc-tools"
RUN apt-get update && apt-get -y install $APP
RUN wget -c https://dl.google.com/go/go${VER}.linux-amd64.tar.gz -O - | tar -xz -C /usr/local && echo "export GOROOT=/usr/local/go" >>~/.bashrc && echo "export PATH=\${PATH}:\${GOROOT}/bin" >>~/.bashrc
<file_sep>#!/bin/sh

#
# In	: $1- message
#
function usage()
{
	test ! -z "$1" && echo "Error: $1"
	echo "    Usage: $0 FILE"
	echo "    To remove comments in FILE"
	exit 0
}

#
# main
#

# check parameter count & file existence
#
test $# != 1 &&	usage "Incorrect number of parameter !!!"
test ! -f $1 && usage "$1 doesn't exist !!!"

# remove line comment
#
cat $1 | sed 's/\/\/.*$//g' >$1.line

# remove block comment in a line
#
cat $1.line | sed 's/\/\*.*\*\///g' >$1.block1

# remove block comment in multiple lines
#
cat $1.block1 | sed 's/\/\*\(.*^\)\+.*\*\///g' >$1.block2
<file_sep>#!/bin/bash

#if parameter is not set, use default
parameter-default() {
	local var1=1
	local var2=2

	echo "var1=$var1, var2=$var2"
	echo "  var1 defined, \${var1-\$var2} outputs \$var1 (${var1-$var2})"
	echo "  var3 not defined, \${var3-\$var2} outputs \$var2 (${var3-$var2})"
	echo

	var1=
	echo "var1="
	echo "  var1 defined, \${var1-\$var2} outputs \$var1 (${var1-$var2})"
	echo "  var1 declared but set as null, \${var1:-\$var2} outputs \$var2 (${var1:-$var2})"
	echo
}


#if parameter is not set, set it to default
parameter-set-default() {
	echo "varA is not declared"
	echo "  \${varA=abc} sets var as (${varA=abc})"
	echo "${varA:=xyz}" >/dev/null
	echo "  this time \${varA=xyz} leaves varA remain (${varA})"
	echo

	local varB=
	echo "  varB declared but is set as null, \${varB=abc} leaves varB as (${varB=abc})"
	echo "  varB declared but is set as null, \${varB:=abc} sets varB as (${varB:=abc})"
	echo

}



parameter-default
parameter-set-default

aa='echo $MODEL'
MODEL=4
echo `eval ${aa}`
<file_sep># use ${ROOTFS} of jetson sample_rootfs (copy from nano success)
# delete config.cache
# qtbase/mkspecs/devices/linux-jetson-tx1-g++/qmake.conf
#    modify eglfs_x11 as eglfs_kms_egldevice
# set ROOTFS
# set PATH to gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu (jetson developer)

#test this
./configure -shared -c++std c++14 -opensource -release -recheck-all --confirm-license\
 -device linux-jetson-tx1-g++ -device-option CROSS_COMPILE=aarch64-linux-gnu-\
 -sysroot ${ROOTFS} -nomake tests -prefix /usr/local/qt5 -extprefix /usr/local/qt5 -hostprefix /usr/local/qt5 -skip webview -skip qtwebengine -opengl es2




<file_sep>#!/bin/bash

PS3="Choose: "
select i in a336 c039 quit
 do 
 [ "$i" = "quit" ]  && exit 0
 echo "You chose $i"
 break  #otherwise user has to choose again and again
done
===================================

the list of select can be omit and it will default to "$@", i.e., the list of quoted command-line arguments.

===================================
print 'Select your terminal type:'
PS3='terminal? '
select term in \
    'Givalt VT100' \
    'Tsoris VT220' \
    'Shande VT320' \
    'Vey VT520'
do
    case $REPLY in
        1 ) TERM=gl35a ;;
        2 ) TERM=t2000 ;;
        3 ) TERM=s531 ;;
        4 ) TERM=vt99 ;;
        * ) print 'invalid.' ;;
    esac
    if [[ -n $term ]]; then
        print TERM is $TERM
        break
    fi
done
<file_sep>#!/bin/bash

D4_MAX_PACKET=3045
D4_P_NAME="VP2730 UVC Device"
VID=1367
PID=10244
VENDOR_NAME="ATEN International Co.,Ltd"
CMD_PREFIX=

P_NAME=
MAX_PACKET=

#
# Usage:
#   gouvc [-p PRODUCT_NAME] [-x MAX_PACKET]  
#
#
usage() {
	echo "Usage: $0 [-p PRODUCT_NAME] [-x MAX_PACKET]"
	echo "    PRODUCT_NAME: product name, default to ${D4_P_NAME}"
	echo "    MAX_PACKET: max packet, yuv defaults to ${D4_MAX_PACKET}"
}


#
# Update g_xxx variable
#
parse_param() {

	while getopts ":p:x:" opt; do
		case $opt in
		p) P_NAME=$OPTARG;;
		x) MAX_PACKET=$OPTARG;;
                \?) usage
                    exit;;
                esac
	done
	OPTIND=1

	test -z "${P_NAME}" && P_NAME=${D4_P_NAME}
	test -z ${MAX_PACKET} && MAX_PACKET=${D4_MAX_PACKET}
	test 0 -eq `id|grep root|wc -l` && CMD_PREFIX="sudo "
	#echo "command=$CMD_PREFIX, $P_NAME, $MAX_PACKET"
}


#
# Remove driver
#
rmdriver() {
	${CMD_PREFIX}rmmod g_webcam >/dev/null 2>&1
	s{CMD_PREFIX}rmmod usb_f_uvc >/dev/null 2>&1
}


#
# Remove driver
#
lddriver(){
	${CMD_PREFIX}modprobe g_webcam idVendor=${VID} idProduct=${PID}\
		iSerialNumber="28032" iManufacturer=\"${VENDOR_NAME}\"\
		iProduct=\"${P_NAME}\" streaming_maxpacket=${MAX_PACKET}
}


########
# main
########
parse_param "$@"
rmdriver
lddriver
sleep 1
./uvc-gadget -d -u/dev/video0

<file_sep>#!/bin/sh

#
# To remove modified cvs files (local)
#
# Note: make sure modified source are committed separately
#

#cvs -n update | grep "^M" | awk '{print $2}' | xargs rm
cvs -n update | grep "^?" | awk '{print $2}'
<file_sep>#usage: ini.rb INI_FILE

#give options default value
$options = {'ini_dbg' => 0, 'print' => false}

#
# output message if message level is no less than current setting
#
def iniDbg(msg, msgLevel = 1)
	if $options['ini_dbg'] >= msgLevel then
		puts "#{msg}"
	end
end


# Get array with given INI file
# In  : filaName
# Ret : hash, name after session, of hash
def iniGet(fileName)
	hashOfHash = {}                                    #SESSION => hashOfSession
	curHash = {}                                       #KEY => value
	curSess = 'Null'

	File.foreach(fileName) do |line|
		line = line.chomp.strip                    #remove leading and trailing spaces and newline
		next if line =~ /^;/                       #skip comment line
		next if line.length == 0                   #skip empty line
		if line =~ /^\[(.+)\]/ then                #session found
			tmpHash = curHash.clone            #copy hash to insert in hash since curHash will be modified
			if !curHash.empty? then
				cmd = "hashOfHash[\'" + "#{curSess}'\] = tmpHash"
				iniDbg("#{cmd}", 2)
				eval(cmd)
			elsif curSess != 'Null' then
				cmd = "hashOfHash[\'" + "#{curSess}'\] = tmpHash"
				iniDbg("#{cmd}", 2)
				eval(cmd)
			end

			curHash.clear
			iniDbg("found session #{curSess}")
			next if curSess = $1               #this must be a true assignment
		end
		token = line.split('=', 2)                 #cut to two pieces at most
		iniDbg("  \(key, value\) = \(#{token[0]}, #{token[1]}\)")
		cmd = "curHash\['" + "#{token[0]}'\] = " + "'#{token[1]}'"
		iniDbg("#{cmd}", 2)
		eval(cmd)
	end
	#the last session
	cmd = "hashOfHash[\'" + "#{curSess}'\] = curHash"
	iniDbg("#{cmd}", 2)
	eval(cmd)
	
	return hashOfHash
end


###
# main
if $0 == 'ini.rb' then
	require 'optparse'
	OptionParser.new do |opts|
		opts.banner = "Usage: ruby ini.rb [-f INI_FILE] [-d LEVEL] [-p]
		LEVEL defaults to 0, which means debug off
		INI_FILE ini file for parsing
		-p to print session and content, defaults to off"
	
		opts.on('-d', '--debug level', 'debug level') { |level|
			$options['ini_dbg'] = level.to_i
		}
		opts.on('-f', '--file INI_file', 'INI file for parsing') { |file|
			$options['file'] = file
		}
		opts.on('-p', '--print', 'print sessions and content') {
			$options['print'] = true
		}
		opts.on('-h', '--help', 'Display usage') {
			puts "#{opts.banner}"
			exit
		}
	end.parse(ARGV)
	
	if !$options.has_key?('file') then
		puts "No INI file provided"
		exit
	else
		iniDbg("Processing #{$options['file']} ...")
	end

	hh = iniGet($options['file'])
	if $options['print'] then
		hh.each_pair do |session, hash|
			puts "----- session \"#{session}\" -----"
			hash.each_pair do |key, value|
				puts "    #{key} = #{value}"
			end
		end
	end
end
<file_sep>#!/bin/bash
# dump given size from memory to current dir
# $1 dump size, must >= 4096, and round down to 4K
#    can be number of xxxK, xxxM, xxxG
#
# dump2file FILE or
#	if FILE present, it must contain "USB=[PATH]/[FNAME]"
#	or "HD=[PATH]/[FNAME]" or "NFS=[PATH]/[FNAME]"
#
# dump2file SIZE or
# dump2file SIZE INPUT_FILE or
# dump2file SIZE INPUT_FILE OUTPUT_FILE
# 
# INUPT_FILE defaults to /dev/zero
# OUTPUT_FILE defaults to dmp2file_SIZE


file_path=`dirname $0`
. $file_path/func

#
#parameter check
#

test -z $1 && echo Error paramter && exit
test -f $1 && doFile $1 && exit

#get size
fsize=`expr 1024 \* 1024 \* 1024`
usrSize=$1
case $usrSize in
*G|*g)
	usrSize=`echo $usrSize |sed -e s/[Gg]//`
	fsize=`expr $usrSize \* $SIZE_1G`
	;;
*M|*m)
	usrSize=`echo $usrSize |sed -e s/[Mm]//`
	fsize=`expr $usrSize \* $SIZE_1M`
	;;
*K|*k)
	usrSize=`echo $usrSize |sed -e s/[Kk]//`
	fsize=`expr $usrSize \* $SIZE_1K`
	;;
*)
	fsize=$usrSize
	;;
esac


#get file name
inFile=/dev/zero
test ! -z $2 && inFile=$2
outFile=$3

checkSize $fsize

test -z $outFile && outFile=dmp2file_$DISPLAY_SIZE
test ! -c $outFile && rm -f $outFile

echo "Dump from $inFile to $outFile, size=$DUMP_SIZE"
doDump $inFile $outFile $BLOCK_SIZE $COUNT

<file_sep>#!/bin/sh
# check usage
TGTDIR=
#relative to kernel tree
SUBDIR=
GIT_SRC=
TGTTAG=master

IS_HTTP=

#
# Usage:
#   dirdiff -s SRC_DIR [-t TGT_DIR] [-c]  
#
# show difference of file name between SRC_DIR and TGT_DIR
# those missing in TGT_DIR can be copied from SRC_DIR if -c specified
#
usage() {
	echo "Usage: $0 -s GIT_SRC [-d DIR_NAME] [-p RELATIVE_PATH] [-t TAG]"
	echo "  ex. $0 -s https://github.com/manuTW/linux -p drivers/media -t v3.12"
	echo "    -s : use file, git://, or https:// protocal to get GIT_SRC"
	echo "    -d : checkout directory name"
	echo "    -p : relative path without \"/\" from GIT_SRC to checkout, default as all GIT_SRC"
	echo "    -t : default to master if not provided"
	exit
}



#parse and do checkout

parse_param() {
	while getopts ":s:p:t:d" opt; do
		case $opt in
		s) GIT_SRC=$OPTARG;;
		d) TGTDIR=$OPTARG;;
		p) SUBDIR=$OPTARG;;
		t) TGTTAG=$OPTARG;;
		\?) usage;;
		esac
	done

	OPTIND=1
	test -z "${GIT_SRC}" && echo Missing GIT_SRC && usage
	#remove tailing ".git" if any
	test -z "${TGTDIR}" && TGTDIR=`basename ${GIT_SRC} | sed s/\.git$//`
	IS_HTTP=`echo ${GIT_SRC}|grep -i http`
	TGTDIR=${TGTDIR}-`date +"%m%d_%H%M%S"`
	if [ -z "${SUBDIR}" ]; then
		echo Checkout ${GIT_SRC} to ${TGTDIR}, tag=${TGTTAG}
	else
		echo Checkout ${SUBDIR} of ${GIT_SRC} to ${TGTDIR}, tag=${TGTTAG}
	fi
}


parse_param $@

mkdir -p ${TGTDIR}; cd ${TGTDIR}
git init
git remote add -f origin ${GIT_SRC}
git fetch origin
git config core.sparseCheckout true
test -n "${SUBDIR}" && echo "${SUBDIR}" > .git/info/sparse-checkout
if [ ${TGTTAG} = "master" ]; then
	git checkout master
else
	git checkout -b br_${TGTTAG} ${TGTTAG}
fi


<file_sep>#!/bin/bash
# Usage: new_install manuchen

IP_KVM=172.16.58.3
IP_NAS=192.168.127.12
IP_PC=192.168.127.12
IP_SERVER=172.16.31.10
PATH_GITHUB=~/work/gh
PATH_NAS=~/nas
PATH_SHELL=${PATH_GITHUB}/shell
URL_GIT_SHELL="https://github.com/twManu/shell.git"

APPLIST="gitk vim cifs-utils minicom v4l-utils terminator fcitx-libs-dev fcitx-table fcitx-tools gcin gcin-tables"
#
# in   : S1 - user name to set permision with
#
get_param()
{
        if [ -z "$1" ]; then
                G_USER=`whoami`
        else
                G_USER=$1
        fi
        X64_CPU=`uname -m`
        MY_UID=`id $G_USER | cut -d"=" -f2 | cut -d"(" -f1`
        test -z "$MY_UID" && exit
        echo G_USER = $G_USER, X64_CPU = $X64_CPU, MY_UID = $MY_UID
}


#
# get answer among (y/n/s)
# in	: $1 - string to highligh for user
# out	: g_ANS = 'n' or 's' or default = 'y'
#
get_answer()
{
	MESSAGE=$1
	echo -en "\\033[0;33m"
	echo -en "$MESSAGE (Yes/No/Skip): "
	echo -en "\\033[0;39m"

	read ans

	if [ $ans == 'N' -o $ans == 'n' ]; then
		g_ANS='n'
	elif [ $ans == 'S' -o $ans == 's' ]; then
		g_ANS='s'
	else
		g_ANS='y'
	fi
}


#
# setting .bashrc
#
do_bashrc()
{
	result=`grep smbnas ~/.bashrc`
	if [ -n "${result}" ]; then
		get_answer "The bashrc might be updated, continue to process ?"
		if [ $g_ANS == 'n' ]; then
			exit 0
		elif [ $g_ANS == 's' ]; then
			return
		fi
	fi
	mkdir -p ${PATH_NAS} ${PATH_GITHUB}
	echo "alias smbnas='sudo mount.cifs //${IP_NAS}/share/git ~/nas -o uid=\$(id -u),gid=\$(id -g),username=manu,vers=1.0'" >>~/.bashrc
	echo "export PATH=${PATH_SHELL}:\${PATH}" >>~/.bashrc
	test ! -d ${PATH_SHELL} && cd ${PATH_GITHUB}; git clone ${URL_GIT_SHELL}
}



#
# install applications
#
do_app_install()
{
	APPLIST="gitk vim cifs-utils minicom v4l-utils terminator virtualenv virtualenvwrapper python3.8 python3.8-dev python3.8-venv apt-utils libhdf5-dev libffi-dev libxml2-dev libxslt1-dev"
	#for dayi-ibus
	APPLIST="${APPLIST} uuid-runtime"
	test $X64_CPU = "x86_64" && APPLIST="$APPLIST ia32-libs lib32ncurses5-dev lib32z1-dev lib32readline-gplv2-dev"

	get_answer "Proceed to install $APPLIST ?"
	if [ $g_ANS == 'n' ]; then
		exit 0
	elif [ $g_ANS == 's' ]; then
		return
	fi

	sudo apt update
	sudo apt install -y $APPLIST

	sudo snap install barrier
}



#
# configure samba
# in	: $1 - username
#
do_smb()
{
	SYSSMBCFG=/etc/samba/smb.conf
	SMBCFG=./tmp.conf

	if grep $G_USER $SYSSMBCFG; then
		get_answer "The $G_USER is present in smb.conf, continue to process ?"
		if [ $g_ANS == 'n' ]; then
			exit 0
		elif [ $g_ANS == 's' ]; then
			return
		fi
	fi

	if [ -f $SYSSMBCFG ]; then
		cp $SYSSMBCFG $SMBCFG
		echo "" >> $SMBCFG
		echo "[$G_USER]" >> $SMBCFG
		echo "	path = /home/$G_USER/" >> $SMBCFG
		echo "	browseable = yes" >> $SMBCFG
		echo "	read only = no" >> $SMBCFG
		echo "	guest ok = no" >> $SMBCFG
		echo "	create mask = 0664" >> $SMBCFG
		echo "	directory mask = 0755" >> $SMBCFG
		echo "	force user = $G_USER" >> $SMBCFG
		echo "	force group = $G_USER" >> $SMBCFG
		sudo mv $SMBCFG $SYSSMBCFG
	fi

	if [ ! -z `which smbpasswd` ]; then
		sudo smbpasswd -L -a $G_USER 
		sudo smbpasswd -L -e $G_USER
	fi
}

#NOTE:
#1.the mount.cifs uid=<uid#>, the user name becames unavailable after 11.10
#2.the ia32-libs fails x86 installation

get_param $1
do_app_install
do_bashrc
<file_sep>function basher() {
	if [[ $1 = 'run' ]]
	then
		shift
		/usr/bin/docker run -e \
		HIST_FILE=/root/.bash_history \
		-v $HOME/.bash_history:/root/.bash_history \
		"$@"
	else
		/usr/bin/docker "$@"
	fi
}
alias docker=basher<file_sep>#!/bin/bash

g_SRC_DIR=
g_TGT_DIR=.
g_ACT_COPY=0


#
# Usage:
#   dirdiff -s SRC_DIR [-t TGT_DIR] [-c]  
#
# show difference of file name between SRC_DIR and TGT_DIR
# those missing in TGT_DIR can be copied from SRC_DIR if -c specified
#
usage() {
	echo "USage: dirdiff -s SRC_DIR [-t TGT_DIR] [-c]"
	echo "    SRC_DIR: source directory"
	echo "    TGT_DIR: target directory, default as current directory"
	echo "    -c:      copy those TGT_DIR missing"
}


#
# Update g_xxx variable
#
parse_param() {
	while getopts ":s:t:c" opt; do
		case $opt in
		s) g_SRC_DIR=$OPTARG;;
		t) g_TGT_DIR=$OPTARG;;
		c) g_ACT_COPY=1;;
		\?) usage
		    exit;; 
		esac
	done
	OPTIND=1
}


#
# Check if g_xxx variable valid
# ask for confirmation if to alter something
#
check_param() {
	test -z ${g_TGT_DIR} && $g_TGT_DIR=$CWD
	test ! -d $g_SRC_DIR && echo "Error: '$g_SRC_DIR' is not a valid source directory" && exit
	#echo source dir=$g_SRC_DIR, target dir=$g_TGT_DIR, do copy=$g_ACT_COPY
	if [ 0 != $g_ACT_COPY ]; then
		echo -n "    copy missing files of $g_TGT_DIR from $g_SRC_DIR? (y/n) "
		read ans
		case $ans in
		y*|Y*) ;;
		*) echo "    ...stop processing !!!"
		   exit;;
		esac
	else
		echo "    show different file in $g_SRC_DIR and $g_TGT_DIR..."
	fi
}


#
# show those source have but target doesn't
# $1    : source directory
# S2    : target directory
# $3    : prefix char (- or +)
process_1() {
	local dir_list=
	local count=0
	local src
	local tgt
	local prefix

	if [ $# -lt 3 ]; then
		echo wrong argument number !!!
		exit
	else
		src=$1; tgt=$2; prefix=$3
	fi

	for file in `ls -a $src`; do
		((count++))
		if [ -f $src/$file ]; then
			test ! -f $tgt/$file && echo "${prefix}f $src/$file"
		elif [ -d $src/$file ]; then
			test ! -d $tgt/$file && echo "${prefix}d $src/$file"
			if [ $count -gt 2 ]; then	#skip . ..
				if [ "$dir_list" == "" ]; then
					dir_list=$file	#avoid " abc", "abc" instead
				else
					dir_list="$dir_list $file"
				fi
			fi
		else
			test ! -e $tgt/$file && echo "${prefix} $src/$file"
		fi
	done

	test ! -z "$dir_list" && echo "directory '${dir_list}' not compared !"
}


#
# show source has but target doesn't with + and - vice versa
# $1    : source directory
# S2    : target directory
#
process() {
	local src
	local tgt

	test $# -lt 2 && echo wrong argument number !!! && exit
	src=$1; tgt=$2

	process_1 $src $tgt "-"
	process_1 $tgt $src "+"
	
}



############
### main ###
############
parse_param $@
check_param
process $g_TGT_DIR $g_SRC_DIR

<file_sep>#!/bin/sh

CUSTROOT=/home/custom

find ${CUSTROOT} -maxdepth 2 | grep -e "-[0-9].*\.[0-9][0-9][1-9,a-c][0-9][0-9]$"

<file_sep># must build ubuntu2004:0000 in advance
# docker build -t ubuntu2004:0110 .
# 01 is major 00 is minor
# for go
#
FROM ubuntu2004:0000
LABEL maintainer="manuchen@home"
LABEL version="01.00"
LABEL description="base of go"
ENV VER=1.14.8
RUN wget -c https://dl.google.com/go/go${VER}.linux-amd64.tar.gz -O - | tar -xz -C /usr/local && echo "export GOROOT=/usr/local/go" >>~/.bashrc && echo "export PATH=\${PATH}:\${GOROOT}/bin" >>~/.bashrc
<file_sep>#!/bin/sh
#
# Taken scan.LOG as output of A180 debug message and format the stitistics
# in file tmp.log
#

# there are 37 channels in area of post code 95035
#
LOG_FILE=scan.LOG
TMP_FILE=tmp.log
STATISTIC_FILE=statistic.log

# extract critical information
#
cat $LOG_FILE | awk '/:ATSCTunerNodeGetSignalLocked|:ATSCTunerNodeGetSignalStrength|:ATSCTunerNodeGetSignalQuality|:SetATSCFrequency/ {print}' > $TMP_FILE


# format as
#	 freq (lock,strength,quality)
#    for each iteration
cat $TMP_FILE | \
awk 'NR%4 == 1 { freq=$5 }; NR%4 == 2 { lock=$5 }; NR%4 == 3 { strength=$5 }; NR%4 == 0 \
{print freq, "("lock","strength","$5")"}' > $STATISTIC_FILE


# format as
#	 freq (lock,strength,quality) (lock,strength,quality)...
#    for each distict frequency
FREQ_LIST=
cur_freq=
line=1

for i in `cat $STATISTIC_FILE`; do
	if [ 1 == `expr $line % 2` ]; then	# frequency
		if [ ! "0${FREQ_COUNTs["$i"]}" -gt 0 ]; then
			# remember each distinct frequency
			FREQ_LIST="$FREQ_LIST $i"
			FINAL_LISTs["$i"]=$i
			let FREQ_COUNTs["$i"]++
		fi
		cur_freq=$i
	else					# (lock,strength,quality)
		FINAL_LISTs["cur_freq"]="${FINAL_LISTs["cur_freq"]} $i"
	fi
	let line++
done


# print result

echo '============ statistics =======================================' >>$TMP_FILE
echo 'frequency (lock, strength, quality) (lock, strength, quality...' >>$TMP_FILE
echo '===============================================================' >>$TMP_FILE
for i in $FREQ_LIST; do
	echo ${FINAL_LISTs["$i"]} >> $TMP_FILE
done
<file_sep>#!/bin/sh
#
# To touch the whole directory
#
# In	: $1 - target directory
#

# In	: $1 - given string to show
#
usage()
{
	echo "$1"
	echo "Usage: touchd.sh TARGET_DIR"
	exit -1
}

test -z $1 && usage
test ! -d $1 && usage "\"$1\" does not exist !!!"

find $1 -exec touch '{}' \;
<file_sep>#!/bin/bash

hexdump -C ~/.bashrc
hexdump -x ~/.bashrc
<file_sep>export AM_DIR=~/bin/amlogic
export WK_DIR=$AM_DIR
export PATH=~/bin:$AM_DIR/arm-2010q1/bin:$PATH
export CROSS_COMPILE=arm-none-eabi-
export KSRC=$AM_DIR/arm-src-kernel-2011-02-21-11.30-git-9dababe0e2
export KOBJ=$KSRC

<file_sep># Download base image ubuntu 20.04
# docker build -t ubuntu2004:0000 .
# 00 is major 00 is minor, python3.8 by default
#  g++
FROM --platform=linux/amd64 ubuntu:20.04
LABEL maintainer="<EMAIL>"
LABEL version="00.00"
LABEL description="base of ubuntu"
ENV TZ=Asia/Taipei
ENV APP="vim git curl build-essential g++ software-properties-common wget"
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get update && apt-get install -y $APP 
RUN echo EDITOR=vim >>~/.bashrc
<file_sep>#!/bin/bash
echo "udevadm info --query=all --name=usb"
echo "udevadm info --query=all --name=/dev/dri/card0 --attribute-walk"
echo "udevadm info --attribute-walk --path=$(udevadm info --query=path --name=/dev/dri/card0)"
echo "udevadm monitor"
echo "sudo udevadm control --reload"
echo "tail -f /var/log/usbdevice.log"
<file_sep>#!/bin/bash
sudo apt update
sudo apt download libgles2-mesa-dev libegl1-mesa-dev
mkdir GLES EGL
pushd GLES; ar x ../libgles2*.deb; tar xf data.tar.xz; sudo cp -a usr/include/GLES* /usr/include; popd
pushd EGL; ar x ../libegl1*.deb; tar xf data.tar.xz; sudo cp -a usr/include/EGL /usr/include; popd
cp -a /usr/src/nvidia/graphics_demos/include/KHR /usr/include

sudo apt install libglm-dev libinput-dev libudev-dev symlinks libxkbcommon-dev ".*libxcb.*" libxrender-dev libxi-dev libfontconfig1-dev
pushd /; sudo symlinks -c -r / ;tar cjf ~/nano441_root.tgz lib usr/include usr/lib usr/local/cuda*; popd
<file_sep>#!/bin/bash
# Usage: mountfdos FULL_PATH_IMAGE, /mnt/Data/KVM/fdos.img by default

MNT_DIR=/mnt/fdos
IMG=/mnt/Data/KVM/fdos.img

mkdir -p $MNT_DIR

test -n "$1" && IMG=$1
if [ -f $IMG ]; then
	sudo mount -t msdos -o loop,offset=32256 $IMG $MNT_DIR
else
	echo "Missing $IMG"
fi

<file_sep>#!/usr/bin/python

import glob, os

SCU="/sys/class/udc/"
UDC="dwc3.1.auto/"

ITEMS={
	"a_alt_hnp_support": 1,
	"current_speed": 1,
	"is_a_peripheral": 1,
	"maximum_speed": 1,
	"srp": 0,
	"uevent": 1,
	"b_hnp_support": 1,
	"is_otg": 0,
	"power": 0,
	"state": 1,
	"b_hnp_enable": 1,
	"function": 1,
	"is_selfpowered": 0,
	"soft_connect": 0,
	"subsystem": 0
}

for ff in glob.glob(SCU+UDC+"*"):
	basename = os.path.basename(ff)
	if basename in ITEMS and ITEMS[basename]:
		if os.path.islink(ff): continue
		if os.path.isdir(ff): continue
		print "*** checking", basename
		os.system('cat '+ff)

<file_sep>#!/bin/bash

#Put the followings to [autoexec] of ~/.dosbox/san5.conf
#   mount c ~/dos/san5
#   mount d / -t cdrom
#   c:
#   san5.com

dosbox -conf ~/.dosbox/san5.conf
<file_sep># Usage:
#	untar.sh -F|-R [-s SRC_FILE] -t TGT_DIR [-q]
#

#
# In	: $1- message
#
function usage()
{
	echo "Error: $1"
	echo Usage:
	echo "untar.sh -F|-R|-G [-s SRC_FILE] -t TGT_DIR [-q]"
	echo "  F : Fedora Core 3"
	echo "  R : Red Hat 9"
	echo "  G : Fedora Core 4"
	echo " SRC_FILE: if omited, $RH9/$FC3 as default for R/F"
	echo " TGT_DIR: target directory"
	echo "  q : quiet"
	exit 0
}

#
# main
#
CUR_DIR=$PWD
RH9DIR=$CUR_DIR/RH9
RH9=rh9-root.tgz
FC3DIR=$CUR_DIR/FC3
FC3=fc3-root.tgz
FC4DIR=$CUR_DIR/FC4
FC4=fc4-root.tgz
D4_SRC_FILE=
SRC_FILE=
TGT_DIR=
QUIET=			#not quiet by default

#
# 1. Check parameters
#
while getopts ":t:s:RFGBq" arg
do
	case "$arg" in
	t)	TGT_DIR=$OPTARG;;
	s)	SRC_FILE=$OPTARG;;
	F)	D4_SRC_FILE=$FC3DIR/$FC3;;
	R)	D4_SRC_FILE=$RH9DIR/$RH9;;
	G)	D4_SRC_FILE=$FC4DIR/$FC4;;
	q)	QUIET=yes;;
	esac
done

test -z $TGT_DIR &&  usage "No target directory assigned"
test ! -d $TGT_DIR && usage "Target directory $TGT_DIR doesn't exist"
test -z $D4_SRC_FILE && usage "Please use -F, -G or -R flag"
test -z $SRC_FILE && SRC_FILE=$D4_SRC_FILE

test ! -f $SRC_FILE && usage "File $SRC_FILE doesn't exist"

#
# 2. Determine source file type, what dir to create after install
#
case $D4_SRC_FILE in
*$FC3)
	#tared "bin dev etc home initrd lib media misc opt root"
	#tared "sbin selinux srv tftpboot usr var"
	DIRS="boot mnt/usb proc sys tmp"
	#not created lost+found
	;;
*$FC4)
	#tared "bin dev etc home lib media misc opt root"
	#tared "sbin selinux srv tftpboot usr var"
	DIRS="boot mnt/usb net proc sys tmp"
	#not created lost+found
	;;
*$RH9)
	#tared "bin boot dev etc home initrd lib lost+found misc mnt"
	#tared "opt proc root sbin tftpboot tmp usr var"
	DIRS="mnt/usb"
	;;
*)	usage "Unknown system";;
esac

#
# guess format
#
if echo $SRC_FILE | grep -q -e "tgz$"; then
	FLAGS="-xzf"
elif echo $SRC_FILE | grep -q -e "tar$"; then
	FLAGS="-xf"
else
	usage "Unknown source file format" 
fi

if [ -z $QUIET ]; then
	echo -n "        To untar $FLAGS \"$TGT_DIR\" from $SRC_FILE ? (y/n): "
	read ANSWER
	if [[ x$ANSWER != xy && x$ANSWER != xY ]]; then exit 0; fi
fi
echo Processing...

pushd . >/dev/null 2>&1
cd $TGT_DIR;tar $FLAGS $SRC_FILE
if [ x"$DIRS" != x ]; then
	echo Creating directories $DIRS ...
	mkdir -p $DIRS
fi
popd >/dev/null 2>&1
<file_sep># Usage:
#	tar.sh FC3|RH9|FC4 TGT_FILE SRC_DIR
#

#
# In	: $1- message
#
function usage()
{
	echo "Error: $1"
	echo Usage:
	echo "$0 FC3|RH9|FC4 TGT_FILE SRC_DIR"
	exit 0
}

#
# check parameters
#
if [ "$#" != "3" ]; then usage "parameter count"; fi

if [ -d $3 ]; then SRC_DIR=$3; else usage "Directory doesn't exist"; fi

if [ ! -f $2 ]; then TGT_FILE=$2; else usage "File exist"; fi
 
case $1 in
FC3)
	echo "  **** you MUST boot with FC3 and then tar from / !!! ****"
	DIR1="bin dev etc home initrd lib media misc opt root"
	DIR2="sbin selinux srv tftpboot usr var"
	# yet tared : boot lost+found mnt proc sys tmp
	;;
FC4)
	echo "  **** you MUST boot with FC4 and then tar from / !!! ****"
	DIR1="bin dev etc home lib media misc opt root"
	DIR2="sbin selinux srv tftpboot usr var"
	# yet tared : boot lost+found mnt net proc sys tmp
	;;
RH9)
	echo "  **** you SHOULDN'T boot with RH9 and then tar from / !!! ****"
	DIR1="bin boot dev etc home initrd lib lost+found misc mnt"
	DIR2="opt proc root sbin tftpboot tmp usr var"
	;;
*)
	usage "Unknown system"
	;;
esac

#
# guess target file
#
if echo $TGT_FILE | grep -q -v -e "^\/" ; then
	TGT_FILE=`pwd`/$TGT_FILE
fi

#
# guess format
#
if echo $TGT_FILE | grep -q -e "tar$"; then
	FLAGS="-c -p --same-owner -l -f"
	ZIP=0
elif echo $TGT_FILE | grep -q -e "tgz$"; then
	FLAGS="-c -p --same-owner -l -f -"
	ZIP=1
else
	usage "Unknown target file format" 
fi

echo "        To tar $FLAGS"
echo "            $DIR1"
echo "            $DIR2"
echo -n "        from \"$SRC_DIR\" as $TGT_FILE ? (y/n): "

read ANSWER
if [[ x$ANSWER != xy && x$ANSWER != xY ]]; then exit 0; fi

echo Processing...

if [ -z "$ZIP" ]; then
	cd $SRC_DIR;tar $FLAGS $TGT_FILE $DIR1 $DIR2
else
	cd $SRC_DIR;tar $FLAGS $DIR1 $DIR2 | gzip -1 >$TGT_FILE
fi

<file_sep>#!/usr/bin/ruby

$myID = 'lessmoney'
$myPW = '<PASSWORD>'
$jkLink = "www.jkforum.net/forum.php"
$unLink = "twunbbs.com/forum.php"
$enLink = "www.eyny.com"
$st85Link = "85st.com/forum.php"
$fishLink = "fishgeter.com"

$allSites = {
	'doJK' => "www.jkforum.net/forum.php"\
	, 'doUn' => "twunbbs.com/forum.php"\
	, 'doEyny' => "www.eyny.com"\
	, 'do85ST' => "85st.com/forum.php"\
}

require 'watir-webdriver'
require 'optparse'

#give options default value
$options = {'debug' => 0}


#
# output message if message level is no less than current setting
#
def dbg(msg, msgLevel = 1)
	if $options['debug'] >= msgLevel then
		puts "#{msg}"
	end
end


#
# set all options['xxx'] to given value
def setAllOptions(value)
	$allSites.keys.each do |site|
		cmd = "\$options['" + "#{site}'] " + "= #{value}"
		eval(cmd)
	end
end


#
# In  : arg - argument list. i.e ARGV
#       $options - loaded w/ default value
# Out : $options - those to execute are set to true
#
def checkParam(arg)
	doAll = 1                                #assume all need to do
	index = 0
	
	setAllOptions(false)
	#process options
	OptionParser.new do |opts|
		opts.banner = "Usage: ruby auto.rb [-d LEVEL] [-j] [-f] [-e] [-u] [-s]
		LEVEL defaults to 0, which means debug off
		-j JK
		-f Fisher
		-e Eyny
		-u UN BBS
		-s 85 ST
	when none is provided, all sites visited"
		
	
		opts.on( '-d', '--debug level', 'debug level') { |level| $options['debug'] = level.to_i }
		opts.on( '-j', '--jk', 'JK forum') {$options['doJK'] = true}
		opts.on( '-f', '--fish', 'Fisher forum') {$options['doFish'] = true}
		opts.on( '-e', '--eyny', 'EYNY forum') {$options['doEyny'] = true}
		opts.on( '-u', '--un', 'UNBBS forum') {$options['doUn'] = true}
		opts.on( '-s', '--st', '85ST forum') {$options['do85ST'] = true}
		opts.on('-h', '--help', 'Display usage') {
			puts "#{opts.banner}"
			exit
		}
	end.parse arg

	$allSites.keys.each do |site|
		varName = "\$options['" +"#{site}']"
		index += 1
		dbg("  user #{varName}: #{eval(varName)}")
		if eval(varName) then doAll = 0 end       #once any is set, not all is requested
	end

	if doAll > 0 then
		dbg("No flag found and to modify enable all options !", 2)
		setAllOptions(true)
	end
end


#
# Do jobs on $options that is true
#
def jobDispatcher()
	$allSites.each do |site, link|
		optName = "\$options['" + "#{site}']"
		if eval(optName) then
			dbg("#{site} w/ #{link}", 3)
			cmd = "#{site}\(\"#{link}\")"
			eval(cmd)
		end
	end
end


def doEyny(link)
	bw = Watir::Browser.new :chrome
	bw.goto link

	div1 = bw.body.div(:id => 'wp').div(:class => 'y')
	if div1 == NIL then
		puts "No 'body.div.div.div' found"
		return
	end

	span = div1.span(:class => 'pipe')
	if span == NIL then
		puts "No 'body.div.div.div.span' found"
		return
	end
	span.hover
	
	span1 = span.element(:xpath => './following-sibling::*[3]')
	if span1 == NIL then
		puts "No 'body.div.div.div.span1' found"
		return
	end
	#puts "#{span1.inspect}, #{span1.text}"
	span1.click

	bw.div(:class => 'rfm').wait_until_present
	#user name in a div
	div = bw.div(:class => 'rfm')
	tr = div.table.tbody.tr
	span = tr.th.span
	hashid = span.a.attribute_value("id")
	hashid = hashid.sub("loginfield_","")
	hashid = hashid.sub("_ctrl","")
	nameid = "username_" << hashid
	#(loginfield_)(.*)(_ctrl)
	tr.text_field(:id => nameid).set $myID
	
	#passwd is sibling of user name
	div1 = div.element(:xpath => './following-sibling::*')
	nameid = "password3_" << hashid
	tr = div1.table.tbody.tr
	tr.text_field(:id => nameid).set $myPW
	bw.send_keys :enter
end


def doUn(link)
	bw = Watir::Browser.new :chrome
	bw.goto link

	bw.div(:class => 'mb_1 mb_11').a.click
	bw.div(:class => 'rfm').wait_until_present
	#user name in a div
	div = bw.div(:class => 'rfm')
	tr = div.table.tbody.tr
	label = tr.th.label
	hashid = label.attribute_value("for")
	#puts "#{label.inspect}, #{label.text} #{label.attribute_value("for")}"
	tr.text_field(:id => hashid).set $myID
	
	#passwd is sibling of user name
	div1 = div.element(:xpath => './following-sibling::*')
	tr = div1.table.tbody.tr
	label = tr.th.label
	hashid = label.attribute_value("for")
	tr.text_field(:id => hashid).set $myPW
	bw.send_keys :enter
end


def doCommon(link)
	bw = Watir::Browser.new :chrome
	bw.goto link

	bw.text_field(:id => 'ls_username').set $myID
	bw.text_field(:id => 'ls_password').set $myPW
	bw.send_keys :enter
	#bw.button(:class => 'pn vm').click
end


def doFish(link)
	bw = Watir::Browser.new :chrome
	bw.goto link

	bw.div(:id => 'umenu').as[1].click
	bw.text_field(:name => 'username').set $myID
	bw.text_field(:name => 'password').set $myPW
	bw.send_keys :enter
end


def doJK(link)
	doCommon(link)
end


def do85ST(link)
	bw = Watir::Browser.new :chrome
	bw.goto link

	bw.div(:class => 'logintx').as[0].click
	bw.text_field(:name => 'username').set $myID
	bw.text_field(:name => 'password').set $<PASSWORD>
	bw.send_keys :enter
end


###
# main

checkParam(ARGV)
jobDispatcher

exit

doFish
doEyny
doUN
doJK($jkLink)
doJK($st85Link)
<file_sep>#!/bin/bash

#
# $1 : top directory to check CVS with
#

# change the [NEW_IP] in [FILE] 
# $1 [FILE] file name, no check FILE here
# $2 [NEW_IP] to replace manuchen@xxx:/wincvs in [FILE], no check NEW_IP here
chgIPofFile() {
	local FILE=$1
	local NEW_IP=$2

	# echo FILE=$FILE, NEW_IP=$NEW_IP
	cat $FILE | sed -e "s/[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+/$NEW_IP/" > $FILE.tmp
	mv $FILE.tmp $FILE
}

############
### main ###
############

# 1. check top directory
test ! -d "$1" && echo Please input valid dir name && exit
TOP_DIR=$1

# 2. get cvs server IP
echo -n "Please input IP of CVS server: "
read NEW_IP

# 3. check cvs server IP
if [ ! -z "$NEW_IP" ]; then
	TEST_IP=`echo $NEW_IP | grep -e "[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+"`
	if [ -z "$TEST_IP" ]; then      
		echo "Invalid IP ($NEW_IP)"
                exit
	fi      
fi
echo Replacing new ip $NEW_IP

# 4. process replacement
find $TOP_DIR -path "*/CVS/Root" | while read f; do chgIPofFile $f $NEW_IP; done

<file_sep>#!/bin/bash

SPEED=100
test $# -ne 0 && SPEED=$1
echo Writing fan speed $SPEED
su -c "echo $SPEED >/sys/devices/pwm-fan/target_pwm"
<file_sep># need to copy ../qmake.conf to jetson-tx1-g++
#export ROOTFS=~/cross/nano_441
#export TARGET_ROOTFS=${ROOTFS}
#export CROSS_COMPILE=aarch64-linux-gnu-
#export PATH=~/bin/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin:${PATH}

#qmake gen makefile
# --sysroot="compile-time $ROOTFS"
# -rpath-link,
./configure -shared -c++std c++14 -opensource -release -recheck-all --confirm-license -device linux-jetson-tx1-g++ -device-option CROSS_COMPILE=${CROSS_COMPILE} -extprefix ${ROOTFS}/usr/local/qt5 -hostprefix /home/manu/cross/hostqt5 -skip webview -skip qtwebengine -opengl es2 -sysroot ${ROOTFS}
<file_sep>#!/bin/bash

echo "\$0=$0"
echo "\$ZSH_NAME=$ZSH_NAME"
echo "\$BASH_SOURCE=$BASH_SOURCE"
echo "\$PWD=$PWD"
echo ""

echo "Current directory is $PWD"
tmpDir=`readlink -f $PWD`
parentDir=`dirname $tmpDir`
pushd .. >/dev/null
echo "Parent directory is $PWD"
popd >/dev/null

tmpDir=`readlink -f $BASH_SOURCE`
parentDir=`dirname $tmpDir`
echo "Script directory is $parentDir"
<file_sep>#!/bin/bash
# put all files in a directory in host to a directory of adb device

#
# Usage:
#   adb_mput.sh LOCAL_DIR REMOTE_DIR
#   adb mput.sh FLIST REMOTE_DIR
#           FLIST - file contains a list of files
#
usage() {
	echo "Usage: adb_mput.sh LOCAL_DIR REMOTE_DIR"
	echo "       adb mput.sh FLIST REMOTE_DIR"
	echo "           FLIST - file contains a list of files"
}



############
### main ###
############
test $# -ne 2 && usage && exit
FLIST=
if [ -d "$1" ]; then
	FLIST=/tmp/flist_mput.txt
	ls $1 > $FLIST
else
	test ! -f "$1" && usage && exit
	FLIST=$1
fi
RDIR=$2

#awk '{system("adb push "$0 " /sdcard/Movies")}' $FLIST
for f in `cat $FLIST`; do
	adb push $f $RDIR
done
<file_sep># Download base image jenkins:jenkins x64
# docker build -t manu-jenkins:0000 .
# RUN:
#  docker run -d --name mj --user root -p 8080:8080 -p 50000:50000 -v /var/run/docker.sock:/var/run/docker.sock manu-jenkins:0000
# Check password: in /var/jenkins_home/secrets/initialAdminPassword
#  docker start mj       ... if ever powered off
#  docker exec -it mj /bin/bash
# 00 is base
# must have USER root to avoid apt-key or something fail
# java -jar jenkins-cli.jar -auth manu:manu -s http://localhost:8080 get-job <myjob> > myjob.xml
# java -jar jenkins-cli.jar -auth manu:manu -s http://localhost:8080 create-job <myjob> < myjob.xml
FROM jenkins/jenkins:latest
LABEL maintainer="<EMAIL>"
LABEL version="00.00"
LABEL description="base of jenkins"
USER root
ENV TZ=Asia/Taipei
ENV APP="apt-transport-https ca-certificates curl gnupg2 software-properties-common"
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get update && apt-get -y install $APP && curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg > /tmp/dkey; apt-key add /tmp/dkey && add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") $(lsb_release -cs) stable" && apt-get update && apt-get -y install docker-ce
<file_sep>#!/bin/sh

#
# output error message and usage before end process
# In	: $1- message
#
function usage()
{
	test ! -z "$1" && echo "Error: $1"
	echo "Usage: $0 SRC_KERNEL_TREE [TGT_KERNEL_TREE]"
	echo "	copy dvb-core, dvb-usb and frontends headers from SRC to TGT kernel tree"
	echo "	    SRC_KERNEL_TREE: the source of root of kernel tree"
	echo "	    TGT_KERNEL_TREE: the target of root of target tree,"
	echo "	        if missed, /lib/modules/\`uname -r\`/source is used"
	exit 1
}


COMMON_PATH=drivers/media/dvb
SUB_DIRS="$COMMON_PATH/dvb-core $COMMON_PATH/dvb-usb $COMMON_PATH/frontends"
TGT_KERNEL_ROOT=/lib/modules/`uname -r`/source

###################################
#####  check source directory #####
test $# -lt 1 && usage "Incorrect arguments"
SRC_KERNEL_ROOT=$1
test ! -d "$SRC_KERNEL_ROOT" && usage "Missing source directory"
echo "   SOURCE: $SRC_KERNEL_ROOT"

###################################
#####  check target directory #####
shift
test ! -z "$1" && set TGT_KERNEL_ROOT=$1
test ! -d "$TGT_KERNEL_ROOT" && usage "Missing target directory"
echo "   TARGET: $TGT_KERNEL_ROOT"

###########################################
##### processing each sub-directories #####
for dir in $SUB_DIRS; do
	if [ ! -d $SRC_KERNEL_ROOT/$dir ]; then
		echo "Missing source $SRC_KERNEL_ROOT/$dir ...skip"
		continue
	fi
	if [ ! -d $TGT_KERNEL_ROOT/$dir ]; then
		echo "Missing target $TGT_KERNEL_ROOT/$dir ...skip"
		continue
	fi
	echo "        copying $dir"
	cp $SRC_KERNEL_ROOT/$dir/*.h $TGT_KERNEL_ROOT/$dir
done

<file_sep>#!/bin/bash

#for host
#
#sudo apt-get install virt-manager libvirt-bin qemu-system qemu-kvm linux-image-extra-virtual
#sudo echo 'auto eth0' >>/etc/network/interfaces
#sudo echo 'iface eth0 inet manual' >>/etc/network/interfaces
#sudo echo 'auto br0' >>/etc/network/interfaces
#sudo echo 'iface br0 inet dhcp' >>/etc/network/interfaces
#sudo echo '\tbridge_ports eth0' >>/etc/network/interfaces
#sudo echo '\tbridge_stp off' >>/etc/network/interfaces
#sudo echo '\tbridge_fd 0' >>/etc/network/interfaces
#sudo echo '\tbridge_maxwait 0' >>/etc/network/interfaces

sudo apt-get install -y xfce4 xfce4-terminal minicom nfs-common nfs-kernel-server
sudo apt-get install -y filezilla vsftpd tftpd-hpa g++ vim git gitk\
	synaptic ssh meld dos2unix
sudo echo '/home/aten-3a00/ti *(rw,sync,no_subtree_check)' >>/etc/exports
echo 'export EDITOR=vim' >>~/.bashrc
<file_sep># almost follow chinese way (no KHR) but I also create symblink as western way 
# sudo apt install symlinks nfs-kernel-server
# sudo vi /etc/exports:
#   <add> / *(ro,fsid=root,no_root_squash,nohide,insecure,no_subtree_check)
# sudo exportfs -a
# sudo symlinks -c -r /
# delete config.cache

#test this
./configure -shared -c++std c++14 -opensource -release -recheck-all --confirm-license\
 -device linux-jetson-tx1-g++ -device-option CROSS_COMPILE=aarch64-linux-gnu-\
 -sysroot / -nomake tests -prefix /usr/local/qt5 -extprefix /usr/local/qt5 -hostprefix /usr/local/qt5 -skip webview -skip qtwebengine -opengl es2


#works
./configure -shared -c++std c++14 -opensource -release -recheck-all --confirm-license -device linux-jetson-tx1-g++ -device-option CROSS_COMPILE=/home/manu/bin/gcc-linaro-6.5.0-2018.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- -sysroot /home/manu/jetson -nomake examples -nomake tests -prefix /usr/local/qt5 -extprefix /home/manu/Downloads/qt-everywhere-src-5.14.1/NanoR32.3.1/qt5 -hostprefix /home/manu/Downloads/qt-everywhere-src-5.14.1/NanoR32.3.1/qt5-host -skip webview -skip qtwebengine -opengl es2

#not this
./configure -shared -c++std c++14 \
 -opensource -release --confirm-license -no-pkg-config \
 -device linux-jetson-tx1-g++ \
 -device-option CROSS_COMPILE=/home/manu/bin/gcc-linaro-6.5.0-2018.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- \
 -sysroot /home/manu/jetson \
 -nomake examples -nomake tests \
 -prefix /usr/local/qt5 \
 -extprefix /home/manu/Downloads/qt-everywhere-src-5.14.1/NanoR32.3.1/qt5 \
 -hostprefix /home/manu/Downloads/qt-everywhere-src-5.14.1/NanoR32.3.1/qt5-host \
 -skip webview -skip qtwebengine -opengl es2

./configure -shared -c++std c++14 \
 -opensource -release --confirm-license -no-pkg-config \
 -device linux-jetson-tx1-g++ \
 -device-option CROSS_COMPILE=/home/manu/bin/gcc-linaro-6.5.0-2018.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- \
 -sysroot /home/manu/Downloads/nano-rootfs \
 -nomake examples -nomake tests \
 -prefix /usr/local/qt5 \
 -extprefix /home/manu/Downloads/qt-everywhere-src-5.14.1/JetsonNano/qt5 \
 -hostprefix /home/manu/Downloads/qt-everywhere-src-5.14.1/JetsonNano/qt5-host \
 -skip webview -skip qtwebengine -opengl es2

./configure -shared -c++std c++14 \
 -opensource -release --confirm-license -no-pkg-config \
 -device linux-jetson-tx1-g++ \
 -device-option CROSS_COMPILE=/home/manu/bin/gcc-linaro-5.5.0-2017.10-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- \
 -sysroot /home/manu/Downloads/nano-rootfs \
 -nomake examples -nomake tests \
 -prefix /usr/local/qt5 \
 -extprefix /home/manu/Downloads/qt-everywhere-src-5.14.1/JetsonNano/qt5 \
 -hostprefix /home/manu/Downloads/qt-everywhere-src-5.14.1/JetsonNano/qt5-host \
 -skip webview -skip qtwebengine -opengl es2


<file_sep>#!/bin/bash
# Usage: new_install manuchen

#ubuntu install mfx
#sudo apt install -y libmfx1 intel-media-va-driver-non-free libigfxcmrt7 libva-drm2 libva-x11-2 libmfx-dev libmfx-tools
#sudo apt install -y gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-tools
#git clone https://github.com/intel/gstreamer-media-SDK.git
#sudo apt install cmake autoconf libtool libglib2.0-dev libudev-dev libgstreamermm-1.0-dev libva-dev libdrm-dev libgst-dev libgstreamer-plugins-*-dev
#mkdir build && cd build && cmake ..
#make; make install


#
# in   : S1 - user name to set permision with
#
get_param()
{
        if [ -z "$1" ]; then
                G_USER=`whoami`
        else
                G_USER=$1
        fi
        X64_CPU=`uname -m`
        MY_UID=`id $G_USER | cut -d"=" -f2 | cut -d"(" -f1`
        test -z "$MY_UID" && exit
        echo G_USER = $G_USER, X64_CPU = $X64_CPU, MY_UID = $MY_UID
}


#
# get answer among (y/n/s)
# in	: $1 - string to highligh for user
# out	: g_ANS = 'n' or 's' or default = 'y'
#
get_answer()
{
	MESSAGE=$1
	echo -en "\\033[0;33m"
	echo -en "$MESSAGE (Yes/No/Skip): "
	echo -en "\\033[0;39m"

	read ans

	if [ $ans == 'N' -o $ans == 'n' ]; then
		g_ANS='n'
	elif [ $ans == 'S' -o $ans == 's' ]; then
		g_ANS='s'
	else
		g_ANS='y'
	fi
}


#
# setting .bashrc
#
do_bashrc()
{
	if `grep EDITOR ~/.bashrc`; then
		get_answer "The bashrc might be updated, continue to process ?"
		if [ $g_ANS == 'n' ]; then
			exit 0
		elif [ $g_ANS == 's' ]; then
			return
		fi
	fi

	##### CVS setting #####
	#echo "export CVSROOT=:pserver:manuchen@10.1.9.200:/home/cvsroot" >> ~/.bashrc
	#echo "export EDITOR=vim" >> ~/.bashrc

	##### CIFS setting #####
	#echo -n "alias lnaver='sudo mount.cifs //avermedia.com/NETLOGON /mnt/aver" >> ~/.bashrc
	#echo -n " -o uid=$MY_UID,username=avermedia\\" >> ~/.bashrc
	#echo "\\\\a000989'" >> ~/.bashrc

	#echo -n "alias lndriver='sudo mount.cifs //10.1.9.247/Driver /mnt/driver" >> ~/.bashrc
	#echo -n " -o uid=$MY_UID,username=avermedia\\" >> ~/.bashrc
	#echo "\\\\a000989'" >> ~/.bashrc

	#echo -n "alias ln618='sudo mount.cifs //10.1.9.247/b618 /mnt/618" >> ~/.bashrc
	#echo -n " -o uid=$MY_UID,username=avermedia\\" >> ~/.bashrc
	#echo "\\\\a000989'" >> ~/.bashrc

	#echo -n "alias lngit='sudo mount.cifs //10.1.9.247/vl/GIT /mnt/git" >> ~/.bashrc
	#echo -n " -o uid=$MY_UID,username=avermedia\\" >> ~/.bashrc
	#echo "\\\\a000989'" >> ~/.bashrc
	
	#echo -n "alias ln200='sudo mount.cifs //10.1.9.200/manuchen /mnt/200" >> ~/.bashrc
	#echo " -o username=manuchen'" >> ~/.bashrc

	#echo -n "alias lnsrc='sudo mount.cifs //10.1.9.200/Resources /mnt/src" >> ~/.bashrc
	#echo " -o username=manuchen'" >> ~/.bashrc

	#ubuntu 21.10 needs forceuid,forcegid
	echo "alias smbnas='sudo mount.cifs //192.168.3.11/share/git ~/nas -o forceuid,forcegid,uid=\$(id -u),gid=\$(id -g),username=manu,vers=1.0'" >> ~/.bashrc
	echo "export EDITOR=vim" >> ~/.bashrc
	#echo "alias goshare='cd /media/sf_share'" >> ~/.bashrc
}


#
# check if application installed well
#
check_app()
{
	CHECKLIST="gitk cifs-utils vim ssh minicom g++ build-essential terminator gparted chromium-browser fcitx-libs-dev fcitx-tools fcitx-table cmake"
	PURGE_LIST="libreoffice-* firefox"

	#CHECKLIST="cvs git tftp mount.cifs vim ssh kaffeine vlc mplayer minicom v4l2ucp g++ codeblocks"
	for app in $CHECKLIST; do
		test ! `which $app` && echo "$app is not installed !!!"
	done
}


#
# install applications
#
do_app_install()
{
	#front type freemono 14
	BASE_APP="gitk vim terminator build-essential curl wget cifs-utils"
	
	# dayi for ubuntu
	#    1. setup language: install chinese language and logout and login
	#    2. follow
	#    https://github.com/Alger23/ubuntu_dayi_for_ibus
	#    3. setup keyboard: add chinese/dayi input source

	# use ssh-keygen and register id_rsa.pub to github
	# git clone <EMAIL>:twManu/shell.git

	#APPLIST="cvs git-core nfs-kernel-server tftpd-hpa tftp-hpa smbfs vim ssh samba \
	#	gitk kaffeine xine-ui vlc mplayer minicom v4l2ucp g++ filezilla codeblocks \
	#	wireshark gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev \
	#	x11proto-core-dev libx11-dev libgl1-mesa-dev g++-multilib mingw32 tofrodos \
	#	python-markdown libxml2-utils xsltproc"
	APPLIST=${BASEAPP}
	test $X64_CPU = "x86_64" && APPLIST="$APPLIST ia32-libs lib32ncurses5-dev lib32z1-dev lib32readline-gplv2-dev"

	if [ ! -z `which cvs` ] ; then
		get_answer "The CVS is installed, continue to process ?"
		if [ $g_ANS == 'n' ]; then
			exit 0
		elif [ $g_ANS == 's' ]; then
			return
		fi
	fi

	#wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

	sudo apt-get -y install $APPLIST
	check_app
	cat >~.vimrc <<EOF
	syntax enable
	set smartindent
	set tabstop=4
	set shiftwidth=4
	set noexpandtab
EOF
}


do_mnt()
{
	DIRLIST="/mnt/aver /mnt/driver /mnt/git"
	for dir in $DIRLIST; do
		if [ ! -e $dir ]; then
			sudo mkdir $dir
		else
			echo "$dir exists...skip creating directory" > /dev/null
		fi
	done
}


#
# configure samba
# in	: $1 - username
#
do_smb()
{
	SYSSMBCFG=/etc/samba/smb.conf
	SMBCFG=./tmp.conf

	if grep $G_USER $SYSSMBCFG; then
		get_answer "The $G_USER is present in smb.conf, continue to process ?"
		if [ $g_ANS == 'n' ]; then
			exit 0
		elif [ $g_ANS == 's' ]; then
			return
		fi
	fi

	if [ -f $SYSSMBCFG ]; then
		cp $SYSSMBCFG $SMBCFG
		echo "" >> $SMBCFG
		echo "[$G_USER]" >> $SMBCFG
		echo "	path = /home/$G_USER/" >> $SMBCFG
		echo "	browseable = yes" >> $SMBCFG
		echo "	read only = no" >> $SMBCFG
		echo "	guest ok = no" >> $SMBCFG
		echo "	create mask = 0664" >> $SMBCFG
		echo "	directory mask = 0755" >> $SMBCFG
		echo "	force user = $G_USER" >> $SMBCFG
		echo "	force group = $G_USER" >> $SMBCFG
		sudo mv $SMBCFG $SYSSMBCFG
	fi

	if [ ! -z `which smbpasswd` ]; then
		sudo smbpasswd -L -a $G_USER 
		sudo smbpasswd -L -e $G_USER
	fi
}

echoCmd() {
	[ -n "$1" ] && {
		echo "$1"
		eval "$1"
	}
}

#since alias takes no parameter, use function instead
ssh20() {
	doDel=
	NET=192.168.20
	if [ $# -lt 1 ]; then
		echo Usage: ssh20 LAST_IP [USER]
		echo "   ssh root@${NET}.LAST_IP by default"
	else
		USER=root
		[ -n "$2" -a "$2" == "-d" ] && doDel=yes
		if [ -n "${doDel}" ]; then
			# try to kill existing ssh end with $1
			curSSH=`ps aux | grep ssh | egrep "$1\$" | awk '{ print $2 }'`
			curSSHcount=`echo ${curSSH} | wc -l`
			echo "found ${curSSHcount} ssh process:"
			for line in ${curSSH}; do
				id=`echo ${line} | sed -e s/[^0-9]//g`
				echoCmd "kill -9 ${id}"
			done
		fi
		ssh-keygen -f "/home/oem/.ssh/known_hosts" -R "${NET}.$1"
		echoCmd "ssh ${USER}@${NET}.$1"
	fi
}

#NOTE:
#1.the mount.cifs uid=<uid#>, the user name becames unavailable after 11.10
#2.the ia32-libs fails x86 installation


get_param $1
do_app_install
#do_mnt
do_bashrc
#do_smb
<file_sep>#!/bin/sh

# there are 37 channels in area of post code 95035
TMP_FILE=tmp.log
grep "SignalLocked =" scan.LOG >$TMP_FILE

cat $TMP_FILE | awk 'BEGIN { x=0 } {print "channel"x+1 $4,$5; ++x; x%=37 }'

<file_sep>#!/bin/bash
# demonstrate usage of named pipe

#
# Usage:
#   named_pipe [-s|-c] [-m MSG]
#
usage() {
	echo "USage: named_pipe [-s|-c] [-m MSG]"
	echo "    -s: run as a server"
	echo "    -c: run as a client"
	echo "   MSG: client message to display in server side"
	echo "        quit mean to stop server"
}


pipe=/tmp/testpipe
g_server=0
g_msg=


#
# Update g_xxx variable
#
parse_param() {
	while getopts ":scm:" opt; do
		case $opt in
		s) g_server=1;;
		c) g_server=0;;
		m) g_msg=$OPTARG;;
		\?) usage
		    exit;;
		esac
	done
	OPTIND=1
	echo "g_server = $g_server, g_msg = $g_msg"
}


#
# server code: read from pipe
#
do_server() {
	test ! -p $pipe && mkfifo $pipe
	trap "rm -f $pipe" EXIT
	while true; do
		if read line <$pipe; then
			if [[ "$line" == 'quit' ]]; then
				break
			fi
			echo $line
		fi
	done
	echo "Reader exiting"
}


#
# client code: write to pipe
#
do_client() {
	if [[ ! -p $pipe ]]; then
		echo "Reader not running"
		exit 1
	fi

	if [[ ! -z "$g_msg" ]]; then
		echo $g_msg >$pipe
	else
		echo "Hello from $$" >$pipe
	fi
}


############
### main ###
############
parse_param $@
if [[ $g_server -eq 1 ]]; then
	do_server
else
	do_client
fi
<file_sep>ls -l | grep -e '^d' | awk '{print $9}'

<file_sep>#!/usr/bin/ruby
# encoding: UTF-8

taiwan = [
	  'http://stockq.org/index/TWSE.php'\
	, '$TWII - SharpCharts Workbench - StockCharts.com'
]

shanghai = [
	  'http://stockq.org/index/SHCOMP.php'\
	, '$SSEC - SharpCharts Workbench - StockCharts.com'
]

japan = [
	  'http://stockq.org/index/NKY.php'\
	, '$NIKK - SharpCharts Workbench - StockCharts.com'
]

dutch = [
	  'http://stockq.org/index/DAX.php'\
	, '$DAX - SharpCharts Workbench - StockCharts.com'
]

dow = [
	  'http://stockq.org/index/INDU.php'\
	, '$INDU - SharpCharts Workbench - StockCharts.com'
]

nasdaq = [
	  'http://stockq.org/index/CCMP.php'\
	, '$COMPQ - SharpCharts Workbench - StockCharts.com'
]

markets = [ taiwan, shanghai, japan, dutch, dow, nasdaq ]
	
require 'watir-webdriver'
#give options default value
$options = {'debug' => 0}


#
# output message if message level is no less than current setting
#
def dbg(msg, msgLevel = 1)
	if $options['debug'] >= msgLevel then
		puts "#{msg}"
	end
end


def fire(location)
	bw = Watir::Browser.new :chrome
	bw.goto location[0]
	
	b = bw.b(:text => '技術線圖')
	button = b.parent.elements[1]
	button.click
	bw.window(:title => location[1]).wait_until_present
	bw.window(:title => location[1]).use do
		bw.text_field(:id => 'overArgs_0').wait_until_present
		bw.text_field(:id => 'overArgs_0').set 5
		bw.text_field(:id => 'overArgs_1').set 22
		bw.text_field(:id => 'overArgs_2').set 66
		bw.input(:value => 'Update').click
	end
end


###
# main

markets.each { |place| fire place }

<file_sep>#!/bin/sh

#
# In	: $1- message
#
function usage()
{
	test ! -z "$1" && echo "Error: $1"
	echo "    Usage: $0 FILE"
	echo "    To remove comments in FILE"
	exit 0
}

#
# main
#

# check parameter count & file existence
#
test $# != 1 &&	usage "Incorrect number of parameter !!!"
test ! -f $1 && usage "$1 doesn't exist !!!"

cpp -fpreprocessed $1 >$1.pre
diff $1 $1.pre >$1.diff
cat $1.diff | grep -e '<[ tab]*#[ tab]*define' | grep -v -e '//' |\
sed 's/^<[ tab]*#[ tab]*define/#define/g' >$1.define
<file_sep>#!/bin/bash
# remove ^M in given file

#
# Usage:
#   removeUP_M.sh [-h] [-f FILE] -n
#
usage() {
	echo "Usage: removeUP_M.sh [-h] [-n] -f FILE"
	echo "    -n: replace ^M with '\n'"
	echo "  FILE: input file to work with"
}

g_newline=0
g_file=


#
# Update g_xxx variable
#
parse_param() {
	while getopts ":nf:" opt; do
		case $opt in
		n) g_newline=1;;
		f) g_file=$OPTARG;;
		\?) usage
		    exit;;
		esac
	done
	OPTIND=1
	#echo "g_newline = $g_newline"
}

#
# validate parameter
#
check_param() {
	test -z "$g_file" && usage && exit 1
	if [[ ! -f $g_file ]]; then
		echo "Not being able to process $g_file"
		exit 1
	fi
}


#
# process file replacement
#
do_action() {
	#cat cx231xx-audio.c | sed "s/\x0d/\\n/g" >cx231xx-audio1.c
	local tmp_file=/tmp/tmpfile_removeUP_M
	local process=0
	echo "     ### first few lines of $g_file follows ###"
	cat $g_file > $tmp_file
	head -n 7 $tmp_file
	echo
	echo -n "To process $g_file "
	test $g_newline -eq 1 && echo -n "w/ new-line replacement "
	echo -n "(y/n) ? "
	read ans

	case $ans in
	y*|Y*)  process=1;;
	*)  echo "...stop processing";;
	esac

	test $process -eq 0 && exit 1
	mv $g_file $g_file.bak
	if [[ $g_newline -eq 1 ]]; then
		cat $g_file.bak | sed "s/\x0d/\\n/g" > $g_file
	else
		cat $g_file.bak | sed "s/\x0d//g" > $g_file
	fi
}

############
### main ###
############
parse_param $@
check_param
do_action
<file_sep>#!/bin/bash

OK=0
CANCEL=1
ESC=255
BACKTITLE="Cody Blog - Example"

Menu(){
    while :
    do {
        Selection=$(dialog --title "CodyBlog - Menu" --clear \
            --backtitle "$BACKTITLE" \
            --cancel-label "Exit" \
            --menu "Choose one" 12 45 5 \
            one "Test 01" \
            two "Test 02" \
            2>&1 > /dev/tty)

        result=$?
        if [ $result -eq $OK ]; then
            Exit "$Selection selected !"
        elif [ $result -eq $CANCEL ] || [ $result -eq $ESC ]; then
            Exit
        fi
    } done
}


Exit(){
    clear
	if [ -z "$1" ]; then
    	echo "Program Terminated."
	else
		echo $1
	fi
    exit
}

Menu
