Tuesday, April 28, 2009

CSS Sprites

I've heard CSS sprites for quite sometime now, but never really tried to understand how to implement it.

But this article explains it to me in a nice, simple way:
http://cssglobe.com/post/3028/creating-easy-and-useful-css-sprites

Basically, you will need to have the following CSS properties:
1. width
2. height
3. background-position

The first two are a no brainer. The last one is a bit tricky. Basically it tells how much to shift the image to the left, and to the top. Hence, the values are always negative.

For example, taking the code from that article:


.sprite {background:url(../images/mySprite.png);}
.monster {height:128px;}
.application {height:61px;}
.wolf {width:115px; background-position:-196px -2px;}


This is saying that the class wolf is 115px wide, and to position the background correctly, move the background 196 px to the left, and 2 px to the top.
Oh and to use the css above, we'll have to combine 'wolf','monster', and 'sprite' classes together.

Very nice article. I highly recommend it.

Saturday, April 25, 2009

PHP +MySQL + PHP My Admin

I had to install PHP, MySQL on my workstation recently, and although the steps are relatively simple, it took me quite sometime to configure everything.

The steps can be summarized as follows:

INSTALLING PHP + MySQL
sudo apt-get install mysql-server
sudo apt-get install apache2
sudo apt-get install php5
sudo apt-get install php5-mysql
sudo apt-get install phpmyadmin


CONFIGURING MySQL
sudo vim /etc/mysql/my.cnf

Find for 'bind-address' configuration:
bind-address

By default, it should be either localhost, or the loopback address (127.0.0.1)

change the value to be the IP address of your machine. (e.g. 192.168.0.10)
This tells MySQL server to listen to that address, instead of the loopback address.

RESTART MySQL
sudo /etc/init.d/mysql restart


CONFIGURE MySQL SECURITY
1. Login to phpmyadmin: http://localhost/phpmyadmin
2. Go to home
3. Create new database, say 'helloworld'
4. Go to home
5. Configure new user.
5.1 Go to 'user' table.
5.2 Click 'Insert'
5.3 Make sure that you specify % as the 'Host' value. This is saying that the user is given access from anywhere
6. Configure the user access for the database
6.1 Go to 'db' table
6.2 Click 'Insert'
6.3 Make sure that you specify % as both 'Host' and 'User' value. Also, use the database name for the 'Db' value (in our case, its 'helloworld'

You should now be able to connect to the database remotely, using tools such as DbVisualizer.

Monday, April 13, 2009

Perpisahan

Kelabu awan pagi berteman ria dengan embun diujung daun,
Bayangan berselubung ria dan duka,
tak kutahu lagi mana yang teringat olehku
pergi tlah dia, menggapai tangan yang tak tersentuh
sebutir air mata mengalir, tak kutahu tujuannya

Kemarin ku bermimpi buai,
sungguh indah, seakan nyata bernafas sinar mentari,
tak kutahu lagi mana yang teringat olehku
pergi tlah dia, menggapai ujung rambut tak terbelai
segaris senyum menghias bibir, tak kutahu kenapa

semoga kau bahagia bersamanya