Archive for the 'Web Development' Category

Forcing HTTPS in a Play 2 Scala app

At Process Street we’ve been developing a new app called MailTheme that, like the Process Street app, it uses the Play Framework.

Unlike Process Street, MailTheme will be running on Google Cloud and, for the time being, won’t be behind a load balancer or proxy. As such, I needed to make all HTTP requests auto-redirect to HTTPS via Play. This turned out to be more difficult than I first imagined, as Play prior to version 2.3 has no way to detect whether or not the incoming request is over SSL.

Read more »

Play 2 Framework not finding environment variables in IntelliJ IDEA on Mac

Recently I was experiencing an issue with the Play 2 Framework where it could not find environment variables on Mac OS when compiled within IntelliJ IDEA. The solution turned out to be simple, but could be inconvenient when an environment variable is used in many programs.

Read more »

Pajama: Client and Server Validation Simplified

When implementing an HTML form that requires validation, a developer must make a decision: should I use client-side validation, server-side validation, or both?

In this article I will give a quick overview of the pros and cons of these validation techniques, as well as introduce my solution to the problem: Pajama.

Read more »

Creating ASP.NET HttpCookie-compatible multi-valued cookies in JavaScript

Cookies are ubiquitous on the web. They’re used to store usernames, login tokens, shopping cart contents, and so on. In libraries, cookies are typically modeled as name-value pairs. An API consumer requests a cookie using a known name (e.g. $.cookie('user') in jQuery with the Cookie plugin) and the library returns a string (e.g. alice). Sometimes, however, just plain old name-value pairs aren’t enough. In this article, we will take a look at how to bake multi-valued cookies in JavaScript that are compatible with the Values property of ASP.NET’s HttpCookie class.

Read more »

Eager boolean operators in JavaScript

In most programming languages like Java, JavaScript, C and C#, the boolean operators && and || perform short-circuited evaluation. Essentially, this means that a program, when evaluating boolean operators, will only evaluate as many arguments as is necessary to determine the value of a boolean expression. Sometimes, however, this is not the behaviour we want.

In this article we will look at how to implement non-short-circuited or “eager” versions of the JavaScript boolean operators && and ||.

Read more »

How to do an AJAX search with jQTouch, Part 2

In the last installment of How to do an AJAX search with jQTouch we looked at how to setup a jQTouch interface with the goal of performing an AJAX search. In this article, we will write the necessary JavaScript to perform that AJAX search, as well as a PHP script to respond to those calls.

This article assumes you have read the first part of this series.

Read more »

How to use custom jQuery animation queues

You may not know this, but whenever you use jQuery commands like fadeIn, slideDown, and delay, you are implicitly making use of a jQuery queue behind the scenes. That queue is named fx, and it is the default queue that all animations use unless otherwise specified.

In this article, we will look at how jQuery animation queues work, how to create and manipulate them, and how to use them in a meaningful way.

Read more »

Biomorph.js: Natural Selection in JavaScript

For his 1986 book The Blind Watchmaker, Richard Dawkins developed a program that created “biomorphs”: virtual creatures created by a computer simulation. The simulation, called Biomorph, was developed in order to demonstrate the power of natural selection.

Recently, in an effort to better understand how the Biomorph program worked, I decided to implement it myself in JavaScript using the HTML5 canvas element. The result of this endeavour can be found here and the GitHub repository here. Read more to learn how to use the Biomorph program.

Read more »

A little bit about Webble and JavaScript games

Webble is a pure HTML/CSS/JavaScript implementation of some of the core features Wezzle game engine. By “pure” I mean that there are no external plugins like Flash used. Furthermore, Webble does not make use of the HTML5 canvas element: all the animation is done purely by moving around HTML elements using JavaScript.

Writing a simple game engine using the DOM and JavaScript poses some interesting problems that are atypical to regular website development. In this article I will discuss a few of the problems that I encountered while writing Webble and how I solved them.

Read more »

How to query posts by template in WordPress

Ever wanted to filter a query_posts call by template? If you’re reading this post, you probably have or need to right now. You probably went to the query_posts documentation and scanned for something like “template=foo” and were deeply disappointed. Then maybe, in an act of desperation, you started to trudge around the plugin library. Stop! Stop right there! You don’t need a plugin to do this. Everything you need is already in WordPress.

Read more »

Next Page »