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 / makefile
Created Feb 3, 2012
membuddy.c & makefile
View makefile
#This is a dummy code for Buddy memory allocation implementation.
all: $(BINNAME)
benwei /
Created Jul 3, 2012
closure sample h4
# reference:
def counter():
d = {'x': 0} # tested with python 2.7.2
def increment(y=1):
# nonlocal only work for python3
#nonlocal x
d['x'] += y
benwei / yd
Created Nov 27, 2012
yd script is a simple wrapper while cache read word for ydict
View yd
mkdir -p "$YD_HIST_DIR/_relation/"
echo "$@" >> "${YD_HIST_DIR}"/_words.txt
if [ ! -f "$WordCacheFile" ]; then
ydict -u -w "$@" | sed -e "s/'/'/g" -e "s/\(.\[36m\)[ ]*/\1 /g" > "$WordCacheFile"
benwei / regex_fun.js
Created Nov 27, 2012
convert function to that.func (javascript)
View regex_fun.js
// regexp
// convert
// function a (a1,a2)
// that.a = function (a1, a2)
cat jsfile.js | sed -e 's/^\([ \t]*\)function[ \t]*\([a-zA-Z]*\)(/\1that.\2 = function (/g'
benwei / BWSpentTime.js
Created Dec 7, 2012
SpentTime class for node js
View BWSpentTime.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();

how to git over ssh

create a base repository

 $ mkdir -p testprj
 $ cd testprj
 $ git init --bare
View SOIPAddress.c
// 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 / blink_by_serial_input_char_a.ino
Last active Dec 16, 2015
blink arduino's led (pin 13) by serial input with char 'a'
View blink_by_serial_input_char_a.ino
benwei /
Created Jul 16, 2013
one line to list line count of c file
find -name "*.c" | while read fn ; do wc -l $fn ; done
View vimtips_regex01
test-keyworkd : anything ;
“test-keyworkd” :“anything”,
s/^\([ \t]*\)\([a-z-]*\):[ \t]*\(.*\);/\1"\2":"\3",/g
You can’t perform that action at this time.