Posted on February 25, 2010. Filed under: C/C++, Linux, Mac, Windows | Tags: , , |

Netscape Plugin Application Programming Interface (NPAPI) is a cross-platform plugin architecture used by many web browsers.

It was first developed for the Netscape family of browsers starting with Netscape Navigator 2.0 but has subsequently been implemented in other browsers including Mozilla Application Suite, Mozilla Firefox, Safari, Google Chrome, Opera, Konqueror, and some older versions of Microsoft Internet Explorer.

Its success can be partly attributed to its simplicity. A plugin declares that it handles certain content types (e.g. “audio/mp3”) through exposed file information. When the browser encounters such content type it loads the associated plugin, sets aside the space within the browser content for the plugin to render itself and then streams data to it. The plugin is then responsible for rendering the data as it sees fit, be it visual, audio or otherwise. So a plugin runs in-place within the page, as opposed to older browsers that had to launch an external application to handle unknown content types.

The API requires each plugin to implement and expose a comparatively small number of functions. There are approximately 15 functions in total for initializing, creating, destroying, and positioning plugins. The NPAPI also supports scripting, printing, full screen plugins, windowless plugins and content streaming.


Read Full Post | Make a Comment ( 1 so far )

BASH Shell: For Loop File Names With Spaces

Posted on November 20, 2009. Filed under: Linux, Mac, Shell | Tags: , , , , , , |

BASH for loop works nicely under UNIX / Linux / Windows and OS X while working on set of files. However, if you try to process a for loop on file name with spaces in them you are going to have some problem. for loop uses $IFS variable to determine what the field separators are. By default $IFS is set to the space character. There are multiple solutions to this problem.

Set $IFS variable

Try it as follows:

IFS=$(echo -en "\n\b")
for f in *
  echo "$f"


IFS=$(echo -en "\n\b")
# set me
for f in $FILES
  echo "$f"
# restore $IFS

More examples using $IFS and while loop

Now you know that if the field delimiters are not whitespace, you can set IFS. For example, while loop can be used to get all fields from /etc/passwd file:

while IFS=: read userName passWord userID groupID geCos homeDir userShell
      echo "$userName -> $homeDir"
done < /etc/passwd

Using old good find command to process file names

To process the output of find with a command, try as follows:

find . -print0 | while read -d $'' file
  echo -v "$file"

Try to copy files to /tmp with spaces in a filename using find command and shell pipes:

find . -print0 | while read -d $'' file; do cp -v "$file" /tmp; done

Processing filenames using an array

Sometimes you need read a file into an array as one array element per line. Following script will read file names into an array and you can process each file using for loop. This is useful for complex tasks:


# failsafe - fall back to current directory
[ "$DIR" == "" ] && DIR="." 

# save and change IFS

# read all file name into an array
fileArray=($(find $DIR -type f))

# restore it

# get length of an array

# use for loop read all filenames
for (( i=0; i<${tLen}; i++ ));
  echo "${fileArray[$i]}"

Playing mp3s with spaces in file names

Place following code in your ~/.bashrc file:

	local o=$IFS
	IFS=$(echo -en "\n\b")
	/usr/bin/beep-media-player "$(cat  $@)" &

Keep list of all mp3s in a text file such as follows (~/eng.mp3.txt):

/nas/english/Adriano Celentano - Susanna.mp3
/nas/english/Nick Cave & Kylie Minogue - Where The Wild Roses Grow.mp3
/nas/english/Roberta Flack - Kiling Me Softly With This Song.mp3
/nas/english/The Beatles - Girl.mp3
/nas/english/John Lennon - Stand By Me.mp3
/nas/english/The Seatbelts, Cowboy Bebop - 01-Tank.mp3

To play just type:
$ mp3 eng.mp3.txt

Another example about IFS:


set $(cat my.file)

# Now the lines are stored in $1, $2, $3, …

echo $1
echo $2
echo $3
echo $4


Read Full Post | Make a Comment ( None so far )

iPhone Simulator Architectures.xcspec

Posted on September 5, 2009. Filed under: iPhone, Mac |

// 32-Bit
{ Type = Architecture;
Identifier = Standard;
Name = “Standard (iPhone Simulator: i386)”;
Description = “32-bit iPhone Simulator architectures”;
ListInEnum = YES;
SortNumber = 1;
RealArchitectures = ( i386, ppc );
ArchitectureSetting = “ARCHS_STANDARD_32_BIT”;

// Old-style Debug
{ Type = Architecture;
Identifier = Native;
Name = “Native Architecture of Build Machine”;
Description = “32-bit for build machine”;
ListInEnum = YES;
SortNumber = 101;
ArchitectureSetting = “NATIVE_ARCH”;

// G3
{ Type = Architecture;
Identifier = ppc;
Name = “Minimal (32-bit PowerPC only)”;
Description = “32-bit PowerPC “;
PerArchBuildSettingName = “PowerPC”;
ByteOrder = big;
ListInEnum = No;
SortNumber = 201;

// G4
{ Type = Architecture;
Identifier = ppc7400;
Name = “PowerPC G4”;
Description = “32-bit PowerPC for G4 processor”;
ByteOrder = big;
ListInEnum = NO;
SortNumber = 202;

// G5 32-bit
{ Type = Architecture;
Identifier = ppc970;
Name = “PowerPC G5 32-bit”;
Description = “32-bit PowerPC for G5 processor”;
ByteOrder = big;
ListInEnum = NO;
SortNumber = 203;

// Intel
{ Type = Architecture;
Identifier = i386;
Name = “Intel”;
Description = “32-bit Intel”;
PerArchBuildSettingName = “Intel”;
ByteOrder = little;
ListInEnum = NO;
SortNumber = 105;

Read Full Post | Make a Comment ( 1 so far )

Howto Install iPhone SDK 2.2.1 on PPC Mac

Posted on September 5, 2009. Filed under: iPhone, Mac |

NOTE: This method is faster and will not require a lot of work! Just follow the instructions and you won’t need to Google yourself  like with the other How Tos.

Are you like me with an old PPC Mac and you want to have fun with the iPhone SDK on it but you just can’t install it? Here’s how to do it:

First, download the OFFICIAL iPhone SDK from Apple’s website. It’s free, and it will just require you to register/login, every thing is free except if you want to become an iPhone developer, then it’s different. If you don’t want to register, you can try to use some logins from this site.

Figure 1


After downloading, open the mountable disk image (DMG) and copy the files (except the About file) into a new folder on your desktop, let’s call it “iPhone SDK PPC”. When the copy is done, right click on the “iPhone SDK” package (.mpkg) and choose “Show Package Contents”.

Figure 2


Then, go in the “Contents” folder, and right click the “iPhoneSDK.dist” file and open it with TextEdit located in your Applications folder or with your favorite text editor.

Figure 3


Search for the “agreedToSLA” function (function agreedToSLA()) at the end of that function, it should normally be written “return false;”, change that to “return true;”.

Figure 4


And finally, look for the “isIntel” function (function isIntel()), the first line should be like this:

“var res = (system.sysctl(’hw.byteorder’) == ‘1234′);”

Change the numeral part to “4321” so it finally look like:

“var res = (system.sysctl(’hw.byteorder’) == ‘4321′);”

Figure 5


Save and quit, load the installer and it should be installing the iPhone SDK now. Once the installation is done, you’ll probably want to compile apps. To do that, go to:


Figure 6


Locate and make a backup of the “iPhone Simulator Architectures.xcspec” file (you can simply copy and paste it in the same directory). After backing up replace your old file by this file.

Open up Xcode and you should be ready to go!

NOTE: and the author of this guide is NOT responsible for any problems caused by following the given steps. They are given as “help” and are NOT guaranteed to work. If you don’t want to follow the steps, or scared to break your computer,  get an Intel Mac.




3.iPhone SDK 2.2.1 (9m2621a)

4.iPhone SDK 2.2 (9m2621)

Read Full Post | Make a Comment ( None so far )

DNS host setting

Posted on June 22, 2007. Filed under: Linux, Mac, Services, Windows |

File locations:

1. Windows

Windows 95/98/Me c:\windows\hosts

Windows NT/2000/XP Pro c:\winnt\system32\drivers\etc\hosts

Windows XP Home c:\windows\system32\drivers\etc\hosts





Read Full Post | Make a Comment ( None so far )

Liked it here?
Why not try sites on the blogroll...