Friday, July 10, 2009

Graceful 3 column to 2 column to 1 column degradation using CSS

I have been wanting to update my blog profile from rounders3 to something a bit more malleable for some time now.

This week I finally got around to it. You can see the results on this blog. It now degrades gracefully from 3-column to 2-column to 1-column mode.

If you are running the latest Safari/Opera/Firefox/Chrome, you can see it in action - just resize the browser window and the layout goes from 3 column, to 2 columns (with the Twitter/Archives sections moving below the profile) to 1 column (with the footer replaced with a helpful message)

This works on all browsers - except IE of course. Older browsers may require the page to be refreshed.

Also, in Print mode, the columns disappear and the footer is replaced with copyright text.

This is all done using CSS 3 Media Queries. These are not supported in Internet Explorer - even v8. Get The Facts - "Firefox and Chrome have more support for emerging standards like HTML5 and CSS3, but Internet Explorer 8 invested heavily in having world-class, consistent support for the entire CSS2.1 specification." Remember?

How did I actually do this? I started off with the instructions given here. They point out that you can use a CSS left and right float to get a three column layout. They also point out an important fact - in the absence of a float, elements will be displayed in the order they are mentioned. Also, clear can be used to ensure that there are no floating elements next to a given element.

Besides this, we have Media Queries. These allow you to specify your display type (for e.g. print for a printer, handheld for a mobile device etc) as well as query on other things such as screen resolution or browser window size/aspect ratio.

Normally you would expect the iPod to respond to handheld, but unfortunately, Apple ignores the handheld tag. In its place, they ask you to query on screen resolution instead.

Finally a couple of things: if your default specification for an object attempts to float to the left, you can override and move it to the right using the CSS !important qualifier. Also, if two rules with !important are triggered at the same time, the one which occurs first is given priority.

Armed with all this, I could write the following to move to two column mode if the browser Window has less than 1000px (view source on this page to see this code). Notice how I changed the margins to accommodate less space required on the right of main-wrap1 in two column mode.
@media only screen and (max-width: 1000px) {
.sidebar-wrap-left {
margin:15px 0px 0px 20px !important;
}
.sidebar-wrap-right {
clear: both !important;
margin:15px 0px 0px 20px !important;
float:left !important;
}
#main-wrap1 {
margin:15px 20px 0px 290px !important;
}
}
This comes below the above for 600-1000 (Note the overlap):
@media print, handheld, only screen and (max-width: 600px) {
.sidebar-wrap-left {
display: none !important;
}
.sidebar-wrap-right {
display: none !important;
}
#main-wrap1 {
margin:15px 20px 0px 20px !important;
}
}
There were a few more tweaks required. For example, the Footer actually has three different messages inside, one each triggerring on Print, sub-600 and Everything Else. Also, the Google Search box in the header (another addition from my side) is layouted using floats - meaning it doesnt play well with the blog layout by default. I had to add the following to get it working (it had a nonsense tab bar on top that I hated)
#uds-searchControl .gsc-resultsbox-visible {
clear:none !important;
}

#uds-searchControl .gsc-tabsArea {
display:none !important;
}
None of this would have been possible without the amazing Firebug extension - its an invaluable tool for use while designing web pages, allowing you to add/view/remove attributes from an element at the same time showing all the CSS attributes (inherited or direct) applicable to an element.

Not surprisingly, the iPod Touch's browser supports media queries. But, it sticks to the 600-1000 rule no matter what. I was pleasantly surprised to find that my 5800's browser also supports media queries. In retrospecitve, since it does Flash too, maybe I shouldnt have been surprise. The 5800 uses sub-600 in portrait/landscape mode and 600-1000 in landscape fullscreen mode (after refresh - using Older/Newer Posts button.) The 5800's UI fails its back end engine as usual - there is no way to refresh the page while in fullscreen mode. Nokia has been taking quite a beating recently by the way. I don't think they deserve it - the 5800/N97 are pretty decent phones, it just that they suddenly have to compete in a field of handheld computers (which is essence is what the iPhone/Palm Pre etc. are - whatever you may choose to call them)

Lastly, I have been having a lot of trouble with FF 3.5 - it seems VERY slow now, much slower than FF3. Most of my friends have switched to Chrome - maybe I will do so too. People are recommending unusual steps to deal with it - from optimizing FF3.5's SQLite databases to clearing out your Temp Folder, Recycle Bin and Temporary Internet Files - it seems its a bug. Mozilla have to get their act together - Chrome will soon have extension support, and the plight of Nokia and Sony should teach them that people have no brand loyalty in the tech domain.

Sunday, July 5, 2009

July Update

Nokia 5800

Nokia is trying to get its act together on Symbian. Symbian is possibly one of the strangest platforms to exist - one that ensures no consistency across even devices that have the same version of the OS. Nokia also tends to release newer features on newer phones rather than adding them to older phones. While Symbian runs very lightweight and responsive, the sheer popularity and quality of the apps on the iPhone Appstore shows easily the problems faced by developers while trying to use Symbian. From a user POV, consider the horrible Download app used by Nokia (that till recently used to show every single apps as free - only to have the app ask for money on installation)

Nokia is trying to improve on this - by launching the Ovi store, having more frequent firmware updates and now, by decoupling features from the OS. Adobe Flash Lite 3.1 recently became available for download over App Update - independently of the Firmware version. This is followed by the Java runtime being updated to 2.0 again independently of the firmware. This has a frightening disclaimer though - it seems if you interrupt the update, your device may need servicing. I am not risking that on a beta version!

Nokia still needs to work on a few things. Their customer care is one - you cant have the same people who service the 50,000 Rs. 1500 phone owners also try to service the 5000 Rs. 15000 phone owners. In India, Nokia tries to do that - and people tell horror stories of Nokia support as a result. Then there's the region coding issue - Ovi store launched months ago but I STILL don't see the Ovi app in the Download app, so officially, it hasnt hit India as yet. Similarly Firmware - Nokia it seems has 500 different Firmwares for the 5800, with minor tweaks for each country. You can easily change a phone's region code and install another firmware - the hardware is identical! But Nokia still makes you wait months for updates if you live in India.

BTW, it seems you can install Python on the 5800 and then that becomes available as a platform - much like J2ME. Amazing!

Firefox

I am sure many people remember M$'s much maligned Get The Facts campaign, which somehow managed to prove that Linux was 10 times more expensive than Windows 2003 - by comparing the cost of running Windows on Intel Xeons and Linux on a hyper-expensive IBM box. Well, they recently came out with a similar campaign for IE8. IE8 somehow manages to beat Firefox on every single category - and even get a "tie" on "customizability." I don't understand why M$ does these things - surely the negative publicity and ill-will generates through this would annul any advantages. Of course, the Firefox team occasionally does annoying things too.

In any case, I have been using FF3.5 for a week now. The only extension which is not working with it is Block Site. Unfortunately, as noted earlier, the browser offers only minimal memory usage improvements - after a week with it, I find FF3.5 using pretty much the same amount of memory of FF3.

In the meantime, the Mozilla team is rushing ahead on the "customizability" front. They recently introduced JetPack - a sort of hybrid between Greasemonkey and normal Extensions. This allows you to write Javascript/CSS that not only changes a page's look and feel (Greasemonkey) but also interacts with the browser chrome (like an extension). The other interesting thing is the ability to create collections of addons on the Firefox site. This allows you to use the Add On Collector extension to create a set of addons which will get installed together. Check out this link to see some collections assembled by Lifehacker.

Customizability is the crux of reason why I use Firefox - even if its slower, uses more memory, has less features etc, I have it customized way too much to my liking using extensions to giv eup on it. The FF team though has an uphill task - jokes aside, IE8 is the best browser by M$ ever and Chrome/Safari/Opera are definitely tough competitors.

Other Stuff

Lifehacker regularly publishes a Hive Five - a comparison of various software in a category, followed by allowing users to vote on their favorite. A few months ago, they came out with a best of the best post - listing the winners of past Hive Fives. This was updated recently with a updated list of new comparisons added since March. Note that these are not free softwares - these are just the best softwares in each cateory, whether paid or free. They recently came out with a separate set 0f the essential free software which any machine needs - called the Lifehacker pack, much like the Google Pack. Of course there is another way to get all these softwares - you can use a installer app, like RadarSync/FileHippo etc. to download and install these for you. These apps are pretty interesting - they serve the same purpose on Windows that Apt does on Linux. Not too many Windows users (even geeks) know about them though, which often leads to many of my friends claiming that there is no Apt-like option for Windows.

It is now possible to synch Outlook to Google Apps, much like Exchange. This is only for the premium version of Google apps. Considering GMail's UI and feature set, one would expect it to be far more widely used than right now. The reason its not, is first and foremost because most organizations are (rightly) not comfortable having their data on the cloud. Retraining requirements for administrators is a factor too, but I feel that is easier to overcome - its a hinderance not a deal breaker. If Google comes out with a Maill Appliance like they have a Search Appliance, Google Apps would be much more popular in the enterprise.

I downloaded M$ Morro - M$'s free antivirus a few days ago. For some reason, the site was non-functional (possibly due to overload) when I opened it. M$ were only going to allow 100,000 people to download Morro. For some reason, I couldn't download Morro during the timeframe allowed, but my MSN ID got registered as a valid tester and I was able to download it the next day. Not that I have installed it of course - I am fully satisfied with Avast thank you very much

Tuesday, June 30, 2009

Firefox 3.5 Released

Firefox 3.5 has been released. It adds several new features - including private browsing and HTML5 support. One feature I disabled the moment I installed Firefox 3.5 - Geolocation. (See the link, I also updated my tweak guide) The other strange thing - all the buttons in the Google Toolbar disappeared, and whenever I stop moving my mouse, an annoying small yellow box pops up under the cursor. (Update - See the last paragraph in this post)

This time, I didn't have as many extensions die on me as for Firefox 3.0. Automatic Save Folder died, but its usable up to Firefox 3.5b4, so possibly it will be updated to fix this. BlockSite is gone too, but I only use to it block Beacon, so I installed Facebook Beacon Blocker instead. This blocks Beacon, but it doesn't replace links with text or show a warning message on block via address bar. It'll do until BlockSite works again...

Mouse Gestures Redox has an updated version you can download from their site, so does Tab Mix Plus. Unfortunately, I use Widefox and on installing Firefox 3.5, everything went blank. So here's how to get Widefox running on Firefox 3.5:
  1. After installing Firefox 3.5, everything will be blank. Exit Firefox. (Use the Task Manager to make sure it REALLY exits - on my machine it has a nasty habit of running in the background while the window closes)
  2. Go to your profile folder - %USERPROFILE%\Application Data\Mozilla\Firefox\Profiles
  3. There will be a folder called <gibberish>.default. Navigate to it
  4. Navigate to chrome.
  5. Rename userChrome.css to _userChrome.css
  6. Start Firefox
  7. Install the latest TabMixPlus Dev Build
  8. Restart Firefox (make sure)
  9. On restart, TMP will be enabled again. This is important. Do not go to next step unless TMP is enabled first
  10. Shut down Firefox (make sure), rename _userChrome.css back to userChrome.css and follow the instructions here as before.
BTW, if you are installing Widefox for the first time with Firefox 3.5, just install TMP, follow the instructions here (after making sure TMP is working on restart) and then setting up Widefox as per the normal instructions here.

I am noticing Firefox 3.5 use less memory - it also seems faster. Lets see how it goes :) BTW, the Widefox pages are hosted on Googlepages - they will be gone soon. Might be a good idea to copy them to your hard disk :) I have shared them on my Office Live Workspace, just in case.

Update: I just uninstalled Google Toolbar and restarted. The small box is gone. Looks like Google Toolbar is not working well with Firefox 3.5. Lets reinstall and see what happens... Yup - that fixes it!

Saturday, June 27, 2009

Gaming and India

Gaming has always been an expensive hobby. More so if you live in India. The government charges exorbitant import duties, driving the price of an Arcade Xbox 360 up to Rs. 17,000 from $199.

There are few places which sell games - online shopping is not popular in India and traditional sites' inventories are woefully inadequate. Thankfully there is some movement on this front - Groove India is the first Indian site I have found that specializes in selling games. Another useful site - Consoul where you can buy/sell and trade games. Unfortunately, they don't accept credit cards and require money to be tranferred to their bank account via net banking instead. Then there's the occasional discounts/schemes offered by Gaming Indians - mostly on PC games. Lastly, in Delhi at least, there's Gamer Dreamz, a site that offers console games on rent for charges from Rs. 1000 to Rs. 1200 per month. I am not sure if this is such a good option - I can buy one game every 2 months in place of this.

Note that you can import games too - in the past I have bought stuff off Play-Asia and Shop To. Both are good, but my experience with Shop To was much better. Play-Asia has an advantage though - it often offers quirky JRPGs that dont get a US release but have an English translated Asian versions - consider Demon's Souls for example.

Also worth mentioning is Electronic Arts' India Store - this offers many EA games, at good price but only for download. Of course, you can also download many of these through Steam. The only thing is, I have long ago given up gaming on my PC - I got tired of constantly having to update my PC to in the end get pathetic framerates on games. Good PC exclusives are few and far in between and publishers seem to think its OK to release PC games with huge numbers of bugs, ridiculous requirement and invasive DRM. Consider the list of patches released for Neverwinter Nights 2. Do you know the default patcher in NWN 2 requires 10GB free hard disk space on the install hard disk? Or that patch 1.03 had over 250 fixes?

The other interesting thing that has been happening is the advent of free games - these are usually ad or micro-transaction supported. While earlier this would usually be casual games, of late even big publishers are getting into this. Of note are Battleforge and Battlefield Heroes which are based on EA's play 4 Free platform. Some other publishers are also moving to this model.

On the handheld front, Nintendo ignores India. The PSP is hugely popular here (I don't own one and never will - I have sworn never to buy another PlayStation console remember?). The interesting about the DS though is that it is thoroughly cracked - every single shop in Pallika sells a DS with a R4 or M3 or something, but I have yet to see anyone selling actual pirated DS games. You will find loads of pirated PS2 games on display, but nothing for the DS. Maybe they load ROMs if you ask them. The DS is an interesting platform - bad graphics, but popular for RPGs. There's a long list of games I want to play on it when I get time (and enthusiasm to squint on a teeny screen) But my personal favorite in this category is the iPod Touch. You can get one in Pallika for just Rs. 12,000/- and its covered by Apple's worldwide warranty. Most games on the App Store are also available in India and I have bought quite a few of them over the past months - especially because many cost less than Rs. 50, which constitutes an impulse buy - even in India.

Signing Off, Kotaku points out a list of the 100 best games to play today, as well as a list of 25 hardest games of all time. Also, there's an interesting chart of LCD screen size and Resolution vs Optimum Viewing Distance (aka Lechner Distance) linked to by Gizmodo - this shows that, for the most part people sit way too far away from their TVs to perceive the full resolution. For example, for my 32" LCD, I should not sit more than 75" away. BTW, in spite of the fact that I bought a BenQ projector several month ago, I have yet to play a single game on it :) The effort of dismantling my gaming setup and moving it the drawing room (which is where the projector has enough space for its screen) has proved to be too much for me to even try!

p.s. The PS2 is on a stand and the PS3 is hidden behind the monitor under a cloth - you can see the DualShock 3 though

Sunday, June 21, 2009

June Update

Credit Card Theft

I just had a pretty exhaustive week at work - a critical performance issue somehow found its way to a client production system and I barely got a few hours of sleep last week. Then on Friday when it seemed the issue was finally solved, I thought I would get some rest and wake up late... Nope - my dad woke me up at 6:00 AM in the morning to tell me someone was using his ICICI credit card from Lucknow to recharge their Airtel account. Now here's the interesting thing - ICICI Bank has recently force switched all their customers to iMint. My dad was so upset with this that he refused to use his ICICI card for several months. Then he used it (or rather had me use it) to pay his BSES Yamuna bill online on the 9th of this month. He hasnt used it after that - but exactly 10 days after using the card for BSES Yamuna, this happens. Suspicious isnt it?

In any case, I learnt some interesting things from that - how to send a fax via my laptop's inbuilt modem for one, how to add a fax printer and print to it from a Windows program, via the built in Fax service. Its a good idea to wipe the CVV code from your credit card so no one can copy it when you hand it off at a restaurant. Try to set up Verified By Visa or MasterCard SecureCode for all your cards. I used to use HDFC Bank Netsafe to generate temporary credit cards extensively when I started buying things online, keeping my credit card only for trusted sites that forced me to store the credit card info (like iTunes!) - I guess I got really lax on this one!

Also, use Firefox/Chrome/Opera/Safari for all transactions - anything except IE! By the way, M$ used one of their recent security updates (!) to sneakily install a nasty little .Net Framework Assistant into Firefox - which essentially allows ActiveX like code to run in Firefox - destroying the very reliability which forms one of the frameworks of Firefox. Initially, you had to do registry manipulations to get rid of it. After a lot of people cried foul on the web, M$ quietly released an update that allow you to uninstall it from within Firefox itself. Sigh... One last thing - I found a nifty little extension that will warn you when a password field is being submitted on a non-secure page - I wish Firefox hadn't removed the Yellow URL Field feature with 3.0. While you can bring it back (using Stylish) or make Firefox hilight secure pages, it still greatly reduces the security of Firefox in my POV. The extension is still experimental though.

iPod Touch Firmware 3.0

The other big thing to happen this week was the release of Firmware 3.0 for the iPod Touch. The three biggest features according to me? Micro-transactions, Spotlight and Bluetooth (Peer-To-Peer as well as Audio). The bluetooth thing is pretty amazing - here's some hardware that was always there in my iPod, I just had no way to access it and bang - its there, I can use it. Spotlight is nice in that I no longer have to scroll pages and pages of apps to get to what I need (I have 6 pages of Apps), thus allowing someone (who's crazy enough) to have more than 11 pages of apps if they want. Apple has added a lot of stuff with this update, although some people seem to have gone a bit nuts documenting every single thing.

Of course the update didnt go completely smoothely - I (very foolishly) had ZoneAlarm Firewall and Avast! Antivirus running while updating, and the update promptly failed with "Unknown Error 1604", leaving my iPod dead and me scared for a few minutes. A bit of searching and I found someone mentioning turning off their Firewall/Anti-Virus and trying again. I did that, restarted iTunes and lo! it restored and updated my iPod. Luckily I had bought the update for $9.99, not grabbed it off the internet, or else I would have been twice as scared - just having successfully voided my warranty.

I am very impressed (possibly even awed) with Apple's attention to detail. Not only did my apps, bookmarks, wireless settings get saved, but also all my app data. This was pretty significant, since I use Stanza and also have a lot of save games:) The only thing it seemed to miss was Contacts synched from Google, which came back the moment I opened the Contacts app. But what really took the biscuit was that they even backed up my wallpaper and the location of every single app on each page. As a fellow programmer, I understand how much hard work this would entail. Amazing! I am pretty satisfied with my iPod Touch right now - at least until 3GS exclusive games start coming up (although hopefully that wont be soon!)

The other interesting thing I tried out was installing iTunes 64-bit on my Window 7 installation and sharing my iTunes library between the 32-bit and 64-bit versions. It seems to work, but I would still backup my ITL file before trying!

Airtel

Lastly, it seems Airtel is now censoring the internet although they seem to have backed off from their ridiculous Fair Usage Policy a bit. Time to break out the Tor Browser Bundle people!