ParseInt(“08”) or “Why I hate JavaScript”

31 05 2011

Let’s do a little exercise. Let’s parse some numbers using JS.

ParseInt(“01”)
1

ParseInt(“02”)
2

ParseInt(“03”)
3

ParseInt(“04”)
4

ParseInt(“05”)
5

ParseInt(“06”)
6

ParseInt(“07”)
7

ParseInt(“08”)
0 (What?)

ParseInt(“09”)
0 (Wait, what!?!)

ParseInt(“10”)
10

Since Javascript uses Octal to parse numbers and starts at zero, 08 and 09 does not exist. They are therefore converted to zero. I found this out the hard way and spent a few hours pulling my own hair in frustration. My logic seemed squeaky clean and I didn’t suspect the parsing had given up on me.

The fix to this is to write:

ParseInt(“08”, 10)
8

Happy coding!

 

1257570397874





SharePoint resource throttling issue

16 03 2011

I get a lot of SharePoint work, much of it involves wrestling SharePoint and responding to issues. Here is a quick tip for anyone who encounters this error message:

sp1

The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator.

 

The solution (if you just wanna run your queries) is to go to SharePoint Central Admin > Manage Web Apps > [Your App] > General Settings > Resource Throttling.

Here you’ll find query limits set for users and admins. The tricky part is that Admins start at 20000 while users start at 5000. This means that your users may experience a problem you’ll be unable to recreate.





Debugging Videos or Camera in WP7

16 03 2011

I’ve today made good progress in the project I’m dedicated to. I amongst other things included a small video clip as a part of the application. As many of you know, video clips are fairly easy to handle in Silverlight. In XAML, it can be as easy as this:

<MediaElement Source="/Videos/MyVideo.wmv" AutoPlay="False"/>

When debugging though, the damned thing refused to work for me. I soon found out this was because of the method of debugging I was using. Here are the tree primary ways of debugging a WP7 application:

1. No phone, debug in emulator.

2. Phone tethered, debug in phone connected to visual studio.

3. Phone disconnected, code pre-deployed running on phone.

It turns out Media Elements will only display when in debug mode 3. Otherwise you’ll just see black or the first frame. This is also true for any camera functionality. If you have issues with your CameraCaptureTasks, try using debug mode 3.

                CameraCaptureTask

Developer tip #23