# Thursday, 05 December 2013

When Internet Explorer 10 launched, it caused some problems with the antiquated browser detection feature of ASP.Net, and thus you needed to make sure that you installed the right patches or performed the right fixes in order to get everything working properly. And I talk about the IE10 incident here on my blog.

And now Internet Explorer 11 has just been auto updated to many users, and again I was seeing problems with my websites. At a MUCH worse scale this time I might add, not only were scripts not being sent ASP.Net didn't think IE11 was capable of receiving cookies which just royally broke the website.

Sometimes your site might seem ok, but buttons are not working and everything that seems to be tied to Javascript seems to be malfunctioning, looking into the Javascript debug console you see something similar to this message :-

'__doPostBack' is undefined

or something like

'WebForm_DoPostBackWithOptions' is undefined.

Once again Scott Hanselman talks about the problem, and mentions the obvious solution of ensuring your server patches were up to date.

But I couldn't get my client's servers patched for some reason, so I hunkered down and tried to manually patch the browser definition file. At first I thought I could just insert the new version into the existing IE browser definition file like it was done for IE10 the last time. Then I actually saw the IE11 user agent string:-

Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko

The MSIE moniker which was used to identify Internet Explorer was DELIBRATELY removed, because IE11 is more than capable of handling HTML5 now and they didn't want any poorly coded Javascript library to incorrect identify IE11 as being an older, less HTML5 capable browser and tell users to use some other browser instead. Very good intentions I must say, too bad ASP.Net brefore 4.5 happens to be one of those legacy systems that do User Agent sniffing and because it didn't see anything it knew was defaulting IE11 to something which couldn't handle Javascript, Cookies, and many many other things.

At first I thought about writing a regular expression pattern which could parse the new User Agent and identify the browser properly. But there were 2 problems with that idea. The first was that I was CRAP at writing complex regular expressions, the second was the fact that why should I even bother with browser sniffing? Every damn browser supports Javascript now, and websites pretty much NEED Javascript anyway. So I set about to make it so that the default browser definition enabled all modern features.

I did so by overriding the default browser defintion at my web site level. First I created a app_browsers folder in the root of the web site, then I create a file called newdef.browser with the following content

UPDATE Jan 30th 2013 : You might not see changes right away when you drop the file in, you might want to try restarting the IIS web pool, if you can't do that, try toggling the compilation/debug attribute under system.web in the root web.config file by alternating it between true and false to restart it.

<?xml version="1.0" encoding="utf-8"?>
<browsers>
<browser refID="Default">
 <capabilities>
  <capability name="browser" value="Generic UpLevel" />         
            <capability name="type"                            value="Generic" />
            <capability name="ecmascriptversion"               value="3.0" />
            <capability name="javascript"                      value="true" />
            <capability name="javascriptversion"               value="1.7" />
            <capability name="w3cdomversion"                   value="1.0" />
            <capability name="supportsAccesskeyAttribute"      value="true" />
            <capability name="tagwriter"                       value="System.Web.UI.HtmlTextWriter" />
            <capability name="cookies"                         value="true" />
            <capability name="frames"                          value="true" />
            <capability name="javaapplets"                     value="true" />
            <capability name="supportsCallback"                value="true" />
            <capability name="supportsDivNoWrap"               value="false" />
            <capability name="supportsFileUpload"              value="true" />
            <capability name="supportsMaintainScrollPositionOnPostback" value="true" />
            <capability name="supportsMultilineTextBoxDisplay" value="true" />
            <capability name="supportsXmlHttp"                 value="true" />
            <capability name="tables"                          value="true" />
        </capabilities>
</browser>
</browsers>

What the file does is that it overrides the default browser definition of a crummy featureless browser to a more up to date one which supports all the cool stuff like cookies, Javascript, etc. etc. I basically just copied all the capability tags from the Chome browser definition file.

WARNING : If for some poor unfortunate reason that you actually RELY on ASP.Net's browser detection feature to detect ancient browsers this will effectively BREAK the function so do so at your own risk!


Thursday, 05 December 2013 23:29:33 (Malay Peninsula Standard Time, UTC+08:00)  #    Comments [0]  | 
# Saturday, 23 November 2013

I always seen these USB charge boosters on sale all over the place.

WP_20131123_001

But I never trusted them, since there was no way I could actually see wheter it was working or not other than through a gut feeling. But a few weeks ago I acquired a USB voltage meter, so now I CAN see wheter it works or not!

A disclaimer before hand, I'm not an electrician, but just someone who has read up on the topic on the Internet so if anything blows up when you try this. Don't blame me.

The speed of your charging depends on how many AMPs flows into your device, based on this Wikipedia article on USB charging we find out that normal USB ports usually only supply 500mA whereas it's possible for a dedicated charging port to deliver more than that.

I've measured most of my USB power sources previously, and other than the dedicated power plugs which came with the phones, they all delivered only 500mA of current when charging. Whereas the dedicated plugs could supply roughly 1A.

So I tested it with the the charger in my car, a Kensington Duo Powerbolt Charger first we use it without the charge booster.

WP_20131123_004

And the charger supplies juice at a current of 0.5A. Next we plug in the charge booster.

WP_20131123_003

Now the current is around 0.8A, definitely higher although not exactly the 2 times faster that the box is talking about.

So I guess it DOES work, even though it might not be as good as they say it is but I guess every little bit counts when it comes to juicing up your devices faster.

One interesting caveat though, the booster has 2 modes of functioning, one is where it'll boost your charging but it means you can't transfer data with your PC in this mode even if it's connected to a PC's USB port. The other mode is normal mode where you can sync data with your PC. My Nokia Lumia 1020 behaved EXTREMELY weird when connected to anything in this mode, basically the phone kept dropping in and out of charge mode, probably due to how the current is being passed through it. I recommend that if you do get this and you need to be NOT in boost mode? Just don't plug the thing in.

Because of this little issue, I have a theory about how this thing works. According to the Wikipedia article a dedicated charging port is identified by shorting it's data pins, so what this charge booster is doing could just be that it's shorting the data pins when it's on so that the device knows it can draw more current from it.

You can find this thing around town, I've seen them selling between RM60 to RM40 under various brands (since it is some China OEM product I guess) The cheapest price was at IP Mart so you can go check it out if you're interested.

A few more things to be aware of before you go.

  • Charging at a higher current heats up the battery/device faster. And since doing data transfer intensive processing on the device (like using Waze) also generates a ton of heat on the device, your device might get pretty hot with this. And then 2 things might happen, either the battery stops charging due to it's thermal protection circuit, or if the thermal protection circuit is faulty the battery *might* catch fire. :P Depends on the ignition temperature of the components inside the device I guess.
  • Someone once told me that if you had a device that was drawing much more current than the power supply could provide at best nothing happens and your device doesn't get charged, at worst you damage the power supply.

Scared yet? ;)


Saturday, 23 November 2013 12:03:00 (Malay Peninsula Standard Time, UTC+08:00)  #    Comments [0]  | 
# Monday, 18 November 2013

I recently got the ultra awesomely nifty Avermedia Game Capture HD II (what not a 2?) Why does it deserve such a title? Because it's not just a simple hardware HDMI capture device, you can actually include audio commentary edit AND upload the video from the box itself as well!!! Check out the review!

Trying to be funny, I recorded WZ doing the edit and upload demo. But he wasn't very cooperative since I didn't rehearse it with him so I left his part out of the video. You can watch the rejected bits below.


Monday, 18 November 2013 11:44:34 (Malay Peninsula Standard Time, UTC+08:00)  #    Comments [0]  | 
# Sunday, 10 November 2013

One important thing which I should regarding my previously comments regarding fuel consumption in my Nissan Serena S-Hybrid follow up post.

My daily office commute doesn't consists of any stretch of highway or anything which would allow me to go above 70km/h for any long stretch. Here's a more detailed table of the fuel consumption based on my records.

Fuel (Liters) Distance (KM) Consumption (KM/L) Average Speed (KM/H) Car Running Time
40 330 8.25 23 14 Hours 2 Minutes
48.22 358.5 7.4 19 18 Hours 23 Minutes
49.29 349.9 7.09 19 18 Hours 10 Minutes
51.37 408.3 7.9 22 18 Hours 17 Minutes

Fuel usage is obtained by pumping to full tank at every cycle. Average speed and Car Running Time is obtained from on board instrumentation.

Below is an Excel Spreadsheet which if I feel like it I'll update to have a better idea of my ongoing fuel consumption. So the data below would be more updated.


Sunday, 10 November 2013 21:16:51 (Malay Peninsula Standard Time, UTC+08:00)  #    Comments [0]  | 
A few years ago Microsoft introduced a new ASP.Net feature called ASP.Net Web Pages. I found the light use of control tags intriguing, but I didn't see any reason to use it instead of the standard ASP.Net Web Forms style of developing web sites. It also didn't help that Microsoft seemed like it was talking about Razor as a side component to be used with ASP.Net MVC another new feature which I wasn't too keen on. But recently as I sat down to take a look at Razor once more, it finally dawned on me what Razor is actually good for. So make yourself a drink and come back to the longest code snippet filled article ever written by me on this site!

Sunday, 10 November 2013 21:00:45 (Malay Peninsula Standard Time, UTC+08:00)  #    Comments [0]  |