This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
YD_HIST_DIR="${HOME}/.ydict_history" | |
mkdir -p "$YD_HIST_DIR/_relation/" | |
echo "$@" >> "${YD_HIST_DIR}"/_words.txt | |
WordCacheFile="${YD_HIST_DIR}"/"$@".txt | |
WordRelationFile="${YD_HIST_DIR}"/_relation/"$@".txt | |
if [ ! -f "$WordCacheFile" ]; then | |
ydict -u -w "$@" | sed -e "s/'/'/g" -e "s/\(.\[36m\)[ ]*/\1 /g" > "$WordCacheFile" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# reference: | |
# http://stackoverflow.com/questions/3190706/nonlocal-keyword-in-python-2-x | |
# http://en.wikipedia.org/wiki/Closure_(computer_science)#Example | |
# | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#http://en.wikipedia.org/wiki/Buddy_memory_allocation | |
#This is a dummy code for Buddy memory allocation implementation. | |
CFLAGS=-DHAVE_DEV_SYS | |
LDFLAGS= | |
CFILES=membuddy.c | |
OBJS=$(CFILES:.c=.o) | |
BINNAME=membuddy | |
all: $(BINNAME) |
NewerOlder