-- Good software makes life easier

a site about firmware, x86, masm, asm, OS, windows, pc architecture.


I shared in another earlier post a dirty tick to change directory to where the batch file is located; this is useful when you want to run your batch file from any directory prompt;


The trick is one single line:

cd /d %0\..

However, this has some limitations.

It is more often than not when you release your batch file in a network shared directory, and your end user want to run directly from there (i.e. without copying to local disk); if the drive is not mapped to the local system, you will be caught in surprise when running the above line.

The error is "CMD does not support UNC paths as current directories";

The hack is simple -- another magic line:

pushd %~dp0

failed design
November 29th, 2013 01:55

a wall socket with two receptacles, however, no enough spaces in between.

a "Function" key which will always be mistaken as CTRL.

a "smart" design which winds 2 pieces together to save space, however, very fragile

a notebook which is very hard to write on the left side

a toilet seat (think....)

even harder one (think...)

a RJ45 socket which always blocks mouse movement

a airplane passenger seat where there is no place for legs

a shirt which customer always have to cut the brand labels

usage tips for Linux
November 6th, 2012 08:30
# to search for a key word in files with certain extension
find . -iname "*.cc" -exec grep -Hin "thekeyword" {} \;
# -i to ignore case
# -H will print out the file name which matches to the filter
# -n will print out the matching line number

#if you want to use some filter containing escape char, use single quote
find . -name "*.cc" -exec grep 'setData(\"Pass'  {}\;

#to count the number of occurrence of certain word/pattern in vim

# to count number of files in a directory
find . -type f | wc -l

# to change command prompt to { $user_name+@+$hostname +":" + $cwd> }
set prompt="\n%{\033[0;32m%}%n@%m:%{\033[0;33m%}%~%{\033[1;30m%}>%{\033\[1;37m%} "

# to use backspace to delete
stty erase ^H

# to pipe error and cout to file; for tcsh and csh only
./genKB_DA.sh >& ./log.txt

# about FTP downloading
use 'hash' to show download progress
use 'prompt' to turn off the 'y/n' prompt which blocks mget

# to check linux kernel version
uname -r

# to check red-hat version
cat /etc/redhat-release

# log in first as 'test' user, and then type the following to allow any user to access current x11 display
xhost +localhost

# to batch delete files based on strings in a file
xargs rm < ../fxxTN1.txt
    svn related
    September 6th, 2012 04:08
    Frequently svn commands

    1. svn up
    2. svn add/delete
    3. svn update -r 1234  (this is to revert local copy to certain revision instead of head revision)
    4. svn revert --recursive .  (this is revert all local changes)
    5. svn diff* svn cleanup
    6. svn status | grep ^\? | cut -c9- | xargs -d \\n rm -r  (this will remove all unversioned files and folders from local copy)

    How to properly add new files to svn repository?

    • never never copy-n-paste a existing folder in your svn checkout; by doing so, you are copying the svn meta data together with source code, and potentially screw up your local copy completely.
    • the right way is to create a new folder manually and then copy source files into it.
    • next, use 'svn add' to schedule them for checking in.
    • until then, 'svn diff' will correctly reflect all your local changes including file addition and deletion.

    Creating and applying patch

    • svn diff >mypatch.diff
    • patch -p0 -i mypatch.diff