Ajax Beginner's Tutorial

Ajax stands for Asynchronous JavaScript and XML and is used for allowing the client side of an application to communicate with the server side of an application.

This might be necessary in order to update the contents of a drop down menu, or to check the availability of a user name, all without reloading the whole page.

Using Ajax isn’t very hard and in this tutorial I’ll show you how to get up and running.

More …

Ignore "Invalid Byte Sequence in UTF-8" Error in Ruby

I wrote a simple Ruby script to parse text files and manipulate their content.

This is useful, for example, if you want to replace all occurrences of the phrase “Dr Jones” with “Prof. Jones” across a set of HTML files.

This was working great on Windows, but when I ran it under Linux, I started getting a “invalid byte sequence in UTF-8” error. This is how I solved it.

More …

How to Validate That Two Time Ranges Don't Overlap in JavaScript

I was working on a form for a timekeeping app, where a user is able to enter their time worked, as well as breaks taken.

There is no limit on the amount of breaks that may be taken, but one of the validation requirements is that no two breaks may overlap.

Here’s how I implemented this validation check.

More …

How to Create a Custom Filter Selector with jQuery

A little jQuery trick I learned recently, was how to create a reusable, custom filter to target specific elements based on their characteristics.

I was kind of surprised that I hadn’t heard of this before, so thought I’d jot it down here, in case it is of use to anyone else.

More …

Resurrecting a Rails 2.x App

This morning I had to give a client an estimate for some work they wanted doing on a Rails 2.1.2 app.

The work itself wasn’t overly complicated, but getting a system up and running using Ruby 1.8 and Rails 2.1 proved to be somewhat of a challenge.

Here’s how I did it.

More …

Display UI-blocking Overlay on Page Load

A client asked me to add an announcement to their website, informing visitors that their business would be shut during the holidays.

“Uh, ok”, I said, thinking that I could place an announcement in the sidebar, but the client wanted more. They wanted it visible, like really, really visible.

The solution we ended up with was to have the announcement displayed in an interface-blocking overlay when the site loaded. This would be shown to the user only once.

Although not overly user-friendly, some people might find this useful, so here’s how I coded it.

More …

FXRuby – How to Capture Close on the Main Window

I wrote a small FXRuby program which allows the user to do some simple file manipulation, then upload the altered files via FTP to a web server.

I ran into a small problem in that when the user clicked the Close button (the X in the upper right-hand corner) of the main window, the application closed straight away.

Normally, this would be the desired behaviour, but in this case I wanted to intercept this message and do some application cleanup first (delete temporary files, make sure the user had saved their work etc).

Here’s how I did it.

More …

Making rsync Behave like SyncToy

Microsoft have produced a very handy backup tool for Windows in the form of SyncToy.

It is intuitive and easy to use, so when I made the switch from Windows to Linux as my main operating system, this was something I sorely missed.

I quickly stumbled upon rsync as the de-facto backup program for Linux, but must admit I was somewhat overwhelmed with the plethora of configuration options it ships with, as well as the tremendously verbose output it produces.

Here’s how to tame it somewhat.

More …

How to Install rbenv on Linux Mint 16

Last year I switched from Windows to Linux Mint as my main operating system and wanted to install a Ruby version manager.

I weighed up the pros and cons of what was available and eventually opted for rbenv as it seemed more lightweight, would let me compile my Rubies myself and (in contrast to RVM) didn’t come with any way of managing gems.

I searched Google and came up with a couple of tutorials to follow, such as this one and this one which described how to install rbenv, but unfortunately they didn’t work for me.

More …