Archive for February, 2006

time calculator

i had to add some time in hh:mm:ss format at work. i was like there was no way i would add those manually. so i looked for a program/script to do the work. since i didn’t find anything, i wrote my own.

here it is.

the most time consuming part is not the addition (which is very easy) but the frontend javascript to move the cursor & insert 10 more rows when the link is clicked. those were fun to write :)

geeky t-shirts

i’m browsing online geeky t-shirt stores out of boredom.

here are some of the entertaining ones i’ve seen:
blue screen of death
c dos
unique computer keys
if at first you don't suceed, call it version 1.0
flow chart t-shirt
like i care
no fix
localhost
opinion
human stupidity
sarcasm
source code
upgrade

heard another here i like:
“SELECT * FROM users WHERE clue > 0
0 rows returned”

why did i come to work?

i don’t know why i came to work today.

the weather is hell. this morning freezing rain fell. then snow pellets, thunder & lightning. tonight we are supposed to get 5 inches of snow. misty was a scared little puppy. she always has been a chicken.

i was woke up by the loud thunder at 6am and was debating if i should go to work ever since. for a while i thought for sure i was NOT going. it all changed around 8 o’clock. i thought maybe the road won’t be as bad.

WRONG! trying to stop for a red light, i did a 180 at an intersection. FORTUNATELY there was no car behind or next to me. otherwise i’d wipe out all three lanes. that really scared the **** out of me. i knew i should have turned around but i kept going. after i got on interstate 80, i found out the right lane was not ploughed at all. the left lane seemed clean. patiently i waited for all the cars on the left lane to pass me and then got on the left lane and drove about 45mph all the way close to the exit. then i was terrified when i had to change back to the right lane to go on the off ramp. i know from my past experience how much control i would be in getting on top of a pile of snow. i just told myself, go slow slow slow. it was still probably pretty risky because by the time i got to the right lane, the car behind me was almost about to hit my rear end. i slowed down to 25mph when i reached the off ramp.

thank god now i’m safely sitting in my cube. of course i will be surprised if even 10% of the IT employees came. all the meetings i have on my schedule have been cancelled.

maybe it’s time to really get some work done? LMAO

disable wordpress smiley for a certain post/page

okie, i thought someone has figured it out by now. but when i asked on the wordpress board, i got no response. so i digged around and figured a hack for it.

i noticed sometimes esp. on some pages, the smiley conversion does a poor job and converts the wrong text into smilies. it really mars my content. personally i want to be able to just turn the smiley off for a certain post or page.

the best way i can think of to do it is via a hack.

open your wp-includes/functions-formatting.php file, try find the function (possibly line 576):
function convert_smilies($text) {

then under it, replace:
global $wp_smiliessearch, $wp_smiliesreplace; $output = ''; if (get_settings('use_smilies')) {

with:
global $wp_smiliessearch, $wp_smiliesreplace, $post; $output = ''; $smileykey = get_post_meta($post->ID, "disable_smiley", TRUE); if (get_settings('use_smilies') && $smileykey != 'true') {

that’s all i needed to do.

now next time you write a new post/post, simply create a custom field with the key disable_smiley and value true to disable smiley conversion for just that post/page. isn’t that neat? :)

rel=”external”

for those who did not know this trick (someone emailed me and asked), I will share it with you here. since xhtml 1.0 strict does not allow the tag target=”_blank” you can still open links in new windows by using the tag rel=”external” to accomplish the same thing. but you will need to link an external js.

create a .js file with the content
function externalLinks() { if (!document.getElementsByTagName) return; var anchors = document.getElementsByTagName("a"); for (var i=0; i<anchors.length; i++) { var anchor = anchors[i]; if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") anchor.target = "_blank"; } } window.onload = externalLinks;

save & upload it. then link it in your header like any other external javascripts. that’s all :)

XHTML strict validated flash code

i put up a slideshow of the silver jewelry club photos i’ve saved. after i added the code given to me directly from slide.com, my site no longer validates with XHTML 1.0 strict rules. So I researched on valid flash embed code and found this nifty javascript trick for embedding flash.

The code given to me from the slide.com:
<embed src="http://widget.slide.com/widgets/slideticker.swf" quality="high" scale="noscale" salign="l" flashvars="site=widget.slide.com&channel=181375" wmode="transparent" bgcolor="#f5f5f5" width="205" height="97" name="flashticker" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"/>

The final code I put up that works & validates:
<div id="slideshow">If you don't see the slideshow, <a href="http://www.flickr.com/photos/68167759@N00/">click here.</a>.</div> <script type="text/javascript"> // <![CDATA[ var fo = new FlashObject("http://widget.slide.com/widgets/slideticker.swf?site=widget.slide.com&amp;channel=181375", "flashticker", "205", "97", "6", "#ffffff"); fo.addVariable("wmode", "transparent"); fo.addVariable("quality", "high"); fo.addVariable("scale", "noscale"); fo.addVariable("salign", "l"); fo.addVariable("align", "middle"); fo.write("slideshow"); // ]]> </script>

given that I’ve properly uploaded flashobject.js and included in the header of my HTML with:
<script type="text/javascript" src="/js/flashobject.js"></script>