$ mkdir -p testprj
$ cd testprj
$ git init --bare
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) |
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
#!/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
// 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
function SpentTime () { | |
this.reset = function () { | |
start = new Date(); | |
} | |
this.diff = function () { | |
var now = new Date(); | |
return (now.getTime() - start.getTime()) | |
} | |
var start = new Date(); | |
} |
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
// | |
// 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. |
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
int led = 13; | |
void setup() | |
{ | |
Serial.begin(9600);//设置波特率为9600bps | |
pinMode(led, OUTPUT); | |
} | |
void turnon_led() { |
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 | |
find -name "*.c" | while read fn ; do wc -l $fn ; done |
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
replace | |
test-keyworkd : anything ; | |
to | |
“test-keyworkd” :“anything”, | |
regex: | |
s/^\([ \t]*\)\([a-z-]*\):[ \t]*\(.*\);/\1"\2":"\3",/g |
OlderNewer