• Changes to NPM’s Unpublish Policy

    Today NPM has made some important changes to their unpublish policy to avoid embarrassing fiascos like the one last week. You can read about the new policy here:

    http://blog.npmjs.org/post/141905368000/changes-to-npms-unpublish-policy

    These changes are clearly a step in the right direction and should prevent an individual from breaking the entire NPM ecosystem by removing a package that is depended on by many others.

    read more...

  • NPM Drama

    Okay, I’m sure we’ve all seen the npm drama that’s gone down in the past week. Azer had a npm module called left-pad, an 11 line function as a module that should have been in the JavaScript standard library. He also had a module called kik, which clashed with the messaging company Kik’s plans to make their own fancy npm module. So Kik went into

    lawyer up

    mode which didn’t go over well with Azer, so when they asked if he would change his module name to something else to appease their trademark he was all

    and NPM got involved. And like any company would they bent over backwards for Kik and the lawyers and removed kik (the module) from NPM. Then Azer ragequit and removed all of his ~200 modules from npm. Which broke the internet even more effectively than Kim Kardashian’s big ass (NSFW).

    Libraries like Babel and React Native were unable to build at all, which stalled them from making new releases, all because of this 11 lines of code that should have been a) in the standard library or b) included in a npm string utility module, not as some silly standalone function.

    read more...

  • I’m Back

    Unbeknownst to me my site was down for 7 days with the message “Error establishing a database connection.”. This occurs when the mysql service crashes on the server. I currently have no way to get notified of this, so any tips on how to do so on a DigitalOcean droplet would be great! The command used to get the mysql service up and running again is:

    sudo service mysql restart
    

  • ES7 Decorators

    I read a fantastic article the other day by Addy Osmani, who among other things created Yeoman, TodoMVC, Material Design Lite, and who works at Google on Chrome and Polymer. The article was what we can expect from ES7 Decorators, which can be found below:

    Exploring ES7 Decorators by Addy Osmani

    You should definitely read the article because it is a succinct and clear explanation of decorators and what you would use them for. They are available to use now in both Babel, though not at the time of writing in Traceur. Generators along with other languages features like async/await, are major additions to JavaScript that should be coming along next year, so you should read up on them now! This article is just a quick summary of Addy’s with some different examples of what you can use decorators for.

    You can check out the examples presented in this article in the online Babel REPL, as long as you check the “Experimental” checkbox. You can then run the generated result in something like JSFiddle.

    read more...

  • Duration Parsing Using Juration

    I’ve been working a lot with appointments and calendaring lately, and one of the requirements to create a new appointment was to have a duration parsing input that was easy to use. One that would let the user input combinations like 1h 10m or 3h or 25mins. It didn’t take me long to find Juration.

    It’s a simple little library, only 2.6kb minified that does one thing and does it well, and it was exactly what I needed. For the string inputs, juration will return the equivalent number of seconds, which you can then determine the hours, minutes and seconds from. For example:

    juration.parse('1h 30m');
    // 5400
    

    Juration also works the other way, you can give it a number of seconds and a formatting option and it will output the string representation, for example:

    juration.stringify(5400, { format: 'long' });
    // 1 hour 30 minutes
    

    Juration parses anything from seconds up to years and is a simple, elegant solution for parsing duration inputs.

  • Angular Directive Isolate Scope Explained

    I’ve written a lot of directives this year, and one of the best ways to learn the ins and outs of Angular is to write a lot of isolated directives with lots of different options. One thing I’ve still felt myself occasionally struggling with is the isolate scope on the directive definition object. Not the concept of the isolate scope, but just what in the hell the difference between all the little symbols you can use is. I aim to explain the difference between these symbols because there are some important things to know about them.

    read more...

  • A Review

    Over the next week or so I’m going to be blowing out the cobwebs of this blog so to speak, in a review, because I’ve been neglecting it quite a bit and I want it to be a better platform for my tech writing. I’m aiming to:

    • Rewrite the theme (again) for an easier to read and navigate blog, including the return of syntax highlighting. I’d previously converted about half of my code samples to use gists but I am going to go back to using a syntax highlighter (probably prism or highlight.js) to reduce load.
    • Go through old posts and put disclaimers on those that are old and probably no longer valid, or have misleading information. I may just implement a flag for posts to display this warning so  I don’t have to do it manually.
    • Speed up the performance of my site. If anyone has any tips on speeding up WordPress I’m all ears, I’ve tried to do a lot of things but they don’t seem to work for long. I may end up upgrading to a larger digitalocean droplet.

    Apart from that, I aim to come up with more articles more frequently, a lot about JavaScript since that is what I’m primarily working with now. Thanks for reading, the changes will be coming soon.

  • this is not allowed before super

    I recently decided to try Babel out as a build system for work in place of Traceur. Along the way I found a spec-compliance issue in much of our ES6 Angular codebase. We have several main classes that other classes inherit common functionality from, for example a Model, Collection and Table class. These classes use dependency injection, naturally, because they are being used to write an Angular application. However, what we were doing was causing the exception ‘this’ is not allowed before super() to be thrown.

    read more...

  • Using $q.all() to Resolve Multiple Promises

    If you have a lot of promises in Angular that need to be run sequentially, you can go about it in one of two ways. There is the classic way of chaining callback functions together to achieve the desired result. Or there is the better way, which uses $q.all().

    read more...

  • Mocks, Stubs, and Injections: Unit Testing in Angular.JS

    Unit testing in Angular is one of the framework’s biggest draws, and the framework’s huge focus on dependency injection makes it an ideal candidate for unit tests. This is very powerful when writing tests because any dependencies that your units or modules have can be easily mocked or injected, whether they are Angular modules or your own defined controllers, factories and directives.

    I found that although this sounds good on paper, it can be quite difficult to achieve in a project whose build workflow involves about 12–15 gulp tasks, ~30 bower dependencies, and all of the modules written in ES6. Finding a way to compile the source files using Traceur and then loading them alongside the bower dependencies was a challenging endeavour, and this article aims to cover what I have found to be an ideal setup for unit testing a dependency-heavy Angular application using ES6 modules. This article will be quite lengthy, so feel free to skip ahead at any point.

    read more...

5 // 11

 

 

Want to read regular updates? Subscribe via RSS!