Free Photoshop Book from SitePoint!

          0 votes
May 29th, 2008

SitePoint is giving away their Photoshop book which normally retails at $29.99 for absolutely free in PDF format for the next 14 days!

http://photoshop.aws.sitepoint.com

Just followed the link above, clicked the "Download Now" button on the page, and insert your email address to obtain the download link.

Share/Save/Bookmark

Star Ratings

          0 votes
May 22nd, 2008

I've added a little star rating system which isn't that fancy but its good enough :-) . You should notice them under the blog titles on the listing page and also in the full blog page. Please take the time to let me know what you think of my blogs by rating them with the new star system along with posting comments.

Thanks for reading,
Richard Sumilang

Share/Save/Bookmark

Friendly Cross-Site Scripting

          0 votes
May 14th, 2008

Recently I was faced with the issue of loading an iFrame from our main site to one of our child sites and they needed to communicate with each other through JavaScript. While developing on our test servers the problem wasn't obvious because everything was on the same domain but when it was near time to deploy on the production servers the shit hit the fan! The reason wasn't so obvious at first but luckily the solution wasn't very hard to implement, it was just a matter of finding it.

Welcome document.domain

Say we have a script at http://foo.mysite.com that needs to communicate with another friendly script at http://bar.mysite.com through means of an iFrame or something. By default your browsers' security won't let them because the full domains aren't the same same (including the sub-domain).

In order to allow both sub-domains to communicate together you must set the document.domain property in JavaScript to the same domain name. So in our case we would need to set the document.domain property on both sites to mysite.com which is the common domain between the two.

 
document.domain="mysite.com";

You can't however set both to foo.mysite.com or bar.mysite.com and you cannot set both of them to another domain such as mysite1.com or anything else. That's the limitation.

Hint: You could use this technique to share cookies across similar domains as well. When setting a cookie you can set it for the parent domain to be accessible from multiple sub-domains.

Be aware that setting this property incorrectly can compromise the security of your site. It is suggested to determine the value by the server, do not set this property by a value determined by the client.

Share/Save/Bookmark

MySQL NDB Cluster Engine Startup Script for openSuSE

          0 votes
May 14th, 2008

Finally took the time to setup an official project on Sourceforge to host this little startup script for MySQL's NDB Cluster Database Engine. When I'm even less lazier i'll fix my server and move my open source SVN projects there.

You can grab the latest code from the project URL below. I'd recommend just getting whatever is the latest code in trunk and I'll continue to maintain the script(s) until our platform specific packages start coming out with their own start up scripts.

Project URL: http://sourceforge.net/projects/ndb-initializer/

SVN URL: https://ndb-initializer.svn.sourceforge.net/svnroot/ndb-initializer

Please post up if you you another flavor of *nix and it works or if you are able to port it to another flavor.

Installation instructions located in script source.

Share/Save/Bookmark

Compiling Apache Web Server on Mac OS X

* * * * * 2 votes
May 8th, 2008

For whatever the reason might be that you need to compile Apache on Mac OS X (likely because I linked you here from another one of my blogs :lol: ), the steps are really simple.

Developer Tools

First things first! If you don't have a copy of Developer Tools installed then install it! Apple's Developer Tools will provide you with a number of required stuff to help us compile programs. (Later if you got a minute its fun to poke through it and see what cool Apps Apple just gave you for free.). You should be able to find it in one of your CDs that comes with your computer or OS X purchase. If you have a broadband connection you can download the latest version from ADC (Apple's Developer Connection) for free by going to http://developer.apple.com.

Apache

Next we'll need to obtain the latest version of Apache Web server by going to http://httpd.apache.org/download.cgi. Download the latest Unix source of Apache (2.2.8 as of this writting) compressed in tar.gz format. Once that is complete open up a terminal window in the directory where you downloaded Apache and type the following commands:

$ tar -xvzf httpd-2.28.tar.gz
$ cd httpd-2.2.8
$ ./configure --enable-layout=Darwin --enable-mods-shared=all
$ make
$ sudo make install

You will need to have the root password handy with the last command in order to install Apache unless you modified the configure command to build in a directory you have permissions to. I would advise to leave the configure command as is so that you will still have the ability to stop/start Apache from your System Preference's Sharing module.

If you are a Terminal junkie like myself you could use /usr/sbin/httpd or /usr/sbin/apachectl to stop/start/restart apache from the command line. Read the man pages for more info how.

That about sums it up! Told ya it was really simple!

Share/Save/Bookmark

Compiling MySQL-Python on Mac OS X

          0 votes
May 6th, 2008

Compiling is so 80s and not the Mac way :???: . If any system should have packages for everything it should be Mac! Well, before I drift off into why I think there should be packages for everything lets get back on topic.

I did this with Mac OS X 10.5 (Leopard) but it should work with older versions (and newer ones). If you tried them and they work please post up!

Developer Utils

If you haven't already, find your install disc of Mac OS X and poke through it and install Developer Tools. You can also download it from ADC (Apple Developer Connection) for free from here. You'll need to do that before continuing.

MySQL

Next you'll need to download the latest stable version of MySQL from here (version 5.0.45) as of this writting. Unpack it by double clicking it, install, blah blah blah.

MySQL-Python

Lastly, download the latest mysql-python from here (version 1.2.2 as of this writting). Unpack it by double clicking and open up _mysql.c in your favorite text editor as they usually say.

Find the following lines and delete them (line ~36):

#ifndef uint
#define uint unsigned int
#endif

Next find these following lines:

uint port = MYSQL_PORT;
uint client_flag = 0;

... and chane them to:

unsigned port = MYSQL_PORT;
unsigned client_flag = 0;

Some people reported having problems trying to build this because for some odd reason they are missing a `mysql` link in its lib directory to itself. Peek inside of /usr/loocal/mysql/lib and see if you have a symbolic link named `mysql` pointing to itself. If you don't, open up your Terminal and run the following command:

sudo ln -s /usr/local/mysql/lib /usr/local/mysql/lib/mysql

We're almost done :) Open up your Terminal into the directory you unpacked mysql-python and run the following:

python setup.py build
sudo python setup.py install

Thats it! Enjoy!

Share/Save/Bookmark

Auto-Hide Your Firefox Toolbars

          0 votes
April 21st, 2008

I love my viewing space, I have a huge 23" Apple display and I always try to get the most out of it however I can! I always have to make all my tool bar icons small and get rid of the ones with least relevance. Anyways, getting back on the ball here's the little tip I figured out earlier today how to hide your bookmarks bar.

Auto-Hide Firefox Toolbar

So first thing we gotta do is edit our userChrome.css. If you don't want to get your hands dirty with figuring out that userChrome stuff in the link then you can also download an extension for Firefox called ChromeEdit Plus.

#PersonalToolbar{display:none;}
#navigator-toolbox:hover > #PersonalToolbar{display: -moz-box;}

Pop the above code in your userChrome.css file and restart and walla! All of sudden you got an auto-hiding bookmarks bar!

If you want you can also get rid of the navigation bar. For that you can apply the code below:

#nav-bar{display:none;}
#navigator-toolbox:hover > #nav-bar {display: -moz-box;}

Unfortunately hiding the navigation bar doesn't really work for us Mac users because that would mean the whole navigator tool bar (which means the bar holding File, Edit, View, etc...) is gone and there is is nothing to hover over to show it to us again. However it works for Windows and *nix users :P .

Now as your journey here has ended I thought I would be nice and give you a few links that might help you continue your journey on your own.

Here are some common userChrome element name IDs that might be helpful. Also the DOM inspector is an extremely powerful tool which would let you not only inspect a web site's DOM but also Firefox so you can completely customize it using your userChrome.css file. It ships with the default install for people using Firefox 2 and below. For Firefox 3 and above you'll have to manually install it from this addon page.

Share/Save/Bookmark

Fix Your Accent!

          0 votes
April 16th, 2008

Fix Your Accent!

So I was driving home on my usual route from work yesterday on Bundy blvd. in Santa Monica when I happen to notice a sign taped on a street light regarding fixing your accent! Seriously wtf! I don't know about you but I wish I had an accent... If I had an accent girls would be on me like flies on sh**!!! Seriously, we all know how fast girls drop their panties when some annoying guy with an accent comes around then we all wish we had an accent! Hmm, maybe thats what this is about? Blah blah...

I haven't actually called the number posted on it to see if this is real or not but the nerve to actually post this is comedy to say the least! If you can't read the number its (310) 930-8070.

I have to admit though, I am annoyed by certain accents (and no I'm not going to say which ones because I'm not trying to hang myself here) so maybe some good might come out from this person trying to do his community a service!

Share/Save/Bookmark

Compiling PHP on Mac OS X

* * * * * 4 votes
March 29th, 2008

Getting Started

You may want to recompile PHP on your Mac for a number reasons such as need a newer version, missing some features you need, testing, or whatever. Some of the most common reasons I found were people needing GD support because the version of PHP that comes with Mac OS X doesn't have it. In this I'll let you know what you need and how to get it done.

Apache

We'll need to recompile Apache even though it already comes with our system because for some unknown reason (to me) the compiled version of Apache that comes with our systems doesn't play too well when we compile PHP. Anyways without going into further details, read through this article real quick, Compiling Apache on Mac OS X, and come back here. Should only take ya like 5 minutes...

Time for PHP

Welcome back! Next, download the latest copy of the PHP source (5.2.5 as of this writting) compressed in tar.gz format from this URL, http://www.php.net/downloads.php. Once complete and you don't care about compiling PHP with any other options such as GD Support, MySQL, etc, and you just want the basic PHP then you can go back to your Terminal, cd into the directory where you downloaded PHP and run the following commands:

$ tar -xvzf php-5.2.5.tar.gz
$ cd php-5.2.5
$ ./configure --enable-layout=Darwin --enable-mods-shared=all --prefix=/usr --mandir=/usr/share/man --localstatedir=/var --infodir=/usr/share/info --disable-dependency-tracking --with-apxs2=/usr/sbin/apxs --with-kerberos=/usr --enable-cli
$ make
$ sudo make install

Like Apache, you would need your root password to install PHP with the last command. Once everything is complete you can go into Sharing from your System Preferences and restart Web Sharing and you will notice you are running the version of PHP that you downloaded!

Note: Whenever editing your apache configuration you will need to restart it in order to see the new changes.

If you do want to build PHP with additional features then proceed below and follow the setup of instructions for each and either feature. For starters we can unpack PHP.

$ tar -xvzf php-5.2.5.tar.gz

Later when I say to build PHP with whatever ./configure command I just mean running the command from your Terminal while being in the directory where you unpacked PHP.

GD Support?

I won't leave you hanging wondering how to install GD since I brought it up earlier and its quite easy so lets do it! If you want jpeg support with GD then you need to install libjpeg. You can download the latest stable source code from http://www.ijg.org/files/. Once you get it go back to your terminal and run the following commands:

$ tar -zxvf jpegsrc.v6b.tar.gz
$ cd jpeg-6b
$ cp /usr/share/libtool/config.sub .
$ cp /usr/share/libtool/config.guess .
$ env CFLAGS="-O -g -arch i386 -arch ppc" LDFLAGS="-arch i386 -arch ppc" ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --mandir=/usr/share/man --enable-shared --enable-static
$ make
$ sudo make install
$ sudo ranlib /usr/local/lib/libjpeg.a

That's that for libjpeg. Now if you also want png support we need to grab libpng from http://www.libpng.org/pub/png/libpng.html. When done, lets go back into our terminal and run the following commands:

$ tar -xvzf libpng-1.2.22.tar.gz
$ cd libpng-1.2.22
$ env CFLAGS="-O -g -arch i386 -arch ppc" LDFLAGS="-arch i386 -arch ppc" ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --mandir=/usr/share/man --disable-dependency-tracking
$ make
$ sudo make install
$ sudo ranlib /usr/local/lib/libpng.a

Alright all set! Now we just have to go back to PHP and configure it with the options for GD. Below is the command:

$ ./configure --enable-layout=Darwin --enable-mods-shared=all --prefix=/usr --mandir=/usr/share/man --localstatedir=/var --infodir=/usr/share/info --disable-dependency-tracking --with-apxs2=/usr/sbin/apxs --with-kerberos=/usr --enable-cli --with-jpeg-dir=/usr/local/bin --with-png-dir=/usr/local/bin --with-gd

All I added were the last 3 options. If you didn't add libjpeg or libpng then you can remove them from the options respectively. After done configuring just remember to make and make install and your done!

MySQL

What PHP build would be complete without MySQL support? This step is super easy, simply go to http://www.mysql.com and download the latest stable version (5.0.45 as of this writing) for your platform and install it. The installation will place the files in a mysql directory in /usr/local. You can see which directory it was installed in by running the following command:

$ ls -lah /usr/local | grep mysql

Now that you've got the MySQL installation directory its helpful to create an alias directory without the version number at the end that will point to your current working version. This is also helpful so you can install multiple versions of software and when you want to switch between them you could simply change where the alias points to. If your MySQL directory was installed to /usr/local/mysql-5.0.45-osx10.4-i686 then this would be your command to create an alias:

$ sudo ln -s /usr/local/mysql-5.0.45-osx10.4-i686 /usr/local/mysql

Also, if you would like to access MySQL from the command line without having to type the full path to the binaries each them then I'd recommend appending your MySQL path to your $PATH environment variable:

$ echo "export PATH=\$PATH:/usr/local/mysql/bin" >> ~/.profile

The above line appends MySQL to your $PATH environment variable and from here on every Terminal window you open will find its way to MySQL.

Continuing on with PHP, depending which MySQL support you want (MySQL, MySQLi, PDO, or all) then just pick out whatever you want and don't want from the line below:

--with-mysql-sock=/var/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql

Conclusion

There are many more options you can add to the configure script to set certain features. To view all the options available you can run ./configure --help and that will spit out just about all the ways you can configure your build. Below is the configure command I used:

$ ./configure --enable-layout=Darwin --enable-mods-shared=all --prefix=/usr --mandir=/usr/share/man --localstatedir=/var --infodir=/usr/share/info --disable-dependency-tracking --with-apxs2=/usr/sbin/apxs --with-ldap=/usr --with-kerberos=/usr --enable-cli --with-zlib-dir=/usr --enable-trans-sid --with-xml --enable-exif --enable-ftp --enable-mbstring --enable-mbregex --enable-dbx --enable-sockets --with-iodbc=/usr --with-curl=/usr --with-config-file-path=/etc --sysconfdir=/private/etc --with-mysql-sock=/var/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql=/usr/local/mysql --with-xmlrpc --with-xsl=/usr --with-pdo-mysql=/usr/local/mysql --enable-soap --with-pear --with-jpeg-dir=/usr/local/bin
--with-png-dir=/usr/local/bin --with-gd

Its also important to note that when doing system updates, not just little security updates or other application updates, but big critical system updates that brings you from something like 10.5.0 to 10.5.1 might rid your Apache and/or PHP setup. Nothing bad will happen, they will just overwrite your setup with their update. If you happened to keep your build then you can just go back and run sudo make install or you can just download the latest versions of the software we used here and redo the steps.

Share/Save/Bookmark

Start!

          0 votes
March 27th, 2008

Ah finally! I've been meaning to get this blog started for a very long time but have had trouble finding spare time to do so but it's here now! [applause]

The purpose of this blog is for me to organize and jot dot useful notes as I continue to explore the fascinating world of science. Most blogs will be focused specifically but not limited to computer science. Other sciences or interesting stuff I come across may be blogged about to.

As part of being a scientist (yes I like to pretend I am one sometimes) you must be open minded and I am always interested in what people have to say so if you feel that you can add more to what I've blogged about then I strongly urge you to comment on my blogs. I am part human too so if you find an error before me in a blog then please post a comment to help out whoever else might be reading it.

Thats about all I have to say for now but stick around as I plan to start adding things very soon! I have already started working on more appealing theme so we have some eye candy going on and if you would like to contribute in one way or another the please don't hesitate to contact me and we'll see what you could do.

Thanks for visiting and we'll see you around!
- Richard Sumilang

Share/Save/Bookmark