Skip to content

Commit 5b7a396

Browse files
committed
lmde: add java-utils
1 parent ad6b021 commit 5b7a396

File tree

23 files changed

+1031
-13
lines changed

23 files changed

+1031
-13
lines changed

.vimrc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ let g:EasyGrepFilesToExclude=".git,build,tags,*.bak,*.o,*.s,*.exe"
33
let g:EasyGrepRoot = "search:.git"
44
set wildignore=*.swp,.gitignore
55
"https://gist.github.com/seyDoggy/613f2648cebc6c7b456f
6-
unlet g:ctrlp_custom_ignore
7-
unlet g:ctrlp_user_command
6+
"unlet g:ctrlp_custom_ignore
7+
"unlet g:ctrlp_user_command
88
" set your own custom ignore settings
99
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.o,tags
1010
let g:ctrlp_custom_ignore = {
@@ -50,7 +50,6 @@ let g:diminactive_use_colorcolumn = 0
5050
let g:ctrlp_clear_cache_on_exit = 1
5151
let g:tagbar_ctags_bin = "ctags"
5252

53-
source ~/conf/vim/.coding.style.vimrc
5453
nmap <leader>tr :CtrlPClearCache<CR>
5554
nmap <leader>tm :LeaderfFunction<CR>
5655
@@ -79,6 +78,4 @@ let g:ale_c_incs = [
7978
\ '/usr/include/lua5.1'
8079
\]
8180
call SetupC99Incs()
82-
let g:ale_c_clangtidy_options = " -- " . g:ale_c_clang_options
83-
let g:ale_cpp_clangtidy_options = " -- " . g:ale_cpp_clang_options
8481

scons/SConstruct

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import SCons
44

55
home_dir = os.environ['HOME']
66
env = Environment(BUILDROOT="build",
7-
CCFLAGS=['-g', '-std=gnu99', '-O2', '-Wall', \
7+
CCFLAGS=['-g', '-std=gnu99', '-O2', '-Wall', \
88
'-Wno-format-truncation', '-Wno-unused-label', \
9+
'-Wno-unused-but-set-variable', \
910
'-I./', \
1011
])
1112
env.Decider('timestamp-newer')
@@ -26,14 +27,16 @@ conf = Configure(env, custom_tests = { 'CheckPKGConfig' : CheckPKGConfig,
2627
'CheckPKG' : CheckPKG })
2728

2829
#if not conf.CheckPKG('gtk+-2.0 >= 2.4.9'):
29-
pkg_deps = ['check', 'hiredis', ]
30+
pkg_deps = ['check', 'hiredis', 'libldns']
3031

3132
for pkg in pkg_deps:
3233
if not conf.CheckPKG(pkg):
3334
print( '%s not found.' % pkg)
3435
Exit(1)
3536

3637
for pkg in pkg_deps:
38+
d = env.ParseFlags('!pkg-config --cflags --libs %s' % pkg)
39+
env.MergeFlags(d)
3740
env.ParseConfig('pkg-config --cflags --libs %s' % pkg)
3841

3942
env.top_dir = os.getcwd()

scons/src/SConscript

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@ Import("env")
33
env.Program(target=env.top_dir+'/build/t.out', source=[ './t.c' ],
44
LIBS=[env.lib_logger]
55
)
6+
env.Program(target=env.top_dir+'/build/ldns.out', source=[ './ldns.c' ],
7+
LIBS=[env.lib_logger, 'ldns']
8+
)
69
#Return(logger_lib)

socks5-proto/dump-socks5-proto.lua

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env lua52
1+
#!/usr/bin/env lua
22

33
local _xprint = require ("commons.print")
44
local dump = require 'pl.pretty'.dump
@@ -31,7 +31,11 @@ local CONN_ERRORS = {
3131
local s = socket.tcp()
3232
local function init_socks5_server()
3333
s = socket.tcp()
34-
assert(s:connect("127.0.0.1", 1080), "connect fail")
34+
socks5_host = "192.168.1.8"
35+
socks5_port = 10832
36+
37+
assert(s:connect(socks5_host, socks5_port), "connect fail")
38+
xprint("... socks5 server=%s:%d\n", socks5_host, socks5_port)
3539
-- step(1): init authentification
3640
local auth_req = char(SOCKS5, NUMBER_OF_AUTH_METHODS, NO_AUTHENTICATION)
3741
s:send(auth_req)
@@ -44,6 +48,12 @@ local function init_socks5_server()
4448
dump_hex_inline("[s00]ack_auth ", auth_response)
4549
end
4650

51+
local function sprint(fmt, ...)
52+
local line=_G.sprint(fmt, ...)
53+
print(line)
54+
end
55+
56+
4757
local function connect_hostname(host)
4858
local host_length = #host
4959
local port = 80
@@ -60,6 +70,9 @@ local function connect_hostname(host)
6070
assert(nil, message)
6171
end
6272
dump_hex_inline("[s00]conn_ack ", conn_response)
73+
local ver = conn_response:byte(1)
74+
local rep = conn_response:byte(3)
75+
sprint("[s00]conn_ack : %s ver = 0x%02x connect_rep = %s", " ", ver, rep == 0x0)
6376
-- pop address
6477
local addr_type = s:receive(1)
6578
dump_hex_inline("[s00]addr_type", addr_type)
@@ -119,14 +132,14 @@ local function connect_ipv4(ip)
119132

120133
end
121134

122-
_G.xopts =
135+
_G.xopts =
123136
{
124-
decl =
137+
decl =
125138
{
126139
{ 'h' , "host" , true , "www.baidu.com", function(k,v) return v ;end } ,
127140
{ 'p' , "port" , true , 80, function(k,v) return k,v; end } ,
128141
{ 't' , "type" , true , "any", function(k,v) return k,v; end } ,
129-
{ 'd' , "debug" , false , true, function(k,v) return k,v; end }
142+
{ 'd' , "debug" , false , true, function(k,v) return k,v; end }
130143
},
131144
--options = {},
132145
--args = {}, -- remaining args
@@ -146,7 +159,11 @@ SECTION("... check connect socks5 server ..\n")
146159
init_socks5_server()
147160
print("")
148161
SECTION("... check connect hostname via socks5 server ..\n")
149-
connect_hostname("www.baidu.com")
162+
connect_hostname("[2001:da8:20d:7042::f2]")
163+
164+
print("")
165+
SECTION("... done ...\n")
166+
os.exit(0)
150167

151168
print("")
152169
s:close()

utils/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
target/*

utils/Makefile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
.PHONY : build help build clean app vmargs touch jdkflags
2+
3+
git-dir := $(shell git rev-parse --show-toplevel | tr -d '\n')
4+
5+
help:
6+
@echo "make [ build | classpath | touch | app | clean | jmh | vmargs | jdkflags"
7+
@echo ". ./etc/vscode/activate"
8+
9+
build:
10+
@./bin/cmp-src.sh target/javautils.jar ./src
11+
@free -h
12+
13+
14+
touch:
15+
@find ./src -name "*" -type f -exec touch {} \;
16+
17+
clean:
18+
@mvn clean
19+
20+
test:
21+
@mvn test
22+
23+
jdkflags:
24+
@java -XX:+PrintFlagsFinal -version | grep Threads
25+
26+
#java -cp ./target/javautils.jar com.nci.apps.App
27+
app:
28+
@java -cp $(shell cat cp.txt) com.nci.apps.App
29+
30+
classpath:
31+
@mvn exec:exec -Dexec.executable=echo -Dexec.args="%classpath"
32+
vmargs:
33+
java -cp ./target/benchmarks.jar com.bettercodebytes.Utils.IdentifyJvmArgs
34+

utils/bin/cmp-src.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
3+
target="$1"
4+
dir="$2"
5+
6+
fg_bright_yellow=''
7+
fg_reset=''
8+
9+
echo_hl()
10+
{
11+
echo -e ${fg_bright_yellow}$@ ${fg_reset} >&2
12+
}
13+
14+
new_file_list=""
15+
16+
run()
17+
{
18+
true && \
19+
echo_hl "found newer files: [$new_file_list]" && \
20+
mvn process-test-classes && touch $target
21+
exit 0
22+
}
23+
24+
LF='\n'
25+
! test -f $target && run && exit 0
26+
for file in "./pom.xml" $(find "$dir" -name "*.*")
27+
do
28+
test "$file" -nt "$target" && new_file_list+=" $file"
29+
done
30+
31+
if test -n "$new_file_list"; then
32+
echo "$new_file_list"
33+
echo -e "${fg_bright_yellow}found newer files:\n["
34+
for new_file in $new_file_list; do
35+
echo " $new_file"
36+
done
37+
echo -e "\n]${fg_reset}"
38+
39+
mvn process-test-classes && touch $target
40+
exit 0
41+
fi
42+
43+
echo_hl "every thing is clean"
44+
exit 0

utils/cp.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/home/leeyg/develop/poc/utils/target/classes:/home/leeyg/.m2/repository/org/codehaus/groovy/groovy/3.0.14/groovy-3.0.14.jar:/home/leeyg/.m2/repository/org/codehaus/groovy/groovy-ant/3.0.14/groovy-ant-3.0.14.jar:/home/leeyg/.m2/repository/org/apache/ant/ant/1.10.12/ant-1.10.12.jar:/home/leeyg/.m2/repository/org/apache/ant/ant-junit/1.10.12/ant-junit-1.10.12.jar:/home/leeyg/.m2/repository/org/apache/ant/ant-launcher/1.10.12/ant-launcher-1.10.12.jar:/home/leeyg/.m2/repository/org/apache/ant/ant-antlr/1.10.12/ant-antlr-1.10.12.jar:/home/leeyg/.m2/repository/org/codehaus/groovy/groovy-astbuilder/3.0.14/groovy-astbuilder-3.0.14.jar:/home/leeyg/.m2/repository/org/codehaus/groovy/groovy-cli-picocli/3.0.14/groovy-cli-picocli-3.0.14.jar:/home/leeyg/.m2/repository/info/picocli/picocli/4.6.3/picocli-4.6.3.jar:/home/leeyg/.m2/repository/org/codehaus/groovy/groovy-console/3.0.14/groovy-console-3.0.14.jar:/home/leeyg/.m2/repository/org/codehaus/groovy/groovy-datetime/3.0.14/groovy-datetime-3.0.14.jar:/home/leeyg/.m2/repository/org/codehaus/groovy/groovy-docgenerator/3.0.14/groovy-docgenerator-3.0.14.jar:/home/leeyg/.m2/repository/com/thoughtworks/qdox/qdox/1.12.1/qdox-1.12.1.jar:/home/leeyg/.m2/repository/org/codehaus/groovy/groovy-groovydoc/3.0.14/groovy-groovydoc-3.0.14.jar:/home/leeyg/.m2/repository/com/github/javaparser/javaparser-core/3.24.2/javaparser-core-3.24.2.jar:/home/leeyg/.m2/repository/org/codehaus/groovy/groovy-groovysh/3.0.14/groovy-groovysh-3.0.14.jar:/home/leeyg/.m2/repository/jline/jline/2.14.6/jline-2.14.6.jar:/home/leeyg/.m2/repository/org/codehaus/groovy/groovy-jmx/3.0.14/groovy-jmx-3.0.14.jar:/home/leeyg/.m2/repository/org/codehaus/groovy/groovy-json/3.0.14/groovy-json-3.0.14.jar:/home/leeyg/.m2/repository/org/codehaus/groovy/groovy-jsr223/3.0.14/groovy-jsr223-3.0.14.jar:/home/leeyg/.m2/repository/org/codehaus/groovy/groovy-macro/3.0.14/groovy-macro-3.0.14.jar:/home/leeyg/.m2/repository/org/codehaus/groovy/groovy-nio/3.0.14/groovy-nio-3.0.14.jar:/home/leeyg/.m2/repository/org/codehaus/groovy/groovy-servlet/3.0.14/groovy-servlet-3.0.14.jar:/home/leeyg/.m2/repository/org/codehaus/groovy/groovy-sql/3.0.14/groovy-sql-3.0.14.jar:/home/leeyg/.m2/repository/org/codehaus/groovy/groovy-swing/3.0.14/groovy-swing-3.0.14.jar:/home/leeyg/.m2/repository/org/codehaus/groovy/groovy-templates/3.0.14/groovy-templates-3.0.14.jar:/home/leeyg/.m2/repository/org/codehaus/groovy/groovy-test/3.0.14/groovy-test-3.0.14.jar:/home/leeyg/.m2/repository/org/codehaus/groovy/groovy-test-junit5/3.0.14/groovy-test-junit5-3.0.14.jar:/home/leeyg/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.9.1/junit-jupiter-api-5.9.1.jar:/home/leeyg/.m2/repository/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar:/home/leeyg/.m2/repository/org/junit/platform/junit-platform-launcher/1.9.1/junit-platform-launcher-1.9.1.jar:/home/leeyg/.m2/repository/org/junit/platform/junit-platform-engine/1.9.1/junit-platform-engine-1.9.1.jar:/home/leeyg/.m2/repository/org/junit/platform/junit-platform-commons/1.9.1/junit-platform-commons-1.9.1.jar:/home/leeyg/.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.9.1/junit-jupiter-engine-5.9.1.jar:/home/leeyg/.m2/repository/org/codehaus/groovy/groovy-testng/3.0.14/groovy-testng-3.0.14.jar:/home/leeyg/.m2/repository/org/testng/testng/7.5/testng-7.5.jar:/home/leeyg/.m2/repository/com/beust/jcommander/1.78/jcommander-1.78.jar:/home/leeyg/.m2/repository/org/webjars/jquery/3.5.1/jquery-3.5.1.jar:/home/leeyg/.m2/repository/org/codehaus/groovy/groovy-xml/3.0.14/groovy-xml-3.0.14.jar:/home/leeyg/.m2/repository/com/esotericsoftware/kryo/5.3.0/kryo-5.3.0.jar:/home/leeyg/.m2/repository/com/esotericsoftware/reflectasm/1.11.9/reflectasm-1.11.9.jar:/home/leeyg/.m2/repository/org/objenesis/objenesis/3.2/objenesis-3.2.jar:/home/leeyg/.m2/repository/com/esotericsoftware/minlog/1.3.1/minlog-1.3.1.jar:/home/leeyg/.m2/repository/org/projectlombok/lombok/1.18.24/lombok-1.18.24.jar:/home/leeyg/.m2/repository/org/projectlombok/test/test-maven-lombok/1.18.20.0/test-maven-lombok-1.18.20.0.jar:/home/leeyg/.m2/repository/javax/validation/validation-api/2.0.1.Final/validation-api-2.0.1.Final.jar:/home/leeyg/.m2/repository/javax/xml/bind/jaxb-api/2.3.1/jaxb-api-2.3.1.jar:/home/leeyg/.m2/repository/javax/activation/javax.activation-api/1.2.0/javax.activation-api-1.2.0.jar:/home/leeyg/.m2/repository/org/slf4j/slf4j-api/1.7.7/slf4j-api-1.7.7.jar:/home/leeyg/.m2/repository/ch/qos/logback/logback-core/1.1.7/logback-core-1.1.7.jar:/home/leeyg/.m2/repository/ch/qos/logback/logback-access/1.1.7/logback-access-1.1.7.jar:/home/leeyg/.m2/repository/ch/qos/logback/logback-classic/1.1.7/logback-classic-1.1.7.jar:/home/leeyg/.m2/repository/org/apache/commons/commons-lang3/3.14.0/commons-lang3-3.14.0.jar:/home/leeyg/.m2/repository/com/github/oshi/oshi-core/6.4.11/oshi-core-6.4.11.jar:/home/leeyg/.m2/repository/net/java/dev/jna/jna/5.14.0/jna-5.14.0.jar:/home/leeyg/.m2/repository/net/java/dev/jna/jna-platform/5.14.0/jna-platform-5.14.0.jar:/home/leeyg/.m2/repository/com/github/jknack/handlebars/4.3.1/handlebars-4.3.1.jar:/home/leeyg/.m2/repository/com/google/guava/guava/33.0.0-jre/guava-33.0.0-jre.jar:/home/leeyg/.m2/repository/com/google/guava/failureaccess/1.0.2/failureaccess-1.0.2.jar:/home/leeyg/.m2/repository/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar:/home/leeyg/.m2/repository/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar:/home/leeyg/.m2/repository/org/checkerframework/checker-qual/3.41.0/checker-qual-3.41.0.jar:/home/leeyg/.m2/repository/com/google/errorprone/error_prone_annotations/2.23.0/error_prone_annotations-2.23.0.jar:/home/leeyg/.m2/repository/com/google/j2objc/j2objc-annotations/2.8/j2objc-annotations-2.8.jar

utils/etc/vscode/activate

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# This file must be used with "source bin/activate" *from bash*
2+
# you cannot run it directly
3+
4+
deactivate () {
5+
# reset old environment variables
6+
if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
7+
PATH="${_OLD_VIRTUAL_PATH:-}"
8+
export PATH
9+
unset _OLD_VIRTUAL_PATH
10+
fi
11+
if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
12+
PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"
13+
export PYTHONHOME
14+
unset _OLD_VIRTUAL_PYTHONHOME
15+
fi
16+
17+
if [ -n "${JAVA_HOME:-}" ] ; then
18+
unset JAVA_HOME
19+
unset JRE_HOME
20+
unset CLASSPATH
21+
unset MAVEN
22+
unset OLDPATH
23+
unset JAVAPATH
24+
unset http_proxy
25+
unset https_proxy
26+
fi
27+
28+
29+
# This should detect bash and zsh, which have a hash command that must
30+
# be called to get it to forget past commands. Without forgetting
31+
# past commands the $PATH changes we made may not be respected
32+
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
33+
hash -r
34+
fi
35+
36+
if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
37+
PS1="${_OLD_VIRTUAL_PS1:-}"
38+
export PS1
39+
unset _OLD_VIRTUAL_PS1
40+
fi
41+
42+
unset VIRTUAL_ENV
43+
if [ ! "$1" = "nondestructive" ] ; then
44+
# Self destruct!
45+
unset -f deactivate
46+
fi
47+
}
48+
49+
# unset irrelevant variables
50+
deactivate nondestructive
51+
52+
VIRTUAL_ENV="/home/leeyg/conf/vscode"
53+
export VIRTUAL_ENV
54+
55+
_OLD_VIRTUAL_PATH="$PATH"
56+
57+
58+
JAVA_MAJOR_VERSION=17
59+
60+
export JAVA8_HOME=/opt/jdk8u352-b08
61+
export JAVA11_HOME=/usr/lib/jvm/java-11-openjdk-amd64
62+
export JAVA17_HOME=/opt/jdk-17.0.5+8
63+
64+
case $JAVA_MAJOR_VERSION in
65+
8)
66+
export JAVA_HOME="${JAVA8_HOME}";;
67+
11)
68+
export JAVA_HOME="${JAVA11_HOME}";;
69+
17)
70+
export JAVA_HOME="${JAVA17_HOME}";;
71+
*)
72+
export JAVA_HOME="${JAVA17_HOME}";;
73+
esac
74+
75+
76+
#export JAVA_HOME=$JAVA17_HOME
77+
export JRE_HOME=$JAVA_HOME/jre
78+
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/lib:$CLASSPATH
79+
export MAVEN=/opt/apache-maven-3.8.6
80+
export OLDPATH=$PATH
81+
export JAVA_PATH=$JAVA_HOME/bin:$MAVEN/bin:$JAVA_HOME/bin
82+
export https_proxy=http://192.168.1.4:10804
83+
export http_proxy=http://192.168.1.4:10804
84+
85+
PATH="$JAVA_PATH:$PATH"
86+
export PATH
87+
88+
# unset PYTHONHOME if set
89+
# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
90+
# could use `if (set -u; : $PYTHONHOME) ;` in bash
91+
if [ -n "${PYTHONHOME:-}" ] ; then
92+
_OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
93+
unset PYTHONHOME
94+
fi
95+
96+
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
97+
_OLD_VIRTUAL_PS1="${PS1:-}"
98+
if [ "x(vscode) " != x ] ; then
99+
PS1="(vscode-${JAVA_MAJOR_VERSION}) ${PS1:-}"
100+
else
101+
if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then
102+
# special case for Aspen magic directories
103+
# see http://www.zetadev.com/software/aspen/
104+
PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1"
105+
else
106+
PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1"
107+
fi
108+
fi
109+
export PS1
110+
fi
111+
112+
# This should detect bash and zsh, which have a hash command that must
113+
# be called to get it to forget past commands. Without forgetting
114+
# past commands the $PATH changes we made may not be respected
115+
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
116+
hash -r
117+
fi

utils/make.aliases

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
alias build='make build'
2+
alias clean='make clean'
3+
alias test='make test'
4+
alias help='make help'
5+
alias run='make app'
6+
alias classpath='make classpath'
7+
alias touch='make touch'
8+
alias vmargs='make vmargs'
9+
alias jdkflags='make jdkflags'
10+
alias emc='emacsclient -c'

0 commit comments

Comments
 (0)