Book Review: Three.js Essentials

Review of book, Three.js Essentials by Jos Dirksen
Packt Publishing, July 2014

Three.js Essentials provides a starting point for anyone curious about how to leverage the WebGL standard using the Three.js JavaScript library. The book consists of seven detailed examples with explanations of how they work. Unfortunately, these explanations are light on detail, making the treatment of this subject somewhat superficial.
Continue reading

Provide Line Numbers for Your Code Listings

Have you ever wanted to list your code on a website and automatically number each line? Sure, you can do it manually, but it’s painful to go back and re-number all those lines should you decide to change the code. Also, it’s difficult for your viewers to copy and paste your code without having to back out all those line numbers.

Well, you’ll be glad to know that it’s really easy to implement this automatic line numbering feature. All you need to do is encase your code in <pre> … </pre> tags, and then let JavaScript and CSS do its stuff!
Continue reading

Preserve Context In Your Ajax Calls

Asynchronous Ajax calls can really mess you up. The problem is that the environment within which you execute an Ajax call isn’t the same environment as when you handle the results. This situation occurs because of the nature of asynchronous environments. The browser makes the Ajax call to the server and then continues with its own business. Sometime later, the server responds with the results of the Ajax call, but by that time, the context of the browser’s running thread has changed.

It’s like arriving at the train station after the train has left town.
Continue reading

Ruby Sinatra Authentication

Topics like authentication often give me the heebie-jeebies. I worry about nefarious hackers in some corner of Beijing trying to hack into my account by somehow circumventing the authentication mechanism I put in place. To fight the situation, I would write the entire authentication routines myself, but I worry that I haven’t tested it thoroughly; on the other hand, I worry about using a library solution that I don’t fully understand and could therefore leave myself open to an attacker that does fully understand the solution.

A good compromise is to understand a bit about authentication and then use a known solution. When it comes to Sinatra, both are within easy grasp.
Continue reading