Tuesday, March 27, 2007

Creating sliding DIVs

Here is a tutorial for writing a sliding divs like you see on Digg or many other sites. It was written in response to another tutorial on implementing a similar behavior.

Both articles are worth reading as it spells out clearly how to do the effect. The version on firblitz takes a more object oriented approach. In both examples, the initial call is from an inline Javascript (a href="javascript:..."). There is nothing wrong with doing this, but to have an even cleaner separation between Javascript and the HTML presentation, it's best to not have inline Javascript at all. Instead, use the event model to attach the function to the event so that that the HTML is completely clean.

Start with the following addition to firblitz's javascript code.




function toggle() {
var sd = document.getElementById("slidediv");
if (sd.style.display == 'none') {
Slide('slidediv').down();
} else {
Slide('slidediv').up();
}
}
function init() {
// attach event listener to objects
var slidediv = document.getElementById("mydiv");
slidediv.addEventListener("click", toggle, true);
}
window.onload = init;



And the body of the html would just be:



clickme





To take it one step further, take out the inline styles. However, this introduced one problem. Javascripts is unable to access the style value directly if it is not an inline style. This is because the element's style is not the style of the CSS object that is assigned through the #id. Thus, you have to manually assign the styles to the element. This is the end result:



function toggle() {
var sd = document.getElementById("slidediv");
var styles = getComputedStyle(sd, '');
sd.style.display = styles.display;
sd.style.height = styles.height;
if (sd.style.display == 'none') {
Slide('slidediv').down();
} else {
Slide('slidediv').up();
}
}
function init() {
// attach event listener to objects
var slidediv = document.getElementById("mydiv");
slidediv.addEventListener("click", toggle, true);
}



And the body of the html is a clean:



clickme

Hello world!


Sunday, March 25, 2007

amateur photographer

I'm not even sure if I should classify myself as an amateur photographer at this point. While I'm enjoying taking pictures, I'm not really experimenting and practicing that much. I'm a long way away from the days when I thought about being a photographer shooting bikini models in exotic locations. I just enjoy taking out the camera and taking baby pictures and to capture memories and small things around the house such as the backyard and the animals that visits.

Still, I'm tempted to get a longer range telephoto lens and knowing that I'm not going to be a "serious" photographer, I have my eyes on a basic beginner lens: Canon EF 100-300mm f/4.5-5.6 USM. At around $285, it's inexpensive as lenses go, but after shelling out so much already, I'm in a belt-tightening mode. For now, I guess I should have it on my wish list.

Beginning PHP and PostgreSQL 8

This book by Jason Gilmore and Robert Treat (published by Apress) is meant to be a comprehensive tutorial on the PHP language and PostgreSQL for beginners. Don't expect it to be a detailed book focused on using PHP with Postgres. It's like two books in one. 2/3 of the book is devoted to teaching PHP and it's well written and easy to understand with plenty of examples. It covers additional topics that other beginning books sometime don't cover such as networking, secure programming and web services although not necessarily in great detail, but I like that it seeds the topic into beginners' heads.

The latter 1/3 is devoted to Postgres and provides better coverage then other stand alone Postgres book and more accessible then the Postgres documentation. It discuss database topics, postgres setup and administration and is a good reference source.

I would recommend this book to those who want to learn either these technology especially those who are going to work with PHP since most likely you'll be needing a database beyond the SQLite solution that comes with PHP.

The only area that I wish would be improved is more details on web services on the PHP side and a discussion on database replication on the Postgres side.

Monday, March 19, 2007

Y! Messenger Archive location

If you archive your messages in Y! Messenger and need to move to another location, the files are stored in:

Program Files\Yahoo!\Messenger\Profile\\Archive\

Saturday, February 24, 2007

Currently Watching...

One positive to often having no hands available to do anything is that it gives a good excuse to watch anime. Currently I'm watching:

Tokyo Maji Gakuen Kenpuchou Tou
Tokyo Majin Gakuen Kenpuchou

Busou Renkin

Code Geass
Shijou Saikyou no deshi Ken'ichi
Legends of the Galactic Heroes
Pumpkin Scissors
Shounen Onmyouji
Tenpou Ibun Ayakashi Ayashi
Bakumatsu Kikansetsu Irohanihoheto

No hands = no video games. :-(

Babies are camera makers' best friend.

When one has a baby, there is an inevitable desire by parents (or grandparents telling the parents) to take pictures and lots of it. I wonder how many new camera sells are directly related to a new baby coming into the world with an eager dad ready to satisfy that urge to take pictures and that inner desire to buy gadget? I think camera makers should be like the diaper and baby food makers who sends you tons of samples before the baby arrives to get you hooked on their product. Send the expectant father a new camera body and a brochure of all your lenses and watch the money flow from daddy's credit card.

Not being immune to the this bug either, I started looking for a new camera after missing some good shots with the digital point-and-shoots that I have. I started photography in high school as a sports and yearbook photographer with traditional 35mm b/w film SLRs, but as time when by (along with the lack of a darkroom) I stopped photography as a hobby.

I bought a Sony Cybershot DSC-S85 a few years back so that I can take pictures on trips. It's a great camera with a good balance of features, but more importantly, it was convenient. I just need to take it out, point and shoot and the images are good. Compare to current point-and-shoot digitals, however, it is a bit bulky and I was envious as people started to whip out little itsy-bitsy cameras out of their shirt pockets with bigger LCDs, more mega-pixels and faster shooting speed. I started looking for a replacement for the S85 starting with newer Sony models. Sony has gotten its hook on me with its brand on my camcorder, TV, PDA, camera and notebook (had 2 over the years), but over the past few years I've been getting more disappointed with the quality of their stuff.

After some research, I decided that it's time to break out of the Sony grip despite the investments I put in Sony chargers, memory sticks, etc., and eventually decided on the Canon Powershot SD800IS. It's a small and compact camera that feels solid and shoots at 7.1 mega-pixels. It's a nice camera, but honestly I don't see the difference in image quality between it and my 4 mega-pixels S85. In low light, the S85 seemed to come out a bit better for my pictures. It could be that I'm not used to the Powershot yet, but regardless I realize that both camera is limited in how quickly they can power up and shoot fast shots. I could go back to my film SLR but I didn't want to deal with the processing time and getting prints then scanning it, etc.

It was time to get a digital SLR and I narrowed down my choices to the Digital Rebel Xti (EOS 400D) and EOS 30D Digital. The Xti is cheaper, newer and is 10 mega pixels, but the 30D can shoot at 5 fps continuous. After reading various reviews and speaking with some friends who own the Xti and hearing that they would upgrade to the 30D as soon as they could, I decided to just go ahead and get the 30D with 2 basic lenses (50mm prime and 28-105 Zoom). It's been a long time since I used an SLR and I'm excited.

EOS 30D

So there, Canon sold two camera because of one baby.

Completed Backyard

yard
Ever since last summer, we've been planning to re-landscape the backyard. Now, months and months later, the final touches have been completed.

We actually wanted to re-landscape the yard when we first moved in because the original English garden style wasn't us and required a lot of work to maintain. We had a few designers come in to give us estimates and they either flaked, was really slow to respond or just couldn't do what we wanted. Eventually we gave up and kept things the way it was until it became a jungle back there that nobody wanted to go into! :-)

With the big news of last year, we decided it was time to finally get the backyard done along with other home projects that we've put off including a Phantom sliding screen and wood flooring. We got a landscaper through a recommendation from a friend at work who came in to clear out the old garden and recommended the patio and designer that we ended up using.

Since we wanted an Asian theme, the goal was simplicity, natural and asymmetrical and the designer helped us with the basic layout, elements and plant suggestions which we then went over with the landscaper to make adjustments.

We're pretty happy with the results. :-) I especially like it at night when the lights comes on. If I can figure out how to do good night shots, I'll try to include some.

The next step is getting that grill...

Tuesday, February 13, 2007

RHEL Version

Had to look in /etc/issues to find out which version of RHEL was installed machines.

Tuesday, January 23, 2007

5 Things About Me

Responding to Marc's post.

1. 2006 ended with me being a first time dad!
2. I've lived longer in my current area then anywhere else in my life.
3. My first computer was a Commodore 64 and I had a IBM-AT 6Mhz (not the 8MHz)
4. One of the biggest "wow" computer moments that I always remember is the first time I heard sound through the Soundblaster card.
5. In my freshman year of college, my roommate and I continued the tradition of throwing an end-of-year party in our dorm room because we had the smallest room in the whole dorm.

beagle on fedora

Today I noticed my hard drive spinning a lot and so I did a "top" to see what was running. A process called beagle-build-in was the highest resource consuming task and a "ps auxfw" showed that it was started by a daily cron job called beagle-crawl-system. Beagle is a Mono-based desktop search engine so I guess what this is doing is to index files on the system, but the thing is that I had not enabled Beagle on my service so I'm not sure why Fedora kept this daily cron job...