2010年4月26日 星期一

md5sum a directory

Generate:
find
(your-dir) -type f -print0 | xargs -0 md5sum >> (output-md5sume-file)

Verify:
md5sum -c (output-md5sum-file)


my example:

robert@robert-desktop ~/work/nbd-work/ttt $ ls
first second test

robert@robert-desktop ~/work/nbd-work/ttt $ find -type f -print0 | xargs -0 md5sum >> ~/Test/mydir.md5


robert@robert-desktop ~/work/nbd-work/ttt $ cat ~/Test/mydir.md5
d41d8cd98f00b204e9800998ecf8427e ./second
d41d8cd98f00b204e9800998ecf8427e ./first
7423d8fc12da81d779d0485b3d3fb67d ./test

robert@robert-desktop ~/work/nbd-work/ttt $ md5sum -c ~/Test/mydir.md5
./second: OK
./first: OK
./test: OK

robert@robert-desktop ~/work/nbd-work/ttt $ echo $?
0



2010年4月13日 星期二

Use djgpp to build a DOS program in dosemu (under Linux)

Topic: How to use djgpp to build a DOS program in DOSEmu (running in Linux) ?

1. Install dosemu

DOSEmu (dosemu HOWTO)

2. Download djgpp files for dosemu

DJGPP (this name comes from ... DJ's GNU Programming Platform)

Use DJGPP Zip File Picker to download what you need (select dosemu for Operating System)

3. Install djgpp into dosemu

Refer to "installation instructions for dosemu" shown in DJGPP Zip File Picker Results. Key points:

* unzip those *.zip files to ~/djgpp/ (~ is your home in Linux)
* edit ~/.dosemu/drvie_c/autoexec.bat :
set PATH=d:\djgpp\BIN;%PATH%
set DJGPP=d:\djgpp\DJGPP.ENV
(dosemu defaults D:\ to ~/)
* reboot dosemu

4. Compile a helloworld in dosemu
* Edit main.c and its Makefile in ~/helloworld/ under Linux
* Then in dosbox, cd D:\helloworld\ and try to make it !
(gcc -o helloworld.exe main.c)

2010年4月7日 星期三

stop on first error (gcc, make)

Just want to see the first compilation error ? Try this:

-> gcc main.c -Wfatal-errors


-Wfatal-errors
This option causes the compiler to abort compilation on the first
error occurred rather than trying to keep going and printing
further error messages.

Ref:
man gcc

2010年1月16日 星期六

grub rescue after re-partition by Windows

Situation:
I install Ubuntu9.10 (with grub loader) in /dev/sda10.
(My MBR bootloader is spfdisk)
Someday, I boot the system to Windows (/dev/sda2) and re-partition /dev/sda3 to NTFS.
After rebooting to Ubuntu9.10, a problem comes: some Windows program has changed the disk MBR and my Ubuntu9.10 is no more in /dev/sda10. It's in /dev/sda9 in the new MBR.

So when boot to /dev/sda9, grub can't find linux in /dev/sda10.
It is in /dev/sda9 now !



--------- in grub rescure, manually boot to /dev/sda9 -------

grub rescue>

set prefix=(hd0,9)/boot/grub

insmod (hd0,9)/boot/grub/linux.mod

----- now you can use [tab] auto-completion ---

set root=(hd0,9) linux /boot/vmlinuz26 root=/dev/sda9 initrd /boot/kernel26.img boot

----- this will boot to Ubuntu 9.10 ------

sudo update-grub
sudo grub-install /dev/sda9

(this will update your grub settings, esp. your boot menu,
so that you can boot normally into Ubuntu9.10 next time)


Reference:

2010年1月13日 星期三

generate a (pseudo) random number in sh

Print a pseudo-random byte (hex) in sh:

cat /dev/urandom | od -t x1 -A n -N 1

->89

-----------

Create a pseudo-random file of size 1 MB:
dd if=/dev/urandom of=a.log bs=1M count=1


Ref:

2010年1月1日 星期五

Install a New font in Ubuntu

For instance, I want to install a new font "Crisp" to my Ubuntu 9.10:


1. Create a new directory for your new font:

sudo mkdir /usr/share/fonts/truetype/crisp/

sudo cp ~/download/Crisp.ttf /usr/share/fonts/truetype/crisp/


2. Rebuild the font information files:

sudo fc-cache -f -v | grep -i crisp

-> /usr/share/fonts/truetype/crisp: caching, new cache contents: 1 fonts, 0 dirs


3. Restart the programs in which you want to use the new font.


--------
Ref:

2009年12月8日 星期二

Electronic circuits

Pull-up resistor

Pull-up resistors are used in electronic logic circuits to ensure that inputs to logic systems settle at expected logic levels if external devices are disconnected.

tri-state (vt)

When outputs are tri-stated (in the Hi-Z state) their influence on the rest of the circuit is removed, and the circuit node will be "floating" if no other circuit element determines its state.

連結

PLL (phase-locked loop)

A PLL is a control system that generates a signal that has a fixed relation to the phase of a "reference" signal.