• Home
  • About
  • Resume

Category: Rant

Pebble Steel: DIY (some assembly required)

By , 04/01/2014 8:38 AM

Pebble Steel: DIY

Pebble Steel is a new flagship smartwatch of a widely successful kickstarter Pebble. It’s the latest craze and everybody wants one. Unfortunately the demand far outweighs the supply – it’s a well known problem. Pebble can’t manufacture enough new Steels in time, there’re many backorders, missed deadlines, a lot of frustrated, complaining customers.

But Pebble is not called genius for nothing. They found a brilliant solution, one they borrowed directly from the Apple, when the company was at its very humble beginning and was struggling as well. If you recall – original Apple 1 computer was sold as an electronic kit, that users had to put together themselves. This approach solved many problems for Apple back then and it will be very helpful for Pebble today.

Enter “Pebble Steel: Do it yourself” kit. The new Steel will ship as a collection of parts with detailed instructions on how to put them together. Since Pebble Steel doesn’t have to come fully assembled – that will seriously cut down manufacturing time and the product will ship to users much sooner. Cost saved on assembly labor will also be passed directly to customers – expect to see cheaper Steels soon. And since majority of Pebble users are computer/electronics geeks anyway, crowd that loves tinkering with their gadgets – assembling your very own Pebble Steel will come as an interesting and a welcome challenge and will make a proud owner even more proud.

Solution for SqlDataReader.ReadColumnHeader NullReferenceException

By , 08/30/2013 10:38 AM

This post related to the previous one, but I decided to write a separate article because it seems to be a common problem.

Sometimes when you use SqlDataReader, you would get an exception:

NullReferenceException {“Object reference not set to an instance of an object.”}
at System.Data.SqlClient.SqlDataReader.ReadColumnHeader(Int32 i)
at System.Data.SqlClient.SqlDataReader.ReadColumn(Int32 i, Boolean setTimeout)
at System.Data.SqlClient.SqlDataReader.GetInt32(Int32 i)

And the maddening thing – it doesn’t happen often, just every once in a while. And it happens at different times too, sometimes reader would read 100 records, sometimes 200 etc.

One possible case – SqlDataReader is losing its connection. And one possible reason for that – connection goes out of scope.

Consider following scenario – you have a function that returns SqlDataReader:

Function GetTheReader() as SqlDataReader
   Dim oConn As New SqlConnection("Connection String") : oConn.Open()
   Dim oComm As New SqlCommand("Stored Procedure", oConn)

   Dim oReader As SqlDataReader = oComm.ExecuteReader(CommandBehavior.CloseConnection)

   Return oReader
End Function

And you use it like this:

Dim oReader as SqlDataReader = GetTheReader()
'Begin use reader - loop, read data etc.

The problem with this approach that connection used to create the reader is stored in a private variable inside of `GetTheReader` function and when the function exits – the variable goes out of scope. Eventually, sooner or later Garbage Collector will collect it and close and dispose of connection – and at this time your SqlDataReader will fail.

The solution? Either use SqlDataReader at the same scope level you created it, or, if you do need to use function – pass connection object into it as one of the parameters, so it would remain valid after function exits.

When SqlDataReader is missing rows

By , 08/27/2013 10:48 PM

I have a very basic scenario:

  1. Execute TSQL Stored procedure
  2. Return a DataReader
  3. Read data from the Reader

This is ADO.NET 101. There is one problem: DataReader loses rows. This problem has haunted me forever, extensive research and numerous suggestion didn’t help, even though the code is extremely basic:

Get the reader:

m_dbSel.CommandType = CommandType.StoredProcedure
m_dbSel.CommandText = "SP_Name"
oResult = m_dbSel.ExecuteReader()

Pass the reader to class constructor to fill Generic List (of Integer):

Public Sub New(i_oDataReader As Data.SqlClient.SqlDataReader)

    m_aFullIDList = New Generic.List(Of Integer)

    While i_oDataReader.Read
        m_aFullIDList.Add(i_oDataReader.GetInt32(0))
    End While

    m_iTotalNumberOfRecords = m_aFullIDList.Count

End Sub

This problem occurs when number of rows returned by the reader is relatively large (over 600,000 records). If this happens – number of rows added to the list from the reader is inconsistent, but always less than real one. Most often “magic” number of 524289 rows is returned.

Well, this is no longer a mystery, thanks to the great people from Stack Overflow @RBarryYoung, @granadaCoder and especially @MartinSmith who was the first to point me in the right direction – and here it is.

Even though the problem is with SqlDataReader – it is happening because it is used in conjunction with Generic List. List, as you may know has a flexible Capacity for number of elements it can store. When count of elements exceeds capacity – capacity increases and always to a power of 2. E.g.

When the count exceeds 4 elements – capacity is set to 8 (2^3)
When the count exceeds 8 elements – capacity is set to 16 (2^4)
When the count exceeds 16 elements – capacity is set to 32 (2^5)

etc..

This is what makes Generic List such a powerful tool, used by many large scale .NET projects, e.g. bingogodz.com. And ordinary this is not a problem. Unfortunately this is not the case when it is used together with SqlDataReader. When count of items in the List exceeds 524,288 (2^19) and its capacity is set to 1,048,576 (2^20) – SqlDataReader’s Read method suddenly returns False even though not all records have been read. No exception is thrown, it simple stops.

The only possible workaround I’ve found so far (I am still looking for better ones) is to pre-set List capacity in advance. Since, when using DataReader, you do not know number of rows, you’re left either with hardcoding the number or running another DB query to retrieve number of rows via something like COUNT(*). Like I said, I don’t like this workaround, please let me know if you find a better one.


UPDATE: Finally figured it out: http://stackoverflow.com/a/18520609/961695

WebHierarchicalDataGrid: get_scrollTop() returns incorrect value

By , 08/02/2013 12:52 PM

Infragistics WebHierarchicalDataGrid has a neat client-side built-in function get_scrollTop() – it is used if at any point you need to retrieve current vertical scroll position of the grid (e.g. to use it in your own calculations to display something at a specific position on the grid – tooltip, help, additional info etc.)

Unfortunately the function has a bug: its value only set if user actually manually scrolls the grid: using mouse and scrollbar on the right, keyboard etc. If no scrolling user-interaction is involved and scroll position changes due to other means (e.g. displayed data size changes) – the function retains original value, throwing all your calculation out of whack. Continue reading 'WebHierarchicalDataGrid: get_scrollTop() returns incorrect value'»

Solution for IE10 error: SCRIPT5022: Sys.ArgumentOutOfRangeException: Value must be an integer

By , 05/01/2013 2:05 PM

If you’re testing your ASP.NET project in Internet Explorer 10, you may encounter following error:

SCRIPT5022: Sys.ArgumentOutOfRangeException: Value must be an integer.
Parameter name: (x or y)
Actual value was (some floating point value)
ScriptResource.axd, line … character …

Often it come up when you use some 3rd party libraries, Telerik or Infragistics (in my case it happened in WebDataMenu control).

Here why it happens. Continue reading 'Solution for IE10 error: SCRIPT5022: Sys.ArgumentOutOfRangeException: Value must be an integer'»

Access your PC files remotely via SkyDrive on mobile device

By , 04/30/2013 1:07 PM

If you use Microsoft Skydrive application on your Windows machine, you know that besides syncing local dedicated Skydrive folder to the cloud it allows accessing your PC files directly (without uploading them to the cloud) from remote location. Unfortunately this feature is available for desktops only, mobile apps are “by design” missing it.

But what prevents you from logging into Skydrive Website directly from a mobile Web browser?

Skydrive In Mobile Chrome

After authorizing yourself with security code you’re in! Albeit this is not as convenient as a native app would be, but until “design” changes this approach allows you to access your PC’s files without installing any additional software on the PC and without downloading any additional app to the device.

ABCMouse.com contact number is 800-633-3331

By , 02/07/2013 11:50 AM

ABCMouse.com offers teaching games for kids. Some like them, some don’t – it’s a matter of taste and preference. What really sucks about the site is their contacts – they never respond to emails, and online contact form isn’t of much use either. And nowhere on the site they list phone number for a contact.

Fortunately such number does exist:

1-800-633-3331

And when you call it, surprisingly, you get to speak to a live person, who resolves your problems pretty quickly.


DISCLAIMER

I feel really silly posting this disclaimer, but due to numerous comments here it is: I am in no way associated with ABCMouse.com. I myself had a bad experience with their service and when I found their direct phone number I decided to share it with the others to spare them the frustration I went through. So, again, I am not charging your card, I cannot cancel your account, please CONTACT THE COMPANY VIA NUMBER ABOVE!

It’s confirmed: Apple sucks!

By , 01/29/2013 10:32 PM

I long suspected that Apple played dirty, just didn’t know to what extent. Today I got a chance to find out.

An iPad mini came into my possession, so I registered an online “AppleID” account. This required all kinds of contact information, including cell phone number which I provided. Soon after registration I began to receive spam calls and text messages. No, not from Apple, oh no. These came from auto insurances, money making schemes and other such scum. Wherever did they get my number? I have had it for several years and NEVER received any spam until this fateful day.

But this is just a beginning. I decided – to hell with it, I was willing to give Apple a chance and they blew it. So now I wanted to delete my account and all associated data. Surprise! You can’t do this online. At http://appleid.apple.com you can only change some contact info, but that’s about it.

So I called support. They requested my device serial number. That made me really wonder – why? If I want to cancel my Google account – they don’t request my Droid phone s/n. Ditto Amazon & Kindle. So why, Apple, why?

The support agent enlightened me. This is needed so I could be charged for this paid support call! I needed to pay to get information on how to cancel my account.

Well, this is really it. Back to Android. Oh and by the way, I don’t see what’ s the fuss is about. As a tablet iPad is pretty average, it does pretty much what any other tablet on the marked does. A few years ago when it was the only thing – maybe it was something. But now – Apple lost it.

Solution for: Value of type ‘System.Web.UI.HtmlControls.HtmlGenericControl’ cannot be converted to ‘System.Web.UI.HtmlControls.HtmlTableRow’ error

By , 11/08/2012 1:14 PM

If you’re trying to compile an ASP.NET project/website in Visual studio 2012 or 2010 and getting error:

Value of type ‘System.Web.UI.HtmlControls.HtmlGenericControl’ cannot be converted to ‘System.Web.UI.HtmlControls.HtmlTableRow’

chances are you have an HTML table in your ASPX markup with runat="server" attribute set and <tbody> or <thead> tags present. Remove <tbody> and <thead> tags and the error should go away.

Run Adobe Flash Player on Android 4.1 Jelly Bean (and above)

By , 09/11/2012 2:18 PM

It is a well known fact that Adobe is willingly shooting itself in the foot stopped supporting flash on Android devices. If you run Android 4.1 (Jelly Bean) it is not even available on the Google Play. Oh and speaking of Google – unlike its desktop counterpart Chrome for Android doesn’t support Flash either.

So.. is this the end of the era?

Fear not. Just download and install this handy Flash APK and install it on your device. Voila! Your mighty tablet/phone now has Flash. It still won’t work in Google Chrome, but other browser (Stock, Dolphin) will happily use it.

Panorama Theme by Themocracy