Javascript imports and exports

Functions, objects and primitive values can be exported from a module. A module can have many named exports and one default export, ES6 favours a default export per module with additional helper functions exposed as named exports. Exports can be marked ‘in-line’ or separately where the practise generally is to export at the end of the file. Exports can be aliased with ‘as’ and writing export default baz is equivalent to export { baz as default }.

function myFoo() {
  return 'stuff'

const bar = 'more stuff'

const baz = 'default stuff'

export { baz as default, myFoo as foo, bar }

Functions, objects and primitive values can be imported from modules. Default exports need to be provided with a name, named exports can be aliased.

// lib.test.js
import theDefault, { foo, bar as myBar } from './lib'

it('imports the default', () => {
  expect(theDefault).toEqual('default stuff')

it('imports myBar', () => {
  expect(myBar).toEqual('more stuff')

it('imports foo', () => {

If you have a folder of related modules a useful pattern is to create an index.js in the folder and export functions from related modules from in it.

// sub/lib1.js
function func1() {
  return 'hi from lib1'

export { func1 as default }
// sub/index.js
export { default as lib1 } from './lib1'
export { default as lib2 } from './lib2'
// sub.test.js
import { lib1, lib2 } from './sub'

it('imports lib1 from a subfolder', () => {
  expect(lib1()).toEqual('hi from lib1')

There are many more ways to import / export modules. These are just my preferences and, as with most style choices, consistency is important.

A more comprehensive guide to import and export is available on MDN.

What is Lambda Calculus

Lambda Calculus is a simple and very sparse notation for representing and applying functions.

The format is:



  • λ signifies it is a Lambda function
  • The x before the period represents the input to the function
  • The function body follows the period

So λx.x is the equivalent of:

function(x) {
  return x


x => x

(To type a λ on OSX hit cmd ctrl space and search for lamda with no ‘b’)

Lambda Calculus consists of:

  • variables (which can only contain lambdas)
  • lambdas (anonymous functions)
  • application of functions to variables and other functions

So no data types, no numbers or strings directly but we can represent numbers and strings with pure functions.

  • lambdas have an arrity of one (meaning they can only take one parameter)
  • working with more than one parameter is done by currying: λx.λy. x(y) The first lambda takes x and returns a function that takes y, applies x to y and returns the result.

Suprisingly with this sparse notation we can represent anything that can be computed although, in my mind at least, it may not be the most maintainable representation.

VS Code as a markdown editor

When I write anything I prefer to do it in markdown then export it to MS Word, Evernote or WordPress. VS Code makes a great markdown editor with a couple of extensions.


Markdown All in One

Seems like an obvious place to start. Adds useful shortcuts, ToC, table formatting and some other useful features.


This adds some useful linting, the default rule set is good but I need to make some changes…

  • MD009 – Allow 2 trailing spaces to signify a line break
  • MD013 – Allow long lines, I prefer to allow wordwrap to deal with this in markdown
  • MD024 – Allow duplicate headers, I often want repeating subheaders in documents

{} User Settings:

  "markdownlint.config": {
    "default": true,
    "MD009": {
      "br_spaces": 2
    "MD013": false,
    "MD024": false


This provides the export to Word in addition to PDF and HTML.

Disable Prettier

I really like Prettier but in v1 it ‘fixes’ unordered bullets in markdown from ‘-’ to ‘*’. There should be a way to configure that in v2 but until then I’ll turn it off for markdown.

{} User Settings:

  "prettier.disableLanguages": [

Mobile editing

I keep markdown docs in a folder in Dropbox and use Byword on IOS to create notes when I don’t have a laptop handy. Byword has functionality to publish to Evernote and WordPress as well.


  "recommendations": [

Shortcuts to remember

  • ctrl } – Header
  • ctrl { – Remove Header
  • ctrl shift v – toggle preview


I have not yet found a good way to export notes to Evernote, there are a couple of extensions for VS Code but there are issues with the required Evernote user extensions. I can use Byword on IOS or OSX to publish to Evernote but would prefer to be able to do so with VS Code. There is a VS Code extension that will copy markdown as rich text but it is Windows only.


For simple posts containing mostly text, pasting the markdown directly into the WordPress text box seems like it should be sufficient. For longer posts, probably best to publish with Byword again but, even with Byword, code snippets could use some more work (will use this method to publish this post).

Open with Alfred

Lastly I want a shortcut in Alfred to open the markdown folder in IOS so I have associated the keyword ‘md’ with this apple script:

on alfred_script(q)
  tell application "Visual Studio Code"
    open "/Users/jp/Dropbox/Apps/Byword"
  end tell
end alfred_script

Why Measure Dev Team Productivity?

I read recently (possibly on a forum?) that as a development manager your product is the team. I like that analogy and, if you buy into it, your main KPIs should be centred on your team’s performance.

There are plenty of reasons to measure performance such as measuring velocity to plan future work but the main reasons I want to measure productivity are:

  • To answer the question ‘are we better as a team than last month?’
  • To measure the results of changes.

Changes can be changes we have made or experiments we are doing as a team e.g. no estimates or everyone works remotely for a sprint. It’s important to be able to measure the effect of the things we try. Other changes may be external e.g. changes to seating plans in the office or business priorities and again it’s important to know the impact of these.

What Do We Measure and How?

This will be different for different teams and there will never be ‘One Measurement’ that works for any team. The best solutions will include a number of measures that, when combined, will be indicative of team productivity.

Another consideration is measuring teams and measuring individuals. There should only be one reason for measuring an individuals performance and that is to support that individual. Even in combination the measures will probably not fairly reflect a developer’s contribution to the team and should not be viewed or used out of context. I am still in two minds how useful individual measures can be…


Complexity is useful when done well but is hard to do well and will vary depending on the project the team is concentrating and, probably, the technologies they are using. We have a fairly monolithic legacy app that started life 10 years ago and a number of much leaner loosely coupled services, also the team is, on the whole, a lot more comfortable in Ruby than Javascript.


Contribution can be documented in Github as commits, pull requests, comments, and merges, or in Jira as comments, status changes etc. These contributions should be fairly easy to measure but allowance does need to be made for pairing.

Code Churn

Okay, LoC is never going to cut it as a measure of productivity but maybe code added, removed, or changed can be added into the mix, again allowing for developers working in pairs.

Pull Request Lag

No one wants to have to merge a pull request that is 6 weeks behind master.

Avoid manual processes

You will want to automate as much of this as possible, manually collating data can work for short periods to answer specific problems (currently the team is logging interruptions to their flow) but is unlikely to be successful in the longer term.

Lastly, it is important that the team buy into this and the reasons for doing it. The team at Reevoo are currently looking at what they want to measure and how to automate collection. I’ll report back when we have something in place.

Synchronising Filezilla Settings via Dropbox

I use multiple machines so it is easier if everything syncs automatically.

While Filezilla doesn’t have this built in, there is the option to move all the settings to another location so it can be done with Dropbox etc.

On OSX right click the Filezilla app and show package contents. The file Contents/docs/fzdefaults.xml.example contains instructions on how to override the defaults:

I have amended mine and saved a copy into the dropbox folder I am using so I just need to copy it across to new machines.

Does Email Obfuscation Work? Results

Four years ago I started a test to see how well different email obfuscation techniques worked to thwart spammers.

My requirements in order of preference were:

  1. A clickable link.
  2. Gracefull degrade for users without javascript.
  3. Users should be able to copy the email address to the clipboard.
  4. It should be easy for me to insert an email address on a page.
  5. It should reduce spam.

Well, it’s been 4 years and here are the results:

Method (see original post for explanations) Emails in inbox percentage of plain text
Using plain text 247 100%
Using AT DOT 48 19%
Using AT DOT and javascript to de-obfuscate 45 18%
Using code direction 0 0%
Using style=”display:none” 1 0%
Using ROT13 0 0%

These addresses all pointed at Gmail inboxes and Gmail deletes spam after 30 days so the spam folder counts can be ignored.

When I started the experiment I hoped the AT DOT and javascript to de-obfuscate as that seemed to fill most of my requirments but the spammer’s crawlers have obviously cracked that trick (not hard I know). The best solution would seem to be an <a> link using ROT13 and the text of the link either a span using code direction or applying the style to the <a> link itself.

Something like:

Messy (and unchecked / written by hand) but I guess an email address will not change much so, once the correct code is worked out, it could be added to a snippet or clipboard manager.

Panes in iTerm2

I don’t use panes in iTerm often enough and whenever I do I seem to have forgotten the keyboard commands to split and navigate them, so…

  • ⌘D – Split vertically
  • ⌘⇧D – Split horizontally
  • ⌘⌥↑ (or ↓, ← or →) – Navigate between panes
  • ⌘⇧↩ – Maximise pane toggle

Scala and SBT set up for the command line on OSX

  1. Install the Java SE SDK from (you can install multiple versions – 1.7, 1.8 …)
  2. Get Homebrew from if you haven’t already and brew update & brew install sbt
  3. For vim install the vim-scala plugin from
  4. Create the obligatory Hello X App.
    mkdir HelloSbt & cd HelloSbt & vi Hello.scala
  5. Create a build file.
    vi build.sbt
  6. Run sbt from the command line  then run to execute. This will install the latest version of sbt and the version of scala specified in the build file.
  7. exit to leave the sbt console

Heroku, Precompiling Assets and Enviroment Variables

It’s easy enough to set up a staging environment on Heroku and have the environment use your staging.rb at runtime by setting the RACK_ENV  variable to “staging”.

Currently there is a problem if you need anything from your staging.rb whilst the slug is being compiled. I ran into this when I specified an asset host. At runtime, assets that were referenced in the rails code were fine, but all assets referenced in my stylesheets pointed at the asset host from the production.rb.

With the default set up, environment variables are ignored during slug compilation. There is a setting in heroku labs that will load the variables before slug compilation:

As with anything in labs, there are no guarantees, butI have had no problems so far.