Skip to main content

Patching with GIF DIFF

· One min read

I've recently had the opportunity to work with some remote teams to collaborate on a project. One question that cropped up was how do I pass the project specific changes to the remote team members without committing the credentials to the repository.

Running SWF Files

· One min read

I was recently posed with a question on how to run Adobe Flash files in the browser. As far as I know, you can write a simple HTML page to embed the Flash file (SWF) in a page and load in the browser (http://superuser.com/questions/116352/how-can-i-play-an-swf-file-using-google-chrome). I also recall that any decent browser would be able to load the SWF file as-is without having to do anything extra.

However, loading the SWF file in Chrome on Linux does not work; loading the file causes Chrome to prompt the user to download it - definitely not the reaction I was hoping from the browser. Trying to solve this problem lead to learn a new thing about MIME types in Linux.

Backbone Events

· 6 min read

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 "add" on the collection and then a properrty is set on the model.

var expModelA = new ExperimentModel({ id: 'a' });
var expCollA = new ExperimentCollection();

Back to Basics

· 3 min read

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.

AppEngine Header Length Limit

· 3 min read

I rely heavily on Google AppEngine which is a platform-as-a-service (PaaS) offering that I can deploy my apps on without having to worry about the actual server instances powering the application.

Contrast this to infrastructure-as-a-service (IaaS) where I decide on the number of servers to spin up for my application.

The benefit of a PaaS offering is an abstraction of the underlying server stuff (and all the nitty gritty server admin issues).

This is great for the developer because the weight of the server admin hat that you have to wear is made a lot more manageable. The tradeoff for this abstraction is the lock-in that you have to endure as a developer.

Hiring Tips

· 2 min read

An article I recently read talks about how to hire the right people. The TL;DR of it is a list of 7 C's (we all love lists right?):

Download JSON as a Text File

· 3 min read

As a Web developer, I sometimes find a need to download some huge JSON object into a text file.

Modern browsers now come with some form of developer tool/console to help debug the monstrous amount of JavaScript in the Web page. For Chrome and Firefox, I simply press F12 to bring up the console. From the console, you can naturally copy the JSON object in its string form by first converting the object into a string like so:

JSON.stringify(obj);

Then highlight the output from the developer console and press Ctrl-C to copy. The trouble comes in when the object is huge - to the tune of thousands of properties.

When an object gets to that size, you will need to scroll to be able to select the complete output. Scrolling the console is itself a tiresome task with text that small. Moreover you run the risk of "over scrolling" such that you select two objects rather than one because you can't tell the difference when they are simply chunks of text.

The best solution is to download the JSON as a text file and then use/manipulate the JSON from the file.

The way to do this is to create a function like this:

Stripping Carriage Returns From Text Files

· One min read

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, the 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