Skip to content

Instantly share code, notes, and snippets.

View carlos-wong's full-sized avatar

carlos carlos-wong

  • Lejurobot.com
  • china, shenzhen
View GitHub Profile
@carlos-wong
carlos-wong / python: query yes or not
Created April 17, 2013 05:42
python: yes or not
def query_yes_no(question, default="yes"):
"""Ask a yes/no question via raw_input() and return their answer.
"question" is a string that is presented to the user.
"default" is the presumed answer if the user just hits <Enter>.
It must be "yes" (the default), "no" or None (meaning
an answer is required of the user).
The "answer" return value is one of "yes" or "no".
"""
@carlos-wong
carlos-wong / git: submodules fetch every modules
Created April 17, 2013 05:59
git: submodules fetch every modules
git submodule foreach git fetch
@carlos-wong
carlos-wong / bash: dd progress
Created April 17, 2013 08:03
bash: dd progress and set dd size if need
pv -tpreb /dev/urandom | dd of=file.img
sudo pv /dev/sdc | dd of=~/workspace/snk_5_2.img bs=1M count=1850 iflag=fullblock
@carlos-wong
carlos-wong / cscope_wiht_python.txt
Last active November 25, 2016 16:10
bash: cscope work with pyhon
Change to the top directory of your python code. Create a file called cscope.files:
find . -name '*.py' > cscope.files
cscope -R
You may need to perform a cscope -b first if the cross references don't get built properly.
@carlos-wong
carlos-wong / python: struct pack char.txt
Created April 20, 2013 06:38
python: struct pack char
struct.pack('c', '\x00')
@carlos-wong
carlos-wong / sensor.c
Created April 20, 2013 06:49
C: #marco print a value with format
#define PRINT_VALUE(a,b) \
printk("%s():%d " #b "is " #a "\n",__func__,__LINE__,b)
@carlos-wong
carlos-wong / *scratch*.el
Created April 20, 2013 06:54
Emacs: max frame on macos
(maximize-frame)
@carlos-wong
carlos-wong / index.html
Created April 28, 2013 06:29
javascript: run function when page onload
<body onload="function('')">
function updateImage(url)
{
<!-- alert(url); -->
if(newImage.complete) {
document.getElementById("theText").src = newImage.src;
newImage = new Image();
newImage.src = "/media/picture/245.jpg";
httpGet(url);
}
@carlos-wong
carlos-wong / index.html
Created April 28, 2013 06:30
javascript: pass parameter to setTimerout
setTimeout(updateImage, 10000, url);
@carlos-wong
carlos-wong / tar.txt
Created April 28, 2013 07:33
tar: show progress when uncompress file
pv file.tgz | tar xzf - -C target_directory