Random header image... Refresh for more!

The Extendables

And when your example code relies on extension methods, please make sure that you have the namespace which contains those extension methods references.

I am so ready to take the Baseball Bat of Great Justice and hand out a Beat Down Of Many Angers on these people.

Listen, it’s simple:

  • .Net 3.0 was largely a mistake.  var and extension methods were part of that mistake.  Don’t use var and extension methods all over the place.  If you don’t know the right place to use them, don’t use them at all.
  • THE DOCUMENTATION MUST NOT SUCK.  No documentation is often better than bad documentation.
  • CODE SAMPLES MUST COMPILE.  You have to realize that people are going to copy and paste whatever is on your page and try to compile it.
  • The easiest way to meet the requirements of THE DOCUMENTATION MUST NOT SUCK and CODE SAMPLES MUST COMPILE is to write a sample class, test it, then paste the entire class into your page.

GRRRRRRRRRRRRRRrrrrrrrrrrrrrrrr

September 5, 2010   No Comments

var-y annoying

I want to smack people who use “var” all over the place in their code.  Particularly in their example code.

I AM NOT A COMPILER.  I DON’T DO TYPE INFERENCE.

September 5, 2010   No Comments

Authorization Required

I’m stuck in Twitter API Authorization Hell.  Apparently username/password combos are too old school.

September 5, 2010   No Comments

‘COMPATIBILITY’ is undefined

At work, I’m currently spending most of my time developing an internal webapp.  It’s the first significant work I’ve done in ASP.Net MVC and JavaScript, so it has been a great learning experiment.

Yesterday, I added a feature that involved JSON serialization to carry data on a round trip from the server to the client and back.  The feature is fairly straightforward:  The server writes one of its data objects to the page as a JSON string, which lets the JavaScript on the page interact with the object.  In response to a user action, the page will package up the object in JavaScript, turning it back into a JSON string, and pass it back to the server.  It feels like a bit of a hack, but hey, it works.

It works in some browsers, that is.  To get the object back into JSON format for the trip back to the server, I was using the method JSON.stringify(object).  The JSON object is apparently natively supported by IE8 and FF3.5 (And maybe Chrome, although I didn’t check), and since the target audience of this internal tool is already using one of those browsers, I don’t have to worry about compatibility.

Before checking into our CI system, which will deploy the code to a testing server, I run it locally.  Works fine in IE8.  Works fine in FF 3.6.  Everything’s happy.  SVN Commit and continue working.  If it’s working HERE, it’ll work THERE.

Or not…

About an hour after I check in this change, I go take a look at the testing server to verify a couple of unrelated changes.  I click on a link and I get a JavaScript error.

'JSON' is undefined

Um…  Excuse me?  I’m using IE8, which I know has a native JSON object.  It’s one of the things they brag about adding in IE8.  It’s there.  I know it’s there.  This worked just fine when I’m running it on my box, and it’s not like there’s some file I forgot to deploy that could cause a native JS object to disappear.  It has to be there…

So I try it in Firefox.  If something went wrong with the deployment or the testing machine, it would be broken in Firefox, too.  Of course, it works fine there.

I scour teh Intarwebz for help related to this error and find nothing useful.  Most of the advice is “Well, did you include ‘JSON2.js’?”, which is a file I’m not using and don’t need because JSON is a native object now.  It has to be there…

After wasting about an hour trying to find a solution, I performed my favourite problem solving manuever:  Throw away everything you know about the problem and start from scratch.  The branch of thought I was on before didn’t get anywhere, so it was time to explore a new direction.  In the initial search, I was looking for a solution to the “JSON is undefined” problem.  But maybe that’s not the problem.  Maybe that’s just the symptom of a different issue.  So now, I have to find what the problem really is.

  • Did the code not get checked in right?  The code is fine.  Nothing’s left in pending changes.
  • Did the JavaScript not get deployed correctly?  The deployment is fine.  All script files I have locally are on the testing server.
  • Have I ever come across anything like this before?  Yes.  IE’s security settings will treat intranet sites differently than Internet sites.

IE security settings…?  Well, that’s easy enough to check.

I go back to the page and change the server in its URL to be the fully qualified internal domain name for the server, not just the name of the server itself.  Hit the link…  Hey, it works!

So…  IE security settings, perhaps?  I consider simply ignoring the problem and telling everyone who uses this app to access the server with the full domain name, but quickly realize what a stupid solution that would be.

Why would this be a security setting, though?  Whenever I’ve run afoul of IE’s security model, it’s because I’ve been doing something that IE thinks could potentially be a risk to security.  It rarely is an actual risk (Unless trying to expand and collapse nodes in an XML file is risky in ways I cannot fathom), but there’s usually some semi-rational reason for blocking an action.  Killing the JSON object isn’t rational.  You can’t do anything with it that you couldn’t already do in JavaScript.  So why disable it?

And that’s when I noticed something.  On my localhost page, there was that little “broken page” button next to the address bar, but that button wasn’t there on the testing server.  WTF?  I didn’t force compatibility settings on the testing server, so why is that button missing?

I open up the Compatibility View Settings dialog and I find this inside:

“Display intranet sites in Compatibility View” is checked BY DEFAULT.

So, Compatibility View is what makes your browser act like IE 7 because so many websites out there were hacked together to work in IE6 and 7 because that’s whate everyone used.  As you may know, IE 6 and 7 were a bit wild when it came to rendering things, prefering the cowboy way of going it alone and doing what feels right, rather than, you know, attempting to follow standards.  When IE8 came along and fixed a lot of those issues, it meant that some poorly designed older pages looked like cat vomit.  So, Microsoft put in the Compatibility View button to make the pages render like they did in IE 7.

That’s all well and nice, except that A: They turned it on by default for intranet sites, and B: It’s not just rendering.  This is important, because I had no idea about this until yesterday.  Compatibility View also rolls back the JavaScript engine in IE to the previous version.  So…  No more JSON object!  Poof!  Gone!

DAMN YOU, IE6.  I’M NOT USING YOU AND I’M NOT EVEN DEVELOPING TO SUPPORT YOU AND YOU’RE STILL MAKING MY LIFE HELL.

So, what did I do?

<script src="Microsoft.Ajax.js" type="text/javascript"/>

That has its own JSON object in it and made my problem go away.  It’s a cop-out, true, but I don’t really care.  I’m trying to write an application that has absolutely nothing to do with stupid default compatibility settings and JavaScript engines and all that other nonsense.

August 18, 2010   4 Comments

Achievement Unlocked: Big Truck Of Fail

That’s it.  I’m calling it.  This Crazy Project Weekend is over.

And it’s a big truck of fail.

The biggest problems are the motors.  They just don’t do what I tell them to do.  If they did, this would be a different story.  But I’ve spent over three days tweaking the motors and the robotics and I just can’t get it working.  Maybe I can get a Stelladaptor and try tweaking it with direct feedback.  Maybe I’d be able to do continuous smooth motion if I could have tracked all the bombs properly.  Maybe I just don’t know what I’m doing.

At least I was able to identify the playfield elements and get the computer to tell what the next move should be, even if I couldn’t actually get it to make that move.  The basic recognition and logic was a lot easier than it was for Pong, mainly because trajectories didn’t really matter.  However, I wasn’t quite able to get the bomb tracking/prediction logic working, which would have reduced the tendency for the robot to get distracted temporarily and miss a bomb.  The full tracking also would have made it possible to detect patterns and move smarter.  I also get the feeling that there’s something already in OpenCV that would have taken care of the object detection and motion tracking for me.  That library is so big and I’m not a computer vision expert, so I don’t really know what’s there or how to use it all.  The book and the documentation aren’t always enough.

And then that virus.  Stupid virus.  Make me waste half a day because the bloody computer stops working.  THAT WAS AWESOME.

The segmented auto-calibration thing did work.  I was able to adjust the robot power and swap out gears and the calibration generally figured out the new pixel/degree ratio.  If the motors were more consistent, then it probably would have worked better.  At any rate, that’s a decent technique that I’ll have to remember for the future.  And I’ll have to clean up the code for it, right now it’s kinda messy.

In the end, I did not accomplish what I set out to do.  The best score the robot ever got was 63, and that was a fluke.  And I didn’t even get close to trying to get it to play on a real TV.

March 1, 2010   No Comments

Bug Tracking

That ain’t right.

And I only have five hours left.

March 1, 2010   No Comments

Seven Hours Remaining

I’ve got just under 7 hours to make this work.

March 1, 2010   No Comments

Taming The Beast

I’ve spent the better part of the last two hours trying to look for a way to make the robot slightly less homocidal.  I came up with someone else who needs to do the same thing I do, that is, rotate the motor 45 degrees exactly and not have it go all wobbly or insane. He’s got loads of graphs, but no solutions.  Apparently there’s another firmware which does really great, if you want to put a non-standard firmware on the NXT and risk bricking the brick.

Then there’s another guy who’s produced a 37 KB executable that’s suppose to do quick and precise rotation.  Never mind that it’s 37 KB worth of code for an embedded system with limited RAM.  Never mind that it’s tainted by the GPL (And the “You Suck Microsoft” GPLv3, at that).  If it does what I need, I’ll use it.

Except…  It doesn’t do what I need.  In fact, it appears to have absolutely no redeeming qualities about it.  The motor still waggles, pretty much the same amount as the normal command.  On top of that, it makes the brick beep.  WTF?  Why do I want the brick to beep when I’m moving a motor?  Then it’s got some questionable coding practices, including encoding command messages as ASCII characters which have to be parsed and interpreted, because obviously, you want to add all the overhead you can when you’re dealing with embedded systems and time-critical operations.  And it’s an executable, not a library, so if there’s anything else you want to do on the NXT side, you’re screwed.

So, I still don’t have happy movement.  I think I’m just going to tone down the motor power a bit and hope it behaves better.

I only have one day left to get it right.

March 1, 2010   No Comments

Achievement Unlocked: Welcome to Raccoon City

So, I’ve lost half the day to a stupid virus.  WONDERFUL.  After repairing my Master Boot Record from the XP Recovery Console, I’m hoping that it’s gone now.  Of course, I can’t tell because all of the Anti-Virus/Anti-Spyware tools I’ve used are COMPLETELY WORTHLESS and didn’t catch it or any of the previous outbreaks there’ve been.  I wonder if it’s been with me for months and can explain these randomly recurring virus hits that come out of nowhere and never seem to die, too.

I’d really like for someone to explain where it came from originally, too.  There has to be something I did wrong, somewhere that I let my guard down, and I’d like to plug that hole.  If I’m going to get randomly hit with no explanation while being safely behind a firewall and anti-virus program, then to hell with it, I’m going to start going to porn sites and start torrenting WaReZ.

February 28, 2010   No Comments

Crazy Weekend Project #4

I know what Crazy Weekend Project #4 will be.

It will be a real-world implementation of robotfindskitten with a special additional mode where the robot hunts down people who write rootkit/MBR viruses and beats them repeatedly with a large metal pipe.

Perhaps it could train the kittens it finds to develop a taste for blood, too.  That could help greatly.

February 28, 2010   No Comments