How to ensure that your Javascript is able to write unicode characters from external Javascript files to your HTML contents

Ever tried injecting Chinese characters into your HTML DOM from an external Javascript file but got something that resembles the following?

Gibberish characters was shown when jQuery attempts to display error message in Chinese

Well that was what I got for the Chinese version of my bilingual form initially as a result of validating an input field as the user is filling up my form.

In this post, I will discuss why I got the unwanted characters and what I did to solve the problem.

Deciding which HTTP status code to use in a HTTP response

When we are in the business of creating web applications, we are always crafting HTTP responses.

A HTTP communication session is initated with a HTTP request from the client and is ended with a HTTP response from the server. In order for a HTTP communication session to take place successfully, the server must be reachable via an IP Address and a port number.

However, a successful HTTP communication session does not imply that the client always get what it wants from the server. Within the HTTP response, the server tells the client whether or not the HTTP request is plausible to fulfill via HTTP status codes.

This is a discussion of some of the status codes that I use at the HTTP server end, in an environment where most of my HTTP clients are robotic in nature.

Designing command-line applications for scheduled execution

Command-line applications are still running amongst us. They are the backbone of large corporations. They are those faithful workers that converts the raw data into beautiful reports while we are asleep. They are those tireless gatekeepers that constantly help us check whether our mission-critical servers are alive and notify us when they detect any anomalies.

Part of what I do for my job is to ensure that those scheduled jobs in my department run smoothly, and in the event that they don’t, run them manually to get the neccessary output for the day and make sure that they continue to run automatically for subsequent days. These scheduled jobs consist of running command-line applications hourly, daily or monthly.

To anticipate future needs, I had spent some time to come out with some guidelines on how I will design my command-line applications meant for scheduled execution.

PHP codes to tell browsers to open the download dialog box for users to download a file

Ideally, when we build web applications which generate files on demand, we will want our users to be able to use their browsers to save a copy of our files in their local harddisk. For instance, the tool for generating customized codes for countries in the world, which I had created earlier, will tell browsers to prompt a download dialog box after users had submitted the form.

Image of firefox dialog box after submitting request to generate custom codes from list of countries in the world.

However, this is not the default behavior of browsers. By default, browsers will show the contents of a HTTP response generated by our PHP script in the browser window. This behaviour can be seen when I point my browser to http://www.techcoil.com/robots.txt.

In this post, I will discuss how we can tell browsers to show a dialog box for users to save the contents generated by a PHP script as a file.

A simple tool to encode text for HTML

Part of my job scope as a Systems Analyst at ANZ is to create form applications for business to generate leads. There are times when business stakeholders gave me paragraphs of terms and conditions to include in my form applications. Thankfully, these paragraphs are usually formatted nicely in Microsoft word documents.

However, because these paragraphs are intended for humans to read, special characters are not presented in html entities.

To utilise my web hosting to the fullest, I had created a tool that help me encode such paragraphs for web browsers to render.

How to compress and decompress files in C#

Files are useful for applications to communicate with others. For instance, web applications can communicate with Google’s crawlers via sitemaps on the Internet. A web application write urls to its pages to its sitemap. When Google’s crawlers come to this web applications, they will download these sitemaps to index urls to the pages of .

To reduce the time needed for files to be trasmitted over the network, it is a good idea for applications to compress files before sending them out to the network, or for a web application, making them available for download via HTTP.

In this post, I document how we can compress and decompress files via the GZip implementation in C# – System.IO.Compression.GZipStream.

How to ensure that your user only runs one instance of your C# program

There are times when we want to limit our users to run an instance of our C# program at any one time. Such situations can be applicable for network monitoring tools, messaging applications, web server monitoring application and etc. In this post, I discuss how we can achieve that via the mutual exclusive (Mutex) mechanism available in C#.

Handy Javascript code segments

The augmentation of Javascript to CSS and HTML is beautiful. While trying out jQuery to create my own tic tac toe game, I realised that there are Javascript/jQuery code segments that could be helpful to me when building web applications.

In this post, I collate Javascript and jQuery code segments that I had utilized in my web projects for ease of future references.

How to execute codes periodically in C#

While some applications passively wait for files to be available for processing, there are many others that need to periodically execute codes to fulfill business requirements. For instance, some may constantly trigger other applications via the command line to monitor the network while some others may constantly access databases to generate graphical reports for business analysts.

C#.Net is one programming language that you can use to create applications that need to do work periodically, especially in a windows environment. In this post, I document the usage of the System.Timers.Timer class to execute codes periodically.