Geeks With Blogs

News profile for Aligned at Stack Overflow, Q&A for professional and enthusiast programmers

Donate Bitcoins

Check out Elapser from T3rse!
"free in Christ Jesus from the law of sin and death." Romans 8:2 (ESV) Check out the Falling Plates video on YouTube.
more about the Gospel
And then listen to Francis Chan speaking at LifeLight in SD.

Programming and Learning from SD JavaScript
When does $.when.apply resolve the promises?
I learned some new things about $.when.apply that were worth sharing. · the first reject will fire the .always, but not the .then · .then won’t fire until all promises are resolved (or one is rejected) Maybe not new to you, but I had to try it out after seeing the last answer at ......

Posted On Friday, January 30, 2015 7:53 PM

MutationObserver in HTML5
We were just in a code review and one of the guys showed how he was using the MutationObserverer with our search control to get tiles to resize after the list (Knockout observable). I hadn’t heard of this before and it looks very useful. Read the linked page (from 2012) to learn more about it. It’s supported on all but Opera mini and started in IE 11 and is a more performant than the old Mutation Events that have been deprecated. You point the MutationObserver to the DOM node and it ......

Posted On Thursday, January 29, 2015 7:55 PM

ctrl+p in Chrome Developer Tools to find and open a file
I was watching part of Using TypeScript for Large Angular JS Applications on TypeScript. In the SourceMaps and TypeScript section, Justin Schwarty mentions that ctrl+p in the Chrome Dev Tools will pull up a list of files (css, js) that you can debug against. This is similar to the ctrl + comma in Visual Studio (or ctrl + t with Resharper). Hopefully, you’re already aware of this, but for me it will be a huge time server. I’ve searched through the tree of files far too often. The official shortcuts ......

Posted On Tuesday, January 13, 2015 4:03 PM

Not using JavaScript Promises? It is time to make the change.
If you ignore the Angular part of this article, it applies to JavaScript in general. If you're still using callbacks with $.ajax(, please look into Promises. jQuery has an implementation (though I've heard it doesn't exactly follow the standard. It will be native in ES6 (the next version of JavaScript) – this is an in-depth on ES6 promises. - even the next IE will have it. Wrangle Async Tasks With JQuery ......

Posted On Tuesday, December 16, 2014 1:30 PM

Ajax promises without jQuery
I’m trying to move away from jQuery, since I’m using Knockout and AngularJS more all the time. I’ve always done my AJAX calls with the useful jQuery $.ajax( method. Searching for “ajax without jquery” brings up a lot of results, but they all include how to do it with jQuery. First a friend found a tutorial on ES6 promises on HTML5 rocks that included an example of “Promisifying XMLHttpRequest”. Since promises aren’t in all browsers yet (IE and Android Browser) you can polyfill with es6-promise. Or ......

Posted On Tuesday, October 7, 2014 4:20 PM

Find an element in a JavaScript array
I needed a C# Dictionary like data structure in JavaScript and then a way to find that object by a key. I had forgotten how to do this, so did some searching and talked to a colleague and came up with this JsFiddle. See the code in my jsFiddle or below: var processingProgressTimeoutIds = []; var file = { name: 'test', timeId: 1 }; var file2 = { name: 'test2', timeId: 2 }; var file3 = { name: 'test3', timeId: 3 }; processingProgressTimeoutId... name:, timerId: }); processingProgressTimeoutId... ......

Posted On Friday, August 22, 2014 6:27 PM

Include your JavaScript references in the correct order
I was stuck for 2 hours on this. I was using Wijmo library and was including the complete library before the open js file. I kept getting’Uncaught TypeError: Cannot call method 'formatString' of undefined’. Finally, I switched the order and put the open js file before the complete js file and the error went away. The lesson is that undefined means you haven’t defined it yet . Make sure it isn’t defined below it and that you didn’t forget to include it ......

Posted On Monday, January 7, 2013 3:51 PM

Mock the window.setTimeout in a Jasmine test to avoid waiting
Jasmine has a clock mocking feature, but I was unable to make it work in a function that I’m calling and want to test. The example only shows using clock for a setTimeout in the spec tests and I couldn’t find a good example. Here is my current and slightly limited approach. If we have a method we want to test: var test = function(){ var self = this; self.timeoutWasCalled = false; self.testWithTimeout = function(){ window.setTimeout(function(){ self.timeoutWasCalled = true; }, 6000); }; }; Here’s ......

Posted On Thursday, August 21, 2014 4:42 PM

Angular Panel Discussion with Dan Wahlin, Jeremy Likness, John Papa, and Ward Bell
10 Reasons Web Developers Should Learn AngularThere is a very informative video discussing AngularJs, TypeScript, etc that is well worth your time. It got me interested and even excited about Angular and the possibilities. I’m a big fan of KnockoutJs, but this video gave me the bug to look into Angular more. Here’s a good article comparing KnockoutJs and AngularJS. Here are some notes from their discussion: They mentioned the cool demos at TypeScript pros and cons around 20 minutes ......

Posted On Monday, February 3, 2014 2:48 PM

Mock RequireJS define dependencies with
I had a module dependency, that I’m pulling down with RequireJS that I needed to use and write tests against. In this case, I don’t care about the actual implementation of the module (it’s simple enough that I’m just avoiding some AJAX calls). EDIT: make sure you look at the bottom example after the edit before using the approach. I found that there is an easier way. I did not want to change the constructor of the consumer as I had a chain of changes that would have to be made and that ......

Posted On Monday, August 18, 2014 4:53 PM

Copyright © Aligned | Powered by: | Join free