La Vita è Bella
Monday, November 19, 2007
AFP versus SMB
I have a Linux file server in my home running Debian Lenny, and I always use SMB for file sharing, it have a very very bad performance. Today I suddenly remember Apple have an AFP protocol, so gave it a try.
I use "apt-cache search afp" to find out that there's a package named "netatalk" can provide AFP file sharing, so install it. But I can only login use guest account, not my system user, from Leopard.
I googled it and found that the problem is: on the Debian side, as a license issue, the Debian package didn't come with SSL support; on the Leopard side, it didn't allow you exchange your password with AFP server without SSL. So the solution is build netatalk yourself, with SSL.
The building steps are described on this blog, and I also disabled atalkd as the author suggested, it caused netatalk to start-up much faster than before.
So finally I got a AFP server for my Mac (compare this icon to the famous BSOD icon for SMB servers in Leopard
):
And as expected, AFP is much much faster than SMB, here's the write test:
For AFP:
fishy@McManaman:~$ dd if=/dev/zero of=/Volumes/Home\ Directory/foo ^C57345+0 records in 57345+0 records out 29360640 bytes (29 MB) copied, 11.0833 s, 2.6 MB/s
And for SMB:
fishy@McManaman:~$ dd if=/dev/zero of=/Volumes/fishy/bar ^C4235+0 records in 4235+0 records out 2168320 bytes (2.2 MB) copied, 10.6889 s, 203 kB/s
I'm impressed!
tags: mac, osx, linux, debian, afp, netatalk, leopard
22:38:32 by fishy - linux - Permanent Link
4 comments - no trackbacks yet - karma: 5 [+/-]
Wednesday, August 01, 2007
The reversed diff
We use diff to find out the different lines in 2 files, but sometimes we also need to find out the same lines in 2 files. So we need the "reversed diff"
And this command can be used as the reversed diff:
cat file1 file2 | sort | uniq -d
tags: diff, uniq, linux, shell, same
17:55:56 by fishy - linux - Permanent Link
Wednesday, March 21, 2007
Bash script: batch resize your photos
If you toke some photos by your camera, and want to post them to somewhere (for example, I want to post the photo of my Treo 650 because I'm going to sell it), you may need to batch resize your photos.
This bash script shows how to uses ImageMagick to batch resize your photos:
1 #!/bin/sh
2
3 for file in *.JPG; do
4 convert -resize 1024x768 $file ${file%.JPG}_resize.jpg
5 done
tags: batch, resize, imagemagick, bash, script
21:28:36 by fishy - linux - Permanent Link
Tuesday, March 20, 2007
Note: set proxy for wget
wget -Y -e "http_proxy=host:port" url
"How to set proxy for wget?" I've been asked this question for many times, but it seems didn't appears in the "-h" output nor man page, so I always forgot it.
That's why I'm making a note here
tags: wget, proxy, linux, note
00:42:01 by fishy - linux - Permanent Link
4 comments - no trackbacks yet - karma: 3 [+/-]
Friday, March 02, 2007
Some (not so many) handy aliases
Under my Debian Linux, when I use screen, I always get some keymap/TERM setting problems, for example, the backspace key never work.
But if I set TERM to "vt100" before launch screen, it's OK, so this alias can resolve the problem:
alias screen='env TERM=vt100 screen'
For the poor network, I always need a multi-thread http downloader. Firefox has a extension DownThemAll!, but after I finish surfing websites (but didn't finish downloading yet), I used to press Command+Q to quit Firefox, and the download was interrupted. lftp has a built-in downloader: pget, so use pget is a good idea:
alias pget="lftp -c pget"
Put the codes into your bashrc file, and restart your terminal, it's done.
tags: alias, bash, screen, pget, lftp
21:25:26 by fishy - linux - Permanent Link
Thursday, December 07, 2006
Make sure your often crash daemon is still running
I have used my old lap-top as a home server. Cause I'm using ADSL at home, I have to use a dynamic DNS.
I choosed a Chinese dynamic DNS provider "Peanut Shell", they've provided a Linux client to commit your IP.
But the Linux client they provided is close-source and often crashes. After it crashed, my domain name can't be kept up-to-date.
So I have to write a script to make sure it's still running:
1 #!/bin/sh
2 pid=`pidof phlinux`
3 if [ -z "$pid" ]; then
4 echo "phlinux not running, start it as daemon now..." >&2
5 /usr/local/phlinux/phlinux -d
6 else
7 echo "phlinux is running"
8 fi
Save this script in some place, and make a link to your "/etc/cron.hourly", so it will be checked every hour.
UPDATED: or maybe you don't want to get mail report on every check, I've updated the script, and you should write a script in your "/etc/cron.hourly" instead of link the script, and writes "/path/to/your/script > /dev/null"
tags: ph, daemon, crash, dyn-dns
13:41:50 by fishy - linux - Permanent Link
Tuesday, January 10, 2006
Script: mp32ogg
I wrote this script to convert mp3 files into ogg files. ogg is a open source audio format that is smaller and seems better than mp3.
Another reason I wrote it is that the audio player for PalmOS, AeroPlayer, is free with ogg plug-in. But the mp3 plugin is not free.
You'll need the following softwares to use this script: mplayer, oggenc, id3v2, iconv. If you are using Debian or Ubuntu, you can apt-get them. iconv is used to conver id3 tags that in GB18030 into UTF-8, if you don't need such feature, you can ignore it, and comment line 9.
It will convert all files under current directory into ogg, and try to keep the tag info. It will try id3v2 first, then id3v1.
It first use mplayer to dump mp3 file into wav file, then use oggenc to convert wav file into ogg file.
It can be ran with a parameter, to specify the ogg quality. If omitted, it's 2.
It's based on the script by stoneboy @ newsmth forum. My work is try to keep tag info.
00:49:50 by fishy - linux - Permanent Link
Tuesday, December 13, 2005
Backup script for Palm
Here's my backup script for my Treo 650, it can keep 1 weeks backup archives:
1 #!/bin/sh
2
3 cd ~/palm
4 pilot-xfer -s backup
5 ARCNAME=backup-`LC_ALL=C date +%Y%m%d-%a`.tar.bz2
6 rm -f backup*`LC_ALL=C date +%a`*.tar.bz2
7 tar jcfv ${ARCNAME} backup/
8
tags: linux, backup, palm
23:39:32 by fishy - linux - Permanent Link
Tuesday, November 29, 2005
Got the Ubuntu free CDs!
Just received my Ubuntu free shipped CDs! (Although I've already used Kubuntu for weeks -__-)
Here're the photos:
tags: ubuntu, cd, linux
18:06:44 by fishy - linux - Permanent Link
Monday, February 07, 2005
Linux Note: Change console resolution
Just change the grub setting(the file "/boot/grub/menu.lst", or press "e" in grub menu), add "vga=xxx" to the end of the "kernel" line, which xxx is a number to define the resolution as the following table:
| depth | 640*480 | 800*600 | 1024*768 | 1280*1024 |
|---|---|---|---|---|
| 8-bit | 769 | 771 | 773 | 775 |
| 15-bit | 784 | 787 | 790 | 793 |
| 16-bit | 785 | 788 | 791 | 794 |
| 24-bit | 786 | 789 | 792 | 795 |
I've picked 792 for 24-bit 1024*768, and see the wonderful cute console
But maybe 24-bit is a waste for console, maybe I should pick 773 or 790.
tags: linux, resolution, console
01:29:00 by fishy - linux - Permanent Link










