Skip to content

Instantly share code, notes, and snippets.

View benwei's full-sized avatar

ben6 benwei

View GitHub Profile
@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 / shell_script_path.sh
Last active March 24, 2020 11:42
get script's location path
t="${0%%`basename $0`}"; cd "$t" ; ABS_PATH=`pwd`
echo $ABS_PATH
@benwei
benwei / dict.sh
Created October 26, 2015 04:38
simple dictionary using curl with dict protocol
#!/bin/sh
## refernce http://www.dict.org/rfc2229.txt
word="$1"
if [ -z "$word" ]; then
echo "syntax: ./dict <word>"
exit 1
fi
curl "dict://dict.org/d:$word"
@benwei
benwei / vim-note01
Created July 6, 2014 13:16
vim search and replace binary characters by regular expression
/\%xnn characters (nn range is 00-FF)
%s/\%xnn//g -- replace all \xnn characters (nn range is 00-FF)
%s/\%unnnn//g -- replace all unicode code 'nnnn' characters, (nn range is 0000-FFFF)
@benwei
benwei / vimtips_regex01
Last active August 29, 2015 13:59
vim tips
replace
test-keyworkd : anything ;
to
“test-keyworkd” :“anything”,
regex:
s/^\([ \t]*\)\([a-z-]*\):[ \t]*\(.*\);/\1"\2":"\3",/g
@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 / blink_by_serial_input_char_a.ino
Last active December 16, 2015 18:21
blink arduino's led (pin 13) by serial input with char 'a'
//
// SOIPAddress.c
//
/*
Copyright (c) 2013, Ben Wei
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
@benwei
benwei / git_over_ssh.md
Created April 1, 2013 10:59
git over ssh note

how to git over ssh

create a base repository

 $ mkdir -p testprj
 $ cd testprj
 $ git init --bare
@benwei
benwei / BWSpentTime.js
Created December 7, 2012 09:59
SpentTime class for node js
function SpentTime () {
this.reset = function () {
start = new Date();
}
this.diff = function () {
var now = new Date();
return (now.getTime() - start.getTime())
}
var start = new Date();
}