Migrating Node.js apps from Heroku to Dokku

eroku (and Dokku) make for an awesome development environment- the most well-known feature being the use of “git push” to deploy changes to a server. For simple projects, I’ve found that the deployment time is as fast as compilation times on JVM based projects, except that at the end you have a working environment. Knowing […]

Lodash debounce example

To ensure that a Javascript function only gets called once ever few seconds, you can run run it through debounce: function run() { console.log(’abc’); }   var realFunction = _.debounce(run, 1500);   realFunction(); realFunction(); realFunction(); Output is: abc In this case, the function will only get run once. If you pass an argument, it will […]

Building a Squarespace integration with Node.js

avascript integrations must be built carefully to avoid excessive rendering and network overhead. If well-built, they make it easy to get get complex functionality in a website, without being locked into the vendor (e.g. Squarespace). I built a small application that uses a search engine to find articles you’ve written for other people, so you […]

Regular Expression to match Postgres Vacuum log statements

You can get log entries for every vacuum in Postgres by enabling this setting in postgresql.conf: log_autovacuum_min_duration=0 Obviously you may prefer to increase the timing too, if you get a lot of entries. This is what the log entries look like: automatic vacuum of table “db.pg_catalog.pg_class”: index scans: 1 pages: 0 removed, 143 remain tuples: […]

Regular Expression for Postgres log messages warning of locks

To match locks in Postgres logs you can use the following regular expressions. The first matches messages that show tables being locked, and the second shows the application loading share locks. .*user=(?P<lock_user_name>\w+),db=(?P<lock_database>\w+) LOG:\s+process (?P<lock_process_id>\d+) acquired (?P<lock_type>\w+) on (?<lock_on>\w+) (?P<lock_tuple>[\(\)0-9,]+) of (?P<lock_object_type>\w+) (?P<lock_object_oid>\d+) of database (?P<lock_db_oid>\d+) after (?P<lock_wait_time>[0-9.]+).* .*user=(?P<lock_user_name>\w+),db=(?P<lock_database>\w+) LOG:\s+process (?P<lock_process_id>\d+) acquired (?P<lock_type>\w+) on transaction (?<lock_transaction_id>\d+) […]

Computer Science in the Real World Moving Information: From Pigeons to the Internet

Map Showing the locations of Paris and Tours

he discipline of Computer Science affects us all, but for many people it is shrouded in mystery. Forged from a union of mathematics and electrical engineering, it beautifully blends the abstract and practical, although knowing this does little to clarify what that means to the non-initiate. The term “Informatik”, or “information science”, was coined in […]

Node CommonJS Example Library Template

If you want to make a new CommonJS module for Node, you can use the following as a template file (we’ll call this ‘detector.js’, but obviously you can name it whatever you want): "use strict";   let _ = require(’lodash’);   exports.functionA = (data) => { return data; };   exports.functionB = (data) => { […]