Archive for May, 2008

Free Photoshop Book from SitePoint!

Thursday, 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

Thursday, 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

Wednesday, 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

Wednesday, 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

Thursday, 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

Tuesday, 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