Changing the naming convention for Aurelia View Model class names

ts and aurelia

I was working on a large Aurelia project and having trouble with clashing names of JS classes. The convention for Aurelia View Models is that their class names end in CustomElement. But to prevent clashes, I wanted to ensure that View Models attached to routes ended in Route and components in Component (e.g. an EmailRoute might contain a EmailComponent). I didn’t find a built-in way to instruct the Aurelia loader to interpret class names this way, but it turned out to be pretty easy to make an override:

@confirmUnload decorator for Aurelia route View Models

ts and aurelia
If a page has complicated forms, you may want to ask the user to confirm when they try to navigate away while there are still unsaved changes. Applying this decorator to Aurelia route View Models does that for you.

@autocast TypeScript property decorator

ts
This TypeScript property decorator makes sure that values assigned to that property are converted to the right type, provided you can do so in a predictable manner.

@queuedOperation TypeScript method decorator

ts
Here is a TypeScript method decorator used to queue calls to a number of async methods that work on shared state and need to be called one at a time to prevent race-conditions.

Instance-targeted TypeScript property decorators

ts
TypeScript property decorators are applied when a class is loaded, not when a new instance of the class is created. Here is a technique you can use to alter properties using decorators so that they still appear like unique, own properties of every instance of your class.

Protractor: lessons learned

js, ts, and protractor

I’ve been working with Protractor a lot in recent monts, writing automated tests for the web UI of our company’s customer portal. In this post, I thought I’d share some of the lessons I’ve learned along the way, and give some practical advice.

Protractor custom locator: by.marker

js, ts, and protractor

Protractor makes it very easy to locate a specific element in your webapp for testing by writing CSS selectors. However, by using this overmuch, you’re locking your integration tests to the current structure of your app, making the tests fragile. Here’s a more robust alternative.

Jasmine custom matcher: toBeInstanceOf

js, ts, and jasmine
Recently I found myself in need of a custom matcher for my Jasmine-based unit tests. I looked around and only found a few some outdated examples, so I wrote my own. Here it is so you don't have to do the same.

Serving with ExpressJS in three quick steps

shell and node

Say you have a couple of files that you want to serve for a while, and you happen to have Node installed on your box. Here’s three easy steps to serve the contents of a directory using Express.

Accessibility is fascinating!

a11y
I used to think accessibility meant outdated government guidelines and ugly designs. But when I dove into it, accessibility turned out to be a fascinating topic and a fun, challenging part of design and development.

Simple poller library in TypeScript

typescript and javascript

Here is a very simple library of pollers written in TypeScript. It uses async / await so if you want to transpile it to ES3 or ES5 you’ll need TypeScript 2.1 or higher.

Collecting translation keys during TypeScript build

typescript and i18n

I found myself in the position of building a lightweight i18n mechanism for the frontend of an enterprise app recently. I implemented a couple of decorators that inject translations into properties. I also extended the Gulp build process to gather all translation keys into a single file for me, which I could then use on the backend to deliver only the required translations, rather than send over the entire dictionary. Here’s how.

Running the Glassfish pkg tool on 64 bit Ubuntu

glassfish, linux, and ubuntu

The Glassfish Java application server comes with a number of tools, including pkg. Unfortunately, pkg is a 32 bit Python application and almost all of us run 64 bit systems. So you need a couple of compatibility libraries to run the tool. Here’s how you do that on Ubuntu 16.04.

Social share snippet for Jekyll

jekyll and liquid

To set up this blog, I wrote a snippet of Jekyll template code (Liquid) to create social share links. You can find it on Github if you’re interested.

ttime: a critical shell trick

shell
In which I demonstrate two shell aliases that every office-worker absolutely must have in order to function.

Angular vs React vs Aurelia

javascript, angular, react, aurelia, and frontend
In which I try out three JavaScript frameworks to see which is best suited for building individual frontend widgets.

Romke's Checklists

dev
I've released a very simple webapp that has some checklists I find useful. I started it off with a checklist to go through before committing code.

Insert hard linebreaks into textareas with vanilla JavaScript

javascript and html

While working on my little checklist app I needed a way to hard-wrap text entered into a <textarea> and preserve the linebreaks when copy-pasting it somewhere else. HTML and CSS don’t support this, so I wrote some vanille JavaScript code to insert the linebreaks, trying to break on words whenever possible.

docker-gen: automatic nginx config with a human touch

docker, nginx, mariadb, mysql, upstart, and wordpress

In this article I will demonstrate a setup using Docker, docker-gen and nginx that will add new Docker containers to nginx automatically as an upstream instruction, but still let you manually configure how these containers are publicly served by writing the site instructions yourself.

Easy access to a dockerized mysql server

docker, shell, mysql, and mariadb
Deploying a new mysql server using Docker is quite easy. But once the server is up, you want root access to it from your command-line. Here's a little shell function that'll do it for you.

Update your projects: up.sh

bash, shell, svn, git, and development

I have a number of frameworks, platforms and reference projects in my workspace that I want to update daily. Rather than going to each of them and doing svn up or git pull by hand, I’ve written a little Bash script to do it for me. I just keep a list of all projects I want updated. Now I need only run ./up.sh once a day.

suspend_until and suspend_for

bash and shell

Here are two Bash scripts I wrote some years ago that allow you to send your computer to sleep for a specified time and then wake up automatically. They work with the rtcwake and pm-suspend tools.

Renderable: simple template inheritance in PHP

php and templating
I wrote this PHP class some time ago. I've used it in a number of tools I've written in PHP. It gives you a simple yet versatile templating mechanism.

Dokku and Docker on the same server: power and control

docker, dokku, mysql, mariadb, nginx, ubuntu, and wordpress

Docker is a platform that allows you to deploy any kind of app in a uniform way. Dokku builds on this to create a full PaaS. It allows you to simply push your code repository to your server and let Dokku build and deploy it for you, automatically.