Rojakcoder
Of Linux, Programming, and Singaporean Ramblings

A little lesson on binding

Wed, Sep 28, 2016

I’ve been writing JavaScript for the past 10 years for my work, and there are still things in the language that trips me up. A very good example is on binding.

Given the setup below, I would have been a little hesitant as to what the right answer is.

Read more

More tips for BackboneJS

Fri, Feb 19, 2016
Some time back when researching for Backbone JS stuff (I can't remember for what now), I encountered this post Lessons learned while working with Backbone.js. This post was written a few years back, but I was still able to glean some gems from it. Specifically, the section "Simplified Object Copying" was something that could be applied on plain vanilla JavaScript. The other section "Changing in referenced object does not trigger events"
Read more

Backbone Events

Tue, Oct 27, 2015
Backbone events are a powerful way to write responsive user interfaces with fewer lines of codes. This article attempts to give a detailed breakdown of the events and the parameters available for the callback functions. The results in this article are applicable for version 1.2.3 of Backbone.js The test is performed by instantiating instances of ExperimentModel extended from Backbone.Model and ExperimentCollection extended from Backbone.Collection. The model is first added to the collection to test "
Read more

Back to Basics

Sun, Sep 27, 2015

When I started my formal education in computer science, I had to take a module on programming with the C language. I remember this was a module that caused many of my peers to re-think their decision to study computer engineering; the concept of pointers was so foreign to many of them that even the smart ones scored poorly.

Read more

Stripping Carriage Returns From Text Files

Tue, Aug 19, 2014

One of the problems with working on Linux and Windows OSes has to do with manipulating text files. Lines are separated by a carriage return and a line break character in text files on Windows, whereas on Linux, they separation is done through a single line break character.

When text files from Windows are opened in Linux, you often see ^M appearing at the end of lines like this:

Line 1^M
Line 2^M

The easiest way to remove the carriage return characters (represented by ^M) is to use the dos2unix command. This lightweight program can be easily obtained on Debian-based systems with the command:

sudo apt-get install dos2unix

Other than using the dos2unix command, the fastest way to remove the carriage return characters is the following command:

cat file1.txt | tr -d '\r' > file2.txt

Why use www?

Tue, Jul 8, 2014
This is a reproduction of the article found at http://www.yes-www.org/why-use-www/. It is reproduced here because the contents are fantastic and I have a fear that the page will be removed eventually because it is a Wordpress site with only one article. This page is intended for webmasters who are looking for information about whether or not to use www in their canonical web site URLs. First, a bit of terminology.
Read more

Solving the Mystery Behind Alternating Failed Tests in QUnit

Tue, Aug 14, 2012

I’ve recently started using QUnit for my JavaScript testing. It’s a unit testing framework for JavaScript. It’s quite an easy framework to learn and I strongly encourage everyone who is doing any decent JavaScript coding to use it or any one of the myriad frameworks out there.

One of the strange problems I faced with QUnit is a strange phenomenon where a custom written plugin fails the test on every alternate invocations of the test.

Read more
Page 1 of 3