• Fast SQL Server Paging

    Just a quick tip if you ever need to implement paging in MSSQL. Here is a simple example of the query, which gets page x of size y and gets the total row count as well.

    SELECT ID, Name, [RowCount] = COUNT(*) OVER()
    FROM MyTable
    WHERE Name LIKE '%Example%'
    ORDER BY ID
    OFFSET @Page ROWS
    FETCH NEXT @PageSize ROWS ONLY
    

    This must be used with an ORDER BY clause. The @Page and @PageSize determine which set of records are returned out of the total result set.

  • ng-options Undefined On Select

    I came across this subtle gotcha related to an ng-options option being undefined on select the other day at work. The initial problem was that out of a list of over a hundred or so options, one of them would cause the required form field validation to kick in because it was undefined on select. I eventually tracked it down to an issue deep within Angular’s options code, and the problem was actually nothing to do with Angular itself.

    read more...

  • Creating Share Buttons With Just URLs

    I came across this Gist on how to create share buttons with just URLs while converting my blog to Jekyll, which is what I use at the start of each post:

    https://gist.github.com/chrisjlee/5196139

    It shows how to create Facebook, Twitter, Google Plus, Linkedin, Pinterest, Tumblr links. Scroll through the comments on the Gist to see the updated sharing links.

  • From Wordpress to Jekyll

    This blog is now run on Jekyll, and here’s why.

    Jekyll

    I got real tired of WordPress for the following reasons:

    1. It’s slow, for a simple blog.
    2. Reliance on a database.
    3. General heavy-ness. I didn’t really use most of its features, and it felt slow to navigate around the admin area.
    4. Did I mention it’s slow?

    I’ve toyed with the idea of moving this blog to Jekyll for a few years now but I felt like it wasn’t mature enough to handle the transition yet. I had fears and doubts about how it would handle SEO and analytics and whether I would lose any important functionality from plugins. Nothing could be further from the truth. Jekyll is now a robust tool for blogging or documentation, and is great for you if you like having more control over the format and output of your blog. I’ve compiled all of the helpful links I found when making the transition.

    read more...

  • gulp.watch High CPU Usage

    I noticed frequent slowdowns on my new work PC with Windows 10, an i7 and 16GB of RAM, and opened up Task Manager to see what could possibly have been slowing everything down. To my surprise, I found that the node process was hogging between 25 and 50 percent of CPU while it was running.

    read more...

  • 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.

1 // 7

 

 

Want to read regular updates? Subscribe via RSS!