Value cannot be null. Parameter name: source

April 25th, 2013 by admin No comments »

Sometimes you may get this error when you are debugging a linq query and it may seem pretty vague to you, and it is, very.  In my situation I didn’t have a parameter name called “Source” or a property named that either, it turns out the problem was a property I had in my linq query that was in fact null and when you execute a query across stuff that may be null you can run into stuff like this.

If  you see this error when you writing code, the easiest way that I know to figure out your problem is to look into anything the query is grabbing that may have a null in it.  Just simply start commenting out stuff and see what happens.

Good luck and I hope this helps someone!!

Underscore.js attempts to read commented HTML

April 11th, 2013 by admin No comments »

I just wanted to throw this out there for anybody trying to figure out why their underscore templates may be failing with properties in their commented html.  It looks to me like underscore.js actually parses everything in the html file in certain situations, I am not fully sure yet but I couldn’t really find much on the web that spoke about it.  I thought I would throw this blog post up so anybody noticing this that has seen it before could chime in and offer some insight into this.  What is weird is that it doesn’t always do it, but only seems to when a change is made at some point to the template being rendered, very strange.  I guess for now my only alternative would be to remove the <%= %> in my comments.  If anybody has some alternatives I am all ears.

How to get all items from an HTML table with JQuery

April 9th, 2013 by admin No comments »

Here is a little snipped that saved me a lot of manual code writing if you are needing to iterate over a set of rows in a table you have on your webpage. Just simply use the “gt(0)” which according to the JQuery API documentation “select all elements at an index greater than index within the matched set.” Then just pair that with tr: in front of it to select all the table rows of your table and voila, you have all your rows. You can then use the .each method to do the iteration. Don’t forget to change #tableId to whatever you called it in your html, enjoy.

1$("#tableId tr:gt(0)").each(function () {
2    //perform logic here
3});

Microsoft 2013 Build Conference a.k.a (We failed, come see!!)

April 1st, 2013 by admin No comments »

build
So the Microsoft Build conference has been announced for June 26th – June 28th (Build Conference) this year instead of the fall like last year and its at the Moscone center, the exact same place as the Google IO conference this year.  I am sure its at the Moscone center due the fiasco Microsoft had last year deciding to have it at their headquarters, which was not set up for a large scale conference of this type.  Several developers were booted out of their sessions and makeshift tents had to be setup for sessions, it was a true mess.  So Microsoft has yet again decided to follow another companies footsteps and have their conference in a real location this year, that should work, now on to the announcement.

Microsoft announced they are going to be unveiling Windows “Blue” which is basically the fix to Windows 8 cause you know, in true Microsoft fashion, they rush products out the door to get those sales, beat the holidays, etc.  If you look through this list of “features” coming to Windows 8 (Windows Blue) you have a hard time arguing that they are really just features that should have been in Windows 8 all along, this is not innovation my friends, this is how you gouge customers.  But its been the mantra of Microsoft for years, its what they do and they do it well.  I don’t think they are going to charge for it as that would only infuriate the users that are already disappointed with it.

Here is the list: List of Features

I don’t want to just hate on Microsoft but IMO they are the worst of the big companies like Google and Apple.  Yes, you could argue that Apple gouges its customers with expensive hardware but my MacBook Retina is a very nice piece of hardware and you can’t get a machine like it with its resolution until now with the Google Pixel.  OSX is a superior operating system to windows 8, even with win 8’s new flashiness, I just want to get work done and OSX still runs circles around it, with minimal updates.

So tell me why I would want to go to a conference where I am just going to be hearing how a company is still trying to play catch up with a product they have failed at getting the public to buy into?  Get free stuff you say?  I could take the $1600 (early, probably $2100) and get myself a surface pro and have money left over.  But you would get a phone too you say?  The iPhone is still superior to the windows phone, developers are still not jumping on the winphone bandwagon.  Facebook and Google refuse to make apps for it which is why 3rd party developers are jumping in and doing a horrible job at it  Microsoft had to roll their own facebook app to get users to use this phone!!!  If that doesn’t tell you something, nothing will.

I am amazed that a company with the resources of Microsoft cannot do a better job than Apple or Google, its truly amazing, they were the big dogs for years but they just simply can’t keep up anymore.  I am sure their past history with the open source community hasn’t helped any with efforts.  From what I can see, they have painted themselves into a corner and the technology field is just passing em by.

Even better way to clear your Web SQL or local dbs in Google Chrome

March 25th, 2013 by admin No comments »

Thanks to one of my visitors to my site, I have been directed to a much easier and cleaner way to delete your local databases in Google Chrome, simple put this into your address bar in Chrome: chrome://settings/cookies and it will pull up a screen similar to this:

cleardbs
I just simply did a search for “localhost” and it pulled up my site which looked like this:

localhost

From there you can delete whatever you want, individual dbs or cookies, any of it.  A much better solution that going out to the file system and blowing away folders and files that are usually in use by chrome which requires a shutdown of all the chrome processes.  I hope this helps others, enjoy!!

Add some sweet logging to your Javascript/Node.js apps with Winston

March 19th, 2013 by admin No comments »

If you are looking for a logging solution to your javascript or node.js apps, look no further, enter Winston.  This little tool can write logs from your apps to a file, to the console, or to a database and you can even query the logs with its own built in syntax, how sweet is that?  Anyways, I have included below the code snippets that is needed to get it going, check it out:

1//by default, Winston is set to log to console
2var winston = require('winston');
3 
4 winston.log('info', 'Hello distributed log files!');
5 winston.info('Hello again distributed logs');
6 
7//you can change that behavior by doing something like this:
8winston.add(winston.transports.File, { filename: 'somefile.log' });
9winston.remove(winston.transports.Console);

Here is the github repo for further reading if you are considering this tool https://github.com/flatiron/winston

Pretty simple, just three lines of code and you are logging, just slap a winston.info() anywhere you want to see some info and you are good to go, enjoy!!

Netflix Comes to the Samsung Arm based Chromebook!!

March 12th, 2013 by admin No comments »

I love my chromebook, on my blog here you can find other posts where I am dual booting it with Ubuntu off of an SD card.  I have since added a 32GB slim jump drive for extra space, its more than I would ever need, but I thought it would be cool to have that kind of storage to move movies around or music or whatever and it was only $20 from amazon.

Anyways, back to my post subject, when I bought the chromebook I knew full well that netflix did not work with it, but at the end of last year you would get a screen like this one below:

chrome-os-error-netflix

Well, I knew from that error that it would come down the road, so I thought it would just be an extra benefit, albeit one that is a very nice feature of the device, especially on trips and such, since the device is so light and for only $249, you can’t beat it.  That day is finally here!!  You may have to grab the latest update for your device by going to settings and then help, just stay on that page, your device will update if it needs it, but if you are like most, you will have all the latest updates and you will be ready to go, enjoy!!

Using Socket.IO with Backbone.js

March 6th, 2013 by admin No comments »

I work on a lot of different projects, some for work and some for fun and some on the side.  I have been working on a social application here lately that will have lots of topics and within those topics they will have comments.  I felt like the ‘Room’ concept of socket.io would be a good fit for this idea so I began implementing it for this project.  When I first set up socket I was having a problem because stupid me had some javascript that was formatted incorrectly and the engine was not throwing an error with it because it translated to good javascript.  In the meantime while I was doing all of that I had stuck the socket connection in a global variable so it was only making one connection, that does seem to be how you would want your socket.io application to be setup anyways.

I have included the final code below of the solution that is working for me with my backbone views, it turns out I had to create a new socket.io connection each time a topic was clicked on by the user, due to the fact that I am ‘joining’ them to that room, identified by the TopicID.  When I had the socket defined globally, I was getting duplicate messages back to my clients and my only reasoning was that I had the single connection so my clients were getting those dupes back at them.

If you have anything you could throw in for me with input, I would really appreciate it as I think this setup is not a very scalable one, thanks.

01//server.js
02var io = require('socket.io').listen(server);
03io.sockets.on('connection', function(socket) {
04  console.log('Socket Connection Made - Server Side');
05  socket.on("leaveRoom", function(data){
06      console.log('Leaving room ' + data.room);
07      socket.leave(data.room);
08  });
09  socket.on("setRoom", function(data){
10      console.log('Joining room ' + data.room);
11      socket.join(data.room);
12  });
13 
14  socket.on('comment', function(data) {
15    console.log('Emitting comment');
16    socket.broadcast.to(data.room).emit('comment', data.comment);
17  });
18});
19 
20//client.js
21//in backbone view initialize()
22var url = "http://localhost:3000";
23this.socket = io.connect(url);
24this.socket.on('connect', function () {
25    that.socket.emit("setRoom", {room: that.model.get("TopicId")});
26});
27this.socket.on('comment', function (data) {
28     $('#commentsList').prepend(data);
29});
30 
31//here is the code to tell server a new comment has been published
32that.socket.emit('comment',{ comment: msg, room: that.model.get("TopicId")} );

Calculate Percentages from Two HTML inputs with javascript

March 1st, 2013 by admin No comments »

I recently had a need for a generic way to calculate 100% across two input boxes, for instance if you entered 50% in one box it would go over and put 50% in the other, and vice-versa.  Well, I have accomplished this with a little help from jQuery and for formatting I use the excellent javascript library called autoNumeric found HERE.  Make sure you use the one I have referenced here in the fiddle as others would not let the autoNumericGet work, it must have been older versions. I have linked my jsFiddle below, check it out, run the sample and see how it works, hope this helps someone.

If you can’t see, the fiddle, here is a link to it:
http://jsfiddle.net/eddie_d_2000/H92FC/

When should you use CQRS or event sourcing?

February 28th, 2013 by admin No comments »

I am currently in the process of helping migrate our current legacy application to an event sourced system, also known as a CQRS (Command Query Responsibility Segregation) system.  We have had some pitfalls for sure and I wanted to outline some of that in this post.  We went with the LOKAD system which can be found here: Lokad Project.  It has hooks into the Microsoft Azure cloud solution so it was a great starter for us to get rolling with that.

The system actually ran fine for quite a while just getting data in and out, things were working perfectly until we decided to throw a lot of commands at the server and see how that processes that.  Rinat Abdullin, the creator of LOKAD outlines that here: Lokad Event Store is slow, we were using the azure blob storage and all that serialization/deserialization causes some serious performance issues when you multiply that by n number of times.  We have moved to the Event Store written by Greg Young found here: Event Store.  This speeds up the writes of the LOKAD system when it comes to the events but still didn’t solve the problem of our read models and how this system likes to make these projections.

If you have been following some of my blog posts in the past, you would know that I have done some research with couchdb, well a co-worker at my work place has been doing a lot of research into Couchbase which leverages couchdb with memcache.  I already liked it cause they used couchdb and I knew how performant that was, what I didn’t know was that it caches a lot of the calls and data, so its in memory and extremely performant.  Our plan is to replace our current readmodels being stored in the azure blobs, which can get quite large, so the serialization/deserialization in some situations can bring performance down to a crawl, to be stored in couchbase.

Anyway, back to my original question, When should you use CQRS or Event Sourcing?  My advice would be to analyze your companies requirements and ask yourself if a system like this would truly give you a reward worth the investment?  My personal opinion is for most business applications it is not needed or necessary to track the intentions or actions on data.  There are some business use cases that I could see it being good for, take banking for instance, its critical to know how the money got from point A to B, or accounting, again mission critical.  Greg Young says he does not like Case Studies, that they are too gimmicky, read his post here: Greg Young Case Studies So I still cannot find a really good case study but I did come across this guys blog post which pretty much sums my overall views on the pattern: A Year in review with cqrs he pretty much came to the conclusion that he doesn’t use the pattern for its intent and a key/value store would have done the job just as well.

There are people out there that think most all applications should be written with this pattern, all I am saying is look at what your needs are and make a judgment call there. I am potentially looking at making a mobile version of a website I worked on with a friend, there is no way I would implement an event sourced system in this situation, it won’t make sense and my client is not going to pay for it, you have to factor in the time it takes to model out the domains and figure out what actions are to be performed on the data.

If you are currently implementing a system like this, I welcome your comments, feel free to leave em, you won’t hurt my feelings. I too am trying to see the real value in a system like this.