Author Archives: Yuriy

Jelly Bean: Android 4.1 on Kindle Fire

And the saga continues. Tired of Ice Cream Sandwich I decided to step up. Turning my Kindle Fire into a Jelly Bean device (same Android version run by Google’s Nexus 7) is a snap. Just go to this XDA thread and download bright shiny new CyanogenMod 10.

Jelly Bean on Kindle Fire

It runs much smoother than ICS, seems a lot faster and more streamlined. There’re a lot of small things (like lockscreen trailing your finger) that make everyday tablet use a lot more enjoyable.

Jelly Bean on Kindle Fire Got a few new features as well, Google Now being one of the coolest one. As you continue to use your tablet, it learns your ways and begins supply you with useful array of information – from weather and traffic of your commute, to appointments and your favorite sports teams.

It doesn’t support Flash anymore, but with the advance of HTML5 Flash becomes more and more irrelevant in such areas as gaming and video. Major apps (Google Chrome, ROM Manager, Titanium Backup etc.) love Jelly Bean and runs perfect under Android 4.1.

Even new Optimum app released exclusively for Kindle Fire runs fine under Jelly Bean (yes sometimes I get so lazy so even finding a TV remote seems as too much of an effort and on Kindle I can watch my cable without getting up).

So, if you haven’t already done so – do yourself a favor and turn your Kindle fire from nothing more than an Amazon shopping cart into a full blown Android tablet, capable of many amazing things.

Disclaimer: Do it at your own risk. I am speaking from personal experience, but I am not responsible if you brick your device.

TSQL: work with yyyy-mm-dd date format in British English

If you work with SQL Server that is set to use UK (British English) format you may experience a strange behavior: when you try to assign a date that is in ‘yyyy-mm-dd’ format to a DateTime variable or insert it into a DateTime column – an error is thrown

The conversion of a varchar data type to a datetime data type resulted in an out-of-range value

or similar. Or even worse – no error is thrown, but an incorrect date is inserted. This is happening because even though ‘yyyy-mm-dd’ looks like universal ISO format, a UK SQL Server interprets it as ‘yyyy-dd-mm’. So a date like ‘2011-07-21’ will throw the above error, but the date ‘2011-08-01’ will be stored as ‘January 8, 2001’ instead of expected ‘August 1, 2011’.

To alleviate this problem simple add a time part to your date – make the format ‘yyyy-mm-ddThh:mm:ss’. So the dates above will become ‘2011-07-21T00:00:00’ and ‘2011-08-01T00:00:00’ and be interpreted correctly by SQL Sercer

UltraWebGrid strange behavior in IE8 when IE=EmulateIE7

If you’re using Infragistics UltraWebGrid in Internet Explorer 8 you may experience strange visual (and other) issues if you have page compatibility set to emulate IE7, e.g.

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />

Issues can range from column moving not working to weird distortion in grouped mode. According to Infragistics this combination is not supported as “unstable”, but you can still make it work.

Infragistics keeps internal flags of what browser is currently in use: ig_shared.IsIE7, ig_shared.IsIE8, etc. The trick is to detect IE8 and make it fall back to IE7:

if (ig_shared.IsIE8) {
    ig_shared.IsIE8 = false;
    ig_shared.IsIE7Compat = true;
}

Place this code on top of your page JavaScript code and when it sees IE8 it will tell grid to use IE7 rendering. This is most definitely a hack, but it works.

Attract traffic and increase your site Google PR

Do you want to get #1 place on Google and significantly increase your site traffic & sales?

Then I recommend you to check out this PR4-PR8 Contextual Link Building Service – it’s quite effective. They GUARANTEE rankings & PageRank increase on Google.

Now, I know as much about SEO as a fire hydrant (and it perhaps knows more), but these guys make site promotion incredible easy. They’re doing it by providing high quality PR4-PR8 link building service, which will skyrocket your site rankings on Google, increase your site traffic & sales for ~250% within 3 months on average, and increase its Google PageRank up to PR4, PR5 or even PR6! Sign up for free at linksmanagement.com today to see what kind of links they cab build for you, and where they’ll come from. Once you sign up, you’ll also get some valuable BONUS!

UltraWebGrid: “Input string was not in a correct format” error while setting width of a column

Infragistics UltraWebGrid allows you to set width of a column in client-side JavaScript, you can do it using code similar to this:

igtbl_getGridById('xmyGrid').Bands[0].Columns[3].setWidth(someValue)

But, while executing this code on the client, you may get a nasty surprise by getting following error from the server:

Input string was not in a correct format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.FormatException: Input string was not in a correct format.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[FormatException: Input string was not in a correct format.]
System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +10163939
System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +207
Infragistics.WebUI.UltraWebGrid.StateChangeProcessor.ProcessChanges() +6230
Infragistics.WebUI.UltraWebGrid.UltraWebGrid.ProcessChanges(StateChanges stateChanges, Boolean fireEvents) +701
Infragistics.WebUI.UltraWebGrid.UltraWebGrid.LoadPostData(String postDataKey, NameValueCollection values) +7580
System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +945
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2071

Now, you do know that your someValue is definitely a number, why this error then? Let alone – why client-size resize causes a server call? But I will leave this to Infragistics. Actual cause of the error – number not being Integer. If you change the code from above to

igtbl_getGridById('xmyGrid').Bands[0].Columns[3].setWidth(Math.ceil(someValue))

it will execute without any errors. Go figure.

Correctly compare file date against TSQL stored date

If you need to track whether a particular file has changed or not (and I am not talking about FileSystemWatcher, often it’s an overkill), one way is to compare file’s LastWriteTime against stored value. But if you store the date value in SQL Server you may be in for a surprise – even if file date hasn’t changed – dates will not compare as equal. Consider following example:

'Reading current system file date/time
Dim dCurrentFileDate As DateTime = File.GetLastWriteTime(sFilePath)

'Storing file date/time in SQL Server table
CMyDatabaseClass.SaveDate(sFilePath, dCurrentFileDate)

'Immediately reading date/time value back
Dim dStoredFileDate As DateTime = CMyDatabaseClass.LoadDate(sFilePath)

'Comparing stored value against current
If dCurrentFileDate = dStoredFileDate
'
End If

The If statement on Line 11 will produce False results even if the dates seem identical. The reason – millisecond part of the datetime. SQL Server and .NET disagree on how to treat it so the best thing to do is to strip milliseconds from system file date/time before storing it or comparing against stored value.

Joe from StackOverflow.com offers a very elegant solution. That solution is in C# and here it is converted to VB.NET. To apply it to the example above simple add after the second line:

dCurrentFileDate = dCurrentFileDate.Value.AddTicks(-(dCurrentFileDate.Value.Ticks Mod TimeSpan.TicksPerSecond))

This will remove milliseconds from the date/time value and next time if you compare to the same value – values will be really equal.

Speed up Box.Net uploads

Box.Net service is know for its abysmal upload speeds, it’s a horrific sight to see your files crawl at several Kb/s, feels like blast from the dial-up past. But there’s a solution – instead of using official site – use it’s less known mirror: BoxEnterprise.Net

Box.Net fast upload

You can use it even if you have free personal account, for normal and bulk upload needs. Login and see your gigabytes fly by.

HTML Table RowSpan: Autofit spanned cells to content

Let’s say you have created an HTML table with following markup:

<table id="xMyTable" style="width:100%;">
   <tr >
      <td style="vertical-align:top">
         <div style="border: 2px solid black; background-color:red; height: 100px;">
         </div>
      </td>
      <td style="vertical-align:top" rowspan="3">
         <div style="border: 2px solid black; background-color:orange; height: 600px">
         </div>
      </td>
   </tr>
   <tr>
      <td style="vertical-align:top">
         <div style="border: 2px solid black; background-color:green; height: 100px">
         </div>
      </td>
   </tr>
   <tr>
      <td style="vertical-align:top">
         <div style="border: 2px solid black; background-color:blue; height: 100px">
         </div>
      </td>
   </tr>
</table>

It’s very basic, one rowspanned cell that holds a content with large height on the right and 3 corresponding cells with content of smaller height on the left. You’d expect it to look like this:

Desired layout of rowspanned HTML table

Unfortunately as is it works only in Google Chrome. In the rest of the browsers, including Interned Explorer and famed FireFox it looks like this:

Current layout of rowspanned HTML table

What happens is browsers automatically spread spanned cells height to evenly fit height of the cell with rowspan. To rectify this situation we need a little help from JavaScript. Continue reading →

Solution for “Operation is not valid due to the current state of the object” error

Typically this happens when AJAX controls are involved (Microsoft’s UpdatePanel or others that utilize AJAX POST requests.) The error may be displayed outright or, if nothing is shown on the UI – logged in the Event Viewer. In any case you will get a message similar to:

0x800a139e – Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Operation is not valid due to the current state of the object

Issue happens because Microsoft Security Update MS11-100 limits number of keys in Forms collection during HTTP POST request. To alleviate this problem you need to increase that number.

This can be done in your application Web.Config in the <appSettings> section (create the section directly under <configuration> if it doesn’t exist). Add 2 lines similar to the lines below to the section:

<add key="aspnet:MaxHttpCollectionKeys" value="2000" /">
<add key="aspnet:MaxJsonDeserializerMembers" value="2000" /">

The above example set the limit to 2000 keys. This will lift the limitation and the error should go away.

Starforce sucks. DRM must die

This is why piracy will always be here. This is why legitimate paid software will never take hold. Main reason being – greed of the publishers and inability to look beyond immediate profit.

I’ve purchased an adventure game “Moment of Silence” (“Момент Истины“, a Russian localisation by company called Akella). The game is perfectly compatible with all versions of Windows from Windows95 till Windows 7 64bit and beyond. BUT its copy protection system made by StarForce isn’t. Attempt to run game displays a cheery message in lines that “Copy-protection works only in Windows 95/NT/98/ME/XP“. Just how dumb is it?

I am running Windows 7. And no, running the game in compatibility mode doesn’t help. And I am not going to install “XP Mode”, which is basically a resource-hogging VM. So I had to go and find a pirated copy of that game with cracked “NO-DVD” executable included. I downloaded it – guess I am a pirate (or at least a user) now. But Akella can go screw itself, I do have a legid copy, it’s just not worth squad.