Javscript Linter – Why do you hate new?

I’m trying backbone and playing with the model concept – something I’ve implemented without a framework in the past. I’m also trying sublime text with the javascript linter turned on, and have noticed it hates “new” quite a bit.

var StandardMethod = Backbone.Model.extend({
    initialize : function(){
        console.log('init');
    }
});

var LintOk = Backbone.Model.extend((function(){
    this.initialize = function(){
        console.log('init');
    };
    return this;
})());

var LintHates = Backbone.Model.extend(new function(){
    this.initialize = function(){
        console.log('init');
    };
});
var sm = new StandardMethod();
var lo = new LintOk();
var lh = new LintHates();‚Äč

The LintOk method requires changes in 3 different places in order to create a closure-compatible function. So if I want some closure variables like:

var NowWithClosures = Backbone.Model.extend(new function(){
	var x = 1;
	this.initialize = function(){
		console.log('init');
	};
	this.AddOneToX = function(){
		x++;
	};
	this.getX = function() {
		return x;
	};
});

var nwc = new NowWithClosures();
nwc.AddOneToX();
console.log(nwc.getX());

I have to use this very verbose method in order to be lint-approved? Is there something I’m missing here? What’s the reasoning for this?

Posted in Uncategorized | Leave a comment

Dreaming of the Paperless Office

There’s this scene in the movie documentary Office Space where the crew shows just how much they love printers.

Those of us who are blessed with working in offices have all been there. Only the top half of the document prints, the scanner is blurry, or the fax machine shreds our original. As a software developer forced to support printing on a variety of systems this can provide hours of endless headache.

I spend a lot of my time building and supporting an internal web app. For simplicity we only support IE and we do most of our printing through a print specific css. Most of the time this works great, but not today.

Despite my best efforts some people, and by “some people” I mean the accounting department, still feel the need to print things every day. So a user calls to tell me that a report which printed just fine yesterday isn’t printing correctly. Specifically the first digit in the column is being put in the previous column. What?? User error? I’ve gotta see this.

I open the report in question: Works
Print Preview: Check.
Look at it on the user’s computer: Fine here too.
Print preview: Again no problem.
Print it out:

What the heck is going on here??! As you can see, the first digit in column B has wandered over to column A. Perhaps they were serving better drinks. I might need one!

Printing the same report from a different users computer: same problem. The same report to a different brand of printer: FIXED.

The solution: don’t print that report to the HP LaserJet 4350dtn printer today. Yesterday wasn’t an issue. Tomorrow probably will be fine too. But today just go ahead and use the other printer.

I need a baseball bat.

Posted in Uncategorized | Leave a comment

Failed to enable constraints

Was working on an older site connected via xsd/data sets to a legacy database. It started giving us this error:

Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
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.Data.ConstraintException: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.

That’s basically a big fat lie, as the database wouldn’t be suddenly violating key constraints. Nonsense. After some digging I determined that this error should actually read:

“The schema in the database has changed, but the xsd hasn’t been updated. Update your xsd with appropriate length on variable length columns.”

There, hope that helps!

Posted in Uncategorized | Leave a comment

NAnt on Windows 7 x64 with Visual Studio 2010

Trying to build NHibernate from a fresh install of VS 2010 and NAnt beta .90 caused me all sorts of headaches. I couldn’t get NAnt to target .Net 3.5. Here’s the error:

check-framework-version:

[echo] Running with net-2.0

BUILD FAILED

C:\Projects\OpenSource\NHibernate\default.build(117,5):
ERROR: NHibernate requires .Net 3.5.

Turns out the NAnt config is pointing at the wrong registry key. Perhaps visual stuido 2010 release is different than previous beta versions. A simple update to the registry key for the net-3.5 framework target fixed it. Previous version:


<readregistry
property="sdkInstallRoot"
key="SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0\WinSDK\InstallationFolder"
hive="LocalMachine"
failonerror="false" />

Corrected:

<readregistry
property="sdkInstallRoot"
key="SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\InstallationFolder"
hive="LocalMachine"
failonerror="false" />

Posted in Uncategorized | 1 Comment

NewEgg Fail

I’d like to relay a story of what not to do. Perhaps with some humor along the way. We’ve had trouble with newegg.com‘s website for quite some time at our company. The most recent time I was unable to order, I decided to let newegg know that I was spending my money over at amazon. So I wrote them a quick note via the their web service interface. Here’s the note I wrote:

I love giving money to newegg, but today I can’t. Seems that some combination of newegg’s shopping cart code and our corporate firewall prevent me from updating my cart. I can totally delete my cookies and start over, adding one item at a time to the cart. But today I wanted to order two of the same item, so I went to amazon. I’ll pay a little more, but at least then I can order them together.

I’ve tried the hosts file trick mentioned in your faq. I’ve tried under Chrome, Firefox, and IE8. I’ve tried it in a house, I’ve tried it with a mouse. I’ve tried it on a different day, I’ve tried it in a different way. I’ve tried it from a different box, I’ve even tried it while juggling socks.

Any ‘Update Cart’ operations timeout. After attempting to perform one I have to clear my cookies and start over.

Level of technical experience: I help build the Internet.

http://secure.newegg.com/test.aspx

E3SSL05 (172.16.21.145)

http://www.newegg.com/test.aspx

E3Web001

After the standard “we did get your email, the internet really still works” email message, I got a wonderful reply from one Lillian Hu (her real name, I’m sure) as follows:

Dear Will,

Thank you for contacting Newegg.

I truly apologize for the unfavorable situation. Please kindly note that we are not technically certified; therefore we can not provide more information or suggestions about this problems. We do apologize if this causes you any inconvenience. Possibly this is a problem at the end of the item stock and we do not have available quantity for purchase. Again, I sincerely apologize for any inconvenience.

If you have any further questions or concerns, please visit our FAQs page. If you still need assistance, please feel free to email me directly and I will be happy to assist you.

Thank you,

Lillian Hu

So tell me dear readers – how does that relate to what I wrote? Even a little bit?

So I wrote back, trying to pass this up the ladder to someone with a little more technical training.

Somehow I think my humorous and loving note was lost on you. I gave my money to amazon.com instead.

Lillian replied at one in the morning:

Dear Will,

Thank you for contacting Newegg.

I do apologize for any inconvenience. This situation is not normal. I would like to further assist this issue on your behalf. Please reply to this email with the screen shot of the problem you met with purchase, I will send report for you.

If you have any further questions or concerns, please visit our FAQs page. If you still need assistance, please feel free to email me directly and I will be happy to assist you.

Thank you,

Lillian Hu

Fantastic. I was hoping she would send report for me. Here’s my screenshot. Enjoy.

neweggfail

We’ll see if they manage to do something useful for me.

Posted in Uncategorized | 3 Comments

Images of the Recently Deceased

Recently Deceased

So sad…

Posted in Uncategorized | Leave a comment

Exchange Server Experience?

Anyone have experience pulling down email and parsing it from an exchange 2003 server? Ideally c# code, but other code would work for reviewing concepts…

For the internal web-app that I’m building I want to be able to send an email with an attachment to a specialized username+234829529308@… sequence and have the attachment appear on certain webpages. This way instead of having to navigate to a specific file or folder users can upload documents to my server by emailing them…

Posted in Uncategorized | Leave a comment

Bing Fail

Here’s a quick and egosurfing comparison of google and bing. Doing a non-quoted search for: will shaver

Google:

  • Me
  • Me
  • Me
  • Me, and others
  • Not Me
  • Me
  • Me
  • Not Me
  • Not Me

Bing:

  • Not Me
  • Not Me
  • Not Me
  • Not Me
  • Not Me
  • Not Me
  • Not Me
  • Not Me
  • Not Me
  • Not Me

Hey, it isn’t *my* fault that “Will” is a common english word.

Posted in Uncategorized | 1 Comment

Snappy Conversationalist

How Exciting

Boring conversation anyway….

Posted in Uncategorized | Leave a comment

Debugging with MVC Source

If you’re trying to debug by building the MVC source and getting something like this error:

The type 'System.Web.Mvc.ViewMasterPage' is ambiguous: it could come from assembly 'C:\WINDOWS\assembly\GAC_MSIL\System.Web.Mvc\1.0.0.0__31bf3856ad364e35\System.Web.Mvc.dll' or from assembly 'C:\Projects\mvccontrib\trunk\src\Samples\MvcContrib.Samples.UI\bin\System.Web.Mvc.DLL'. Please specify the assembly explicitly in the type name.

Then Steve will help you solve the ambiguous reference problem.

Posted in Uncategorized | Leave a comment