Check radio group for selected elements with Prototype

August 8th, 2008

Just a quick one today.

Here's a little snippet on how you can check if any element of a radio button group is selected, using Javascript and the Prototype library.

function $FR(formElement, radioName) {
var el = formElement.getInputs('radio', radioName).find(function(radio) { return radio.checked; });
return el;
}

Usage:

var theform = $("mainform");
if ($FR(theform, "radio_group_name")==undefined) {
alert("Please select at least one element of the radio group");
}

Digg It!

How to override Firefox search language settings

July 31st, 2008

I live in Japan, but I really love to have my (Google) search results to be in English. However, every other program out there thinks it knows what I need better than me. 

That exactly the case with Firefox 3 on Mac. It annoyed the hell out of me to get my location detected every single time I do search and search Japanese segment of the web for my English-worded queries. Making changes to my preferred search language in my Google accounts yielded ZERO results. 

But before you go insane, there's an easy solution!

1. Open file: /Applications/Firefox.app/Contents/MacOS/searchplugins/google.xml in your favorite text editor

2. add <Param name="hl" value="en"/> to the parameters section (if you want english as default language) as well as replace {moz:locale} entries to the required language setting.

See the screenshot.

3. Restart Firefox and enjoy!

Digg It!

Permalinks back online

July 31st, 2008

Sorry about downtime. WP 2.6 seemed to change the way permalinks are processed on Apache side, so I had to re-compile my ancient Apache install in order to add mod-rewrite. Everything should work fine now :)

Digg It!

Upgraded to wordpress 2.6

July 25th, 2008

… and publishing this article using iPhone's WordPress application! Pretty cool huh:)

photo

Digg It!

Want to get notified when a long action on remote server completes?

July 20th, 2008

Sometimes you might want to run a long action on a remote server, like dump a few gigs DB, or rsync a few thousands of files between two not very fast computers.

You want to take next action as soon as that long operation completes but don't want to baby sit your servers.

How about getting email notification to your.. say.. iPhone.. when the action completes? It's pretty easy! Have a look!

mysqldump -u user -p mydatabase && echo "Dump finished!" | mail -s "Wake up!" mike@example.com

Once the command mysqldump finishes executing,  you'll get mail with subject "Wake up!" and body "Dump finished!"

You can chain more commands, of course, by adding && between them ( && executes next chained command only if the previous one completed without errors)

Pretty cool to have such a simple but useful trick under your belt, isn't it? :)

Digg It!

Yeah! My iPhone can now ssh into things!

July 20th, 2008

Thanks to the great guys at iphone-dev and their Pwnage 2.0 package, I can now finally ssh into the server I have to manage (as well as perform other tasty tasks in command line!)

 Now, I only need one application to make iPhone 100% usable for me - some utility running on background and reminding me about missed calls and messages (vibrating, making sounds.. anything!).

Digg It!

My second iPhone 3G!

July 18th, 2008

Yesterday, I have noticed one little unpleasant detail in my otherwise perfect iPhone 3G. One bad pixel in top left area of the screen. Just one black dot that never changes its color and just stays the same black pixel forever.

Called Softbank today (my mobile operator) - these guys are clueless! Told me they'll get in touch with me but it never happened. Also called Apple support line and was redirected to Softbank with all the exchange inquiries.

So during lunch I just decided why not have a little trip to Apple store here in Nagoya, because it never hurts to check (in America, people can get their iPhones exchanged right in Apple stores).

And oh miracle! My iPhone WAS exchanged right at the Genius bar counter! The guy over the counter had a look at the screen - "Ah.. yeah I see". Then told me that he has to check Apple's policy regarding bad pixels on iPhones - and there's zero-tolerance in this regard, so you can get your iPhone exchanged even for one dead pixel. Then he checked the inventory, and there was the same model I have! The iPhone came in plain brown box though, not the stylish Apple package - definitely a sign that these units are for replacements only.

I received the unit, asked if I can check the screen for bad pixels - and there were none! I few mins later I was going out of the store with my new, replaced iPhone.

I had my doubts if the same approach that works in the USA, will work in Japan - and I'm very happy to confirm that it does!

Thanks Apple!

Digg It!

Jesus Phone 3G..

July 12th, 2008

..is mine!

 

and I'm Softbank's slave for next 2 years.. Well.. at least I didn't have to sell my soul ;)

Digg It!

Time to undig my Cocoa knowledge?

June 26th, 2008

.. I have one nice idea for an iPhone app so.. hm… maybe I'll refresh (re-learn?) my ObjC .. but I don't really have time to spare as it stands now. Oh well.. we'll see :)

Digg It!

Hold on with upgrading to ruby 1.8.6-p230!!

June 26th, 2008

I started getting weird

(eval):2:in `protect_against_forgery?'

error from one of my Rails2-based system today. Mongrels were seg-faulting as well. The problem was quite unexpected as I have not touched the code for a while!

Turned out the problem was with the latest upgrade to ruby 1.8.6 patch level 230 (which is recommended by the Ruby on Rails site). And looks like this was the only system re-deployed (and restarted under new ruby version) since I have upgraded.

Now I'm back to p111, "vulnerable", but at least working version until problems sort themselves out.

Until they do, do not upgrade!

UPDATE:

Looks like the is a patch which addresses vulnerabilities which patch 230 addressed in turn. Check here for details. However, I'll just stick here for a couple of days for a real fix from the Ruby team.

Digg It!