April 16, 2008

Playback local H.264 file by using flashplayer plugin

Flashplayer 9 Update 3 has H.264 support.

Here's a simple example to play local H.264 media file by using flashplayer plugin in your favorite browser.
Download (43KB)
Usage: Untar it and open flashmediaplayer.html in a browser window.

I used FLV Media Player.
Because of the security restriction of Flash, I can't use Javascript to interact the playback. I believe you can work out a better solution.

The FLV Media Player is licensed under a Creative Commons License.
It allows you to use, modify and redistribute the script for free for noncommercial purposes.

Posted by ginn at 5:12 PM | Comments (0)

March 27, 2008

Upgrading to Movable Type 4.1

Sorry for long time silence.
I'm too lazy to manage my site.

This is a test post for the new system.
Good luck!

Posted by ginn at 3:41 PM | Comments (1) | TrackBack (0)

November 12, 2007

Don't save chat history in my Gmail account

I've no idea Gmail saves all my chatting log with Gtalk until I tried to search something in my Gmail.

I was shocked, since actually I don't use Gtalk client but Adium, and I can't remember if there's a checkbox or notice somewhere before I signed up gtalk. Actually I thought gtalk service is tightly bundled with gmail service.

I don't want to keep the log, so I "googled" a solution. The solution said, there's a "Chat history:" setting in "Chat" tab of "Gmail Settings". Well, I spent 10 mins to find such tab, but I didn't see it because I was using Safari 2.

Poor me.

Posted by ginn at 6:34 PM | Comments (1)

Google Notifier dies on Mac OS X 10.5 (Leopard)

Google Notifier will crash after a few times of checking mails if you have proxy setting in system preferences.

An interesting bug. But I've no idea why Google still couldn't give a fix, Leopard is already out more than 2 weeks.

See also:

http://groups.google.com/group/Gmail-Problem-solving/browse_thread/thread/9bf2438144e4ec51

Posted by ginn at 4:35 PM | Comments (0)

August 15, 2007

Porting code from GCC to Sun Studio

Some problems you may not know.

1) Avoid using multi-character character constant
Code sample:


#include
int main()
{
const int a = 'ABCD';
printf("%x\n", a);
return 0;
}

You will get different result on Solaris x86 and SPARC if it is compiled with Sun Studio.
It's an endian issue.
On x86, result is "44434241"
On SPARC, result is "41424344"

If it is compiled with gcc, result is "41424344" for both platform.

gcc gives you a warning for this code, but Sun Studio doesn't.
Interesting.

You can use 'A' << 24 | 'B' << 16 | 'C' << 8 | 'D'

2) Avoid doing *x++ = foo(*x);
Code sample:


#include
int main()
{
char x[11] = "ABCDEFGHIJ";
char *ptr = x;
int i;
for (i = 0; i < 9; i++) {
*(ptr++) = *ptr + 1;
}
printf("%s\n", x);
return 0;
}

If it is compiled with gcc, g++, or cc (Sun Studio C compiler), the result is
BCDEFGHIJJ
But if it is compiled with CC (Sun Studio compiler), the result is
CDEFGHIJKJ

All code tested with Sun Studio 11 on OpenSolaris.

Posted by ginn at 6:09 PM | Comments (0)

August 3, 2007

Set a breakpoint at GNOME warning information

Just want to log here in case I forgot the function name again.
The function is g_logv().

Posted by ginn at 6:27 PM | Comments (0)

June 14, 2007

HOWTO: Backup your Mac OS X to nfs

First, you need to set up a nfs sharing.
I'm using a Solaris server.
Here're my steps.
Create a user with uid 501 (it's the default uid for first user on Mac OS X).
Create /export/home/mac, chmod 777 /export/home/mac
You can figure out how to give a proper mod/owner for /export/home/mac.
Since I'm restricting nfs access from certain machine, I don't care.

su
sharemgr create mygroup
sharemgr add-share -s /export/home/mac/ -r MAC mygroup
sharemgr set -P nfs -S sys -p root=macbookpro -p rw=macbookpro mygroup
sharemgr show
svcadm enable svc:/network/nfs/server:default

macbookpro is hostname of the Mac OS X client.

Then, try to mount it on Mac OS X
create /private/mnt/

sudo mount_nfs -o -P your_Solaris_machine:/export/home/mac /private/mnt/

create MBP_BACKUP directory in /private/mnt for a test.

Now, use rsync to backup your Mac OS X.
I assuming you're using Mac OS X 10.4, your rsync supports -E.

Create backup_excludes.txt to exclude some files.
Here's my version: (may not need to be that long)

automount/*
proc/*
dev/*
.Spotlight-V100/*
.Spotlight-V100/.*
.Trash/*
.Trashes/*/*
.hotfiles.btree
.journal
.journal_info_block
.vol
Desktop DB
Desktop DF
Library/Caches
System/Library/Caches
System/Library/Extensions.kextcache
Temporary Items
Users/*/Library/Caches/*
Volumes/*
cores/*
mach
mach.sym
private/Network/*
private/_Network_/*
private/automount/*
private/var/automount/*
private/var/db/BootCache.playlist
private/var/db/NetworkInterfaces.xml
private/var/db/volinfo.database
private/var/run
private/var/tmp/*
private/tmp/*
private/var/run/*
private/var/spool/postfix/*
private/var/vm/*
private/mnt/*

Here we go!

sudo rsync -E -a -x -S --delete --progress --exclude-from=backup_excludes.txt / /private/mnt/MBP_BACKUP/

You may want add "-u" for update.
Check rsync manpage for details.
It took my several hours for the first time sync.

Good luck!

BTW: How to sync back?

Update: It crashed to 4 Languages (system hang, kernel panic) when I tried to re-sync my disk. Might be a bug of rsync or nfs? I don't know how to solve it yet. Don't use -E and don't sync large files (>2G) seems fine.

Posted by ginn at 4:29 PM | Comments (2)