Journal
Styling a Select Like It’s 2019 (Filament Group, Inc.)
Recently, we’d seen some articles suggest that things haven’t changed a great deal with select's styling limitations, but I decided to return to the problem and tinker with it myself to be sure. As it turns out, a reasonable set of styles can create a consistent and attractive select across new browsers, while remaining just fine in older ones too.
Here’s a breakthrough in the always-frustrating field of styling form elements. Scott Jehl of Filament Group introduces a new technique for styling the select
element in a modern way without the need for a parent element, pseudo-elements, or javascript. Thanks, Scott!
(via @scottjehl)
Promises in JavaScript
A brief explainer (for future-me and anyone else it helps) on what promises are and how to use them. Note: this is not an official definition, but rather one that works for me.
In the normal run of things, JavaScript code is synchronous. When line 1 has run (perhaps defining a new variable) and the operation has completed, line 2 runs (perhaps operating on the variable we just defined). However sometimes in line 1 we need to do something which will take longer – maybe an unknown length of time – for example to call a function which fetches data from an external API. In many cases we don’t mind that taking a while, or even eventually failing, but we want it to execute separately from the main JavaScript thread so as not to hold up the execution of line 2. So instead of waiting for the task to complete and return its value, our API-calling function instead returns a promise to supply that value in the future.
A Promise is an object we use for asynchronous operations. It’s a proxy for the success value or failure reason of the asynchronous operation, which at the time the promise is created is not necessarily yet known.
A promise is in one of three states:
- pending
- fulfilled (the operation completed successfully)
- rejected (the operation failed)
We say a pending promise can go on to be either fulfilled with a value, or rejected with a reason (error).
We also talk about a promise being settled when it is no longer pending.
One memorable analogy was provided in Mariko Kosaka’s The Promise of a Burger Party. In it she describes the scenario of ordering a burger from, say, Burger King. It goes something like this:
- you place your order for a Whopper;
- they give you a tray with a buzzer. The tray is a promise that they will provide your burger as soon as it has been cooked, and the buzzer is the promise‘s state;
- the buzzer is not buzzing to start with: it’s in the pending state;
- the buzzer buzzes: the promise is now settled;
- they might inform you that their flame-grill broke down half-way through. The cooking operation failed, and the promise of a burger has been rejected with that reason. You’ll likely want to act on that (by getting a refund);
- alternatively all goes to plan, you go the counter and they fulfil their promise of a tasty burger placed onto your tray.
- you decide you want to act on the success of getting your tasty burger by doing another thing, namely buying a coke. In code you’ll be within the
.then()
method which is the success handler for your promise and in there you can just callbuyCoke()
. (Note: thebuyCoke()
operation might be synchronous; the real life analogy being that it’s so quick to pour a coke that the assistant does it and serves it on a tray immediately rather than giving you a tray as a promise for it.) At the end of yourthen()
you might choose to return ameal
object which combines your burger and coke. - You could then chain a further
.then()
to the original.then()
to work with your snowballing data value. This is becausethen()
methods always return a promise (even if the operation within was not asynchronous), and we already know that promises are thenable (i.e. have athen()
method) hence our ability to keep chaining.
Promise syntax
There are two things we need to be able to do with promises:
- create and return them;
- work with a returned promise.
Create and return a promise
When you create a promise you pass a function known as the executor to it, which runs instantly. Its arguments resolve
and reject
are callbacks provided by JavaScript. Our code goes inside the executor.
let examplePromise = new Promise(function(resolve, reject) {
// do a thing, possibly async, then…
if (/* everything turned out fine */) {
resolve("Stuff worked!");
} else {
reject(Error("It broke"));
}
});
Work with a returned promise
examplePromise.then(function(response) {
console.log("Success!", response);
})
.catch(function(error) {
console.log("Failed!", error);
})
References
My Git Cheatsheet
I’ve used Git for many years but it can still trip me up. At times I’ve worked primarily in a GUI (like Sourcetree or Fork), and other times directly on the command line. I’ve worked on projects where I’ve been the sole developer and others where I’m part of a large team. Regardless of the tools or context, I’ve learned there are certain need-to-knows. Here’s a list of useful Git concepts and commands for my reference and yours.
Note: the following is not an exhaustive list but rather the thing I keep coming back to and/or regularly forget. For deeper explanations, see the list of resources at the foot of the article.
Table of contents
- Starting work
- Remotes
- Committing updates
- Branches
- Save changes temporarily
- Staying current and compatible
- Reviewing your activity
- Fixing things
- Miscellaneous handy things
- Useful GitHub stuff
- Useful external resources
Starting work
Create a remotely-hosted repo
Option 1: Create a new repo in your Github account
This generates a new, empty repo (optionally initialised with a README).
Do this when you will be working on a new, dedicated project rather than contributing changes to a pre-existing one.
Option 2: Create repo from a “template repository” (owned by you or someone else)
This generates a new repo with the same directory structure and files as the template. It’s a good option for starting your own new, potentially long-lived project from a solid starting point.
Unlike a fork it does not include the entire commit history of the parent repository. Instead it starts with a single commit.
Github Reference: Creating a repository from a template
Option 3: Fork an existing repo (usually owned by someone else)
This generates a new repo which is a copy of another repo, including its commit history. Your commits will update your copy rather than the original repo.
Do this by clicking the Fork button in the header of a repository.
This is good for (often short-lived) collaboration on an existing repo. You can contribute code to someone else’s project, via PRs.
Github Reference: Working with forks
Start locally by cloning
clone
creates a local copy on your computer of a remote (Github-hosted) repo.
cd projects
git clone https://github.com/githubusername/projectname.git optionallocaldirectoryname
You might be cloning a repo you own, or one owned by someone else (to use its features in your project).
Your local copy will, by default, have its origin
remote set to the Github repo you cloned.
I cloned an empty new project
We’re in easy streets. The default remote is set exactly as you want it. Just write code, push
at your leisure, and pull
if/when you need to.
I cloned a pre-existing project (owned by me or someone else):
I plan to use it in my own, separate project
You might want to cut all ties and have a clean slate, git-wise.
rm -rf .git
git init
git remote add origin https://github.com/mygithubusername/mynewproject.git
git push -u origin master
Alternatively you might want to keep the original remote
available so you can pull in its future project updates, but reset the origin
remote to your new/target repo.
git remote rename origin upstream
git remote add origin https://github.com/mygithubusername/mynewproject.git
git push origin master
git pull origin master
# in the future the original repo gets an update
git pull upstream master
The source repo is my fork of a project to which I want to contribute
See Working with forks for how best to stay in sync and open PRs.
Duplicating (also knows as “duplicate without forking”)
This is a special type of clone. I know this is an option, but it‘s not one I’m familiar with or have had call to use. I can refer to Duplicating a repository if need be.
Start locally from a blank slate
Although cloning is the easiest way to get started locally, ocassionally I start by coding from scratch instead.
mkdir myproject && cd myproject
echo "# Welcome to My Project Repo" >> README.md
git init
git add README.md
git commit -m "first commit"
# go to Github and create an empty repo, if you haven’t already.
# then add as a remote
git remote add origin https://github.com/mygitusername/myproject.git
# push up, passing -u to set the remote branch as the default upstream branch our local branch will track
# this saves typing out ‘origin master’ repeatedly in future.
git push -u origin master
Remotes
Remove a remote from your local settings:
git remote rm <name>
Rename a remote:
git remote rename oldname newname
Configuration
Configure your favourite editor to be used for commit messages:
git config --global core.editor "nano"
Use git st
as a shortcut for git status
(to stop me mistyping as “statsu”):
git config --global alias.st status
Configure any setting:
git config [--global] <key> <value>
git config --global user.email "myname@domain.com"
Staging, unstaging and deleting files
# stage all unstaged files
git add .
# stage individual file/s
git add filename.txt
Unstage with reset
(the opposite of git add
):
# unstage all staged files
git reset .
# unstage individual file/s
git reset filename.txt
Delete a physical file and stage the deletion for the next commit:
git rm folder/filename.txt
Committing updates
Commit with a multi-line message:
git commit
Commit with short message:
git commit -m "fix: typo in heading"
Stage and commit all changes in a single command (note: doesn’t work with new, untracked files):
git commit -am "fix: typo in heading"
Branches
Show all local branches:
git branch
Show all local and remote branches:
git branch -a
Show branches you last worked on (most recently commited to):
git branch --sort=-committerdate
Save current state to new branch but don’t yet switch to it (useful after committing to wrong branch):
git branch newbranchname
Create and switch to new branch (main
or whatever branch you want to branch off):
git checkout -b mynewbranch
Note that if you branch off foo_feature
then when creating a PR in GitHub for your changes in mynewbranch
you can change the Base branch from the default of main
to foo_feature
. This specifies that you are requesting your changes be merged into foo_feature
rather than main
and makes the comparison of changes relative to foo_feature
rather than main
.
Switch to an existing branch:
git checkout branchname
Save typing by setting the upstream remote branch for your local branch:
# git branch -u remotename/branchname
git branch -u fuzzylogic/v3
# now there’s no need to type origin master
git pull
Delete local branch:
git branch -d name_of_branch
# need to force it because of some merge issue or similar?
git branch -D name_of_branch
Save changes temporarily
stash
is like a clipboard for git.
# Before changing branch, save changes you’re not ready to commit
git stash
# change branch, do other stuff. Then when return:
git stash pop
Staying current and compatible
fetch
remote branch and merge
simultaneously:
git pull remotename branchname
# common use case is to update our local copy of master
git pull origin master
# shorthand when a default upstream branch has been set
git pull
# an alternative is to update (fetch) which does not auto-merge, then 'reset' to the latest commit on the remote
# https://stackoverflow.com/questions/55731891/effects-of-git-remote-update-origin-prune-on-local-changes
git checkout master
git remote update --prune
git reset --hard origin/master
Merge another branch (e.g. master) into current branch:
git merge otherbranch
# a common requirement is to merge in master
git merge master
Rebasing
git rebase
can be used as:
- an alternative to merge; and
- a means of tidying up our recent commits.
As an alternative to merge its main pro is that it leads to a more linear therefore easier-to-read history. Note however that it is potentially more disruptive therefore not right for every situation.
Say I’ve been working on a feature branch and I think it’s ready.
I might want to just tidy up my feature branch’s commits and can do this with an “interactive rebase”. This technique allows me to tidy my feature branch work to remove trivial, exploratory and generally less relevant commits so as to keep the commit history clean.
I might also want to bring in master
to ensure synchronicity and compatibility. rebase
sets the head of my feature branch to the head of master
then adds my feature branch’s commits on top.
While it’s a good idea to rebase
before making a PR, don’t use it after making a PR because from that point on the branch is public and rebasing a public branch can cause problems for collaborators on the branch. (The only exception to the previous rule is if you’re likely to be the only person working on the PR branch)
Rebuild your feature branch’s changes on top of master:
git checkout master
git pull origin master
git checkout myfeaturebranch
git rebase master
Force push your rebased branch (again, only when you’re unlikely to have/require collaborators on the PR):
git push --force origin myfeaturebranch
Tidy a feature branch before making a PR:
git checkout myfeaturebranch
git rebase -i master
# just tidy the last few (e.g. 3) commits
git rebase -i HEAD~3
# this opens a text editor listing all commits due to be moved, e.g.:
pick 33d5b7a Message for commit #1
pick 9480b3d Message for commit #2
pick 5c67e61 Message for commit #3
# change 'pick' to 'fixup' to condense commits, say if #2 was just a small fix to #1
pick 33d5b7a Message for commit #1
fixup 9480b3d Message for commit #2
pick 5c67e61 Message for commit #3
# alternatively if use 'squash', after saving it will open an editor
# and prompt you to set a new commit message for the combined stuff.
pick 33d5b7a Message for commit #1
squash 9480b3d Message for commit #2
squash 5c67e61 Message for commit #3
More on squash including a handly little video if I forget how it works.
Undo a rebase:
git reset --hard ORIG_HEAD
For more detail, read Atlassian’s guide to rebasing.
Reviewing your activity
Show commit history (most recent first; q
to quit):
git log
# compact version
git log --oneline
# limit scope to commits on a branch
git log branchname
Check if your feature branch is trailing behind:
# show commits in master that are not yet in my feature branch
git log --oneline my-feature..master
# show commits on remote branch that are not yet in my local branch
git log --pretty='format:%h - %an: %s' new-homepage..origin/new-homepage
# show commits by me that included “heroku” and that changed file Gemfile
git log --author=Demaree --grep=heroku --oneline Gemfile
Show changes that occurred in the most recent commit or a given commit.
git show
# show changes in a given commit
git show 591672e
Review differences between staged changes and last commit:
git diff --cached
Review changes between a given version/commit and the latest:
git diff 591672e..master
Fixing Things
Discard all your as-yet uncommitted changes:
git restore .
Get your local feature branch out of a problem state by resetting to the state it is on the remote (e.g. at last push
).
git reset --hard origin/my-branch
Undo all the changes in a given commit:
git revert 591672e
Alter the previous commit (change the message and/or include further updates):
# we are amending the previous commit rather than creating a new commit.
# if file changes are staged, it amends previous commit to include those.
# if there are no staged changes, it lets us amend the previous commit’s message only.
git commit --amend
Move current branch tip backward to a given commit, reset the staging area to match, but leave the working directory alone:
git reset 591672e
# additionally reset the working directory to match the given commit
git reset --hard 591672e
See what the app/site was like (e.g. whether things worked or were broken) at a given previous commit, noting the following:
- You’re now “detatched”, in that your computer’s HEAD is pointing at a commit rather than a branch.
- You’re expected to merely review, not to make commits. Any commits you make would be “homeless”, since commits are supposed to go in branches. (However you could then branch off.)
git checkout 591672e
Return one or more files to the state they were in at a previous commit, without reverting everything else.
git checkout 3aa647dac9a8a251ca223a693d4c140fd3c1db11 /path/to/file.md /path/to/file2.erb
# if happy you then need to commit those changes
git commit
When git st
reveals a list of staged files including lots of strange files you don’t want there mixed with others you do…
# add those you want to stay modified and staged
git add path/to/file-I-want-1.rb path/to/file-I-want-2.md
# this will clear all others out of the stage
git checkout .
Grab one or more commits from elsewhere and drop into your current branch:
git cherry-pick 591672e
# grab the last commit from a branch e.g. master
git cherry-pick master
Fix a pull that went wrong / shouldn’t have been done:
git pull origin branchname
# whoops!
git reflog
# shows a list of every thing you've
# done in git, across all branches!
# each one has an index HEAD@{index}
# find the one before you broke everything
git reset HEAD@{index}
# magic time machine
Miscellaneous handy things
Revert to the previous branch you were on
git checkout -
Useful GitHub stuff
- Review your branches on a repo
- Review PRs and issues you’re subscribed to, i.e. ones on which you were active or mentioned
- Review your or another user’s PRs
- If you are fixing something that was raised in a GitHub issue, link that issue in your fix PR’s sidebar under Linked Issues (rather than just mentioning it in the PR) and it will automatically close the issue when you merge.
Useful external resources
- Tips, tutorials and Cheat Sheets from Atlassian
- Need to undo an old commit? Committed to master by mistake? Get out of trouble with Oh Shit, Git!
- More getting out of trouble: Git Flight Rules
- Oh-my-zsh Git aliases and how to add your own
- The original Pro Git reference
- Git for Humans by David Demaree from A List Apart is a great intro to the concepts and basic commands.
Definitive web font @font-face syntax
These days, whenever I’m about to use a web font on a new site I generally find myself running a google search for the latest “definitive @font-face
syntax” that covers all modern browser/device needs.
For a long time I headed straight for Paul Irish’s Bulletproof @font-face Syntax but I noted a few years back that he’d stopped updating it.
When buying web fonts from type foundries such as Fontsmith the foundries do tend to provide their own guidelines. However, I’m not convinced that these are sufficiently cross-platform compatible.
Recently I’ve been reading Flexible Typesetting by Tim Brown and in it he recommends Webfont Handbook by Bram Stein. That’s now next on my reading list, however in the meantime I found an excerpt on A List Apart which specifically covers the best modern @font-face
syntax.
Based on Stein’s advice, here’s what I’m now using.
@font-face {
font-family: Elena;
src: url(elena.woff2) format("woff2"),
url(elena.woff) format("woff"),
url(elena.otf) format("opentype");
}
Soon, when all browsers support the woff
format we’ll be able to reduce this to simply:
@font-face {
font-family: Elena;
src: url(elena.woff2) format("woff2"),
url(elena.woff) format("woff");
}
Surface Noise

It’s taken a few years, but me and Tom are excited to be releasing a new record on our label, The Nuclear Family.
Titled Surface Noise, our third release will be available on both 12″ vinyl and digital, hitting all good record stores in early November ‘18.
You can pre-order it now from our Bandcamp page.
Here's what our press release says:
Artist: The Nuclear Family vs Other Lands Title: Surface Noise Label: The Nuclear Family A: The Nuclear Family - Surface Noise B: Other Lands - See Thru Time
Did you miss us? The Nuclear Family - Tom Churchill and Laurence Hughes - are back after a three-year hiatus, and this time we’ve roped in one of our good buddies, Other Lands, to help us deliver a double-header of deep delights for discerning DJs and dancers, cut nice and loud over a full side each.
Surface Noise, on side A, is the first of the Family’s recent studio jams to see the light of day, with its classic 808 drums and analogue bass underpinning warm pads, twinkling melodies and some subtle vocoder flourishes.
On the flipside, we’re honoured to present a killer track from Other Lands - aka Edinburgh’s veteran DJ/producer Gavin Sutherland, fresh from the success of his recent Pattern Transform 12” for Firecracker and all manner of other exciting studio and live projects. See Thru Time is a masterclass for the heads, with mellifluous chord progressions and a timeless groove.
TNF 003 will be available on vinyl via Rubadub in November, along with a digital version via Bandcamp.
Rise by Gina Miller
I’ve just read Rise by Gina Miller.

In 2016 Miller took the UK government to court for attempting to force through Article 50—the mechanism for starting Brexit—which would have lead to the nation leaving the EU without parliamentary consent.
Its title a reference to the Maya Angelou poem Still I Rise, the book is partly the author’s story of how she has been shaped by the successes and failures in her life, and partly a personal manifesto stating that every person can stand up and make a positive difference, even in the face of adversity.
Miller begins with her fight, in the aftermath of the Brexit vote and the “festering wounds” it exposed, to ensure that the UK’s democratic process and constitution be upheld. She traces her background as a child born in Guayana, a British colony at the time. As the daughter of a self-made man who became the country’s attorney general, she and her family saw Great Britain as the promised land, “a culture where the rule of law was observed and decency was embedded in the national fabric.” Since moving to the UK, forging a successful career and speaking up for her beliefs, that notion of justice and decency has come under scrutiny as she has been met with racist and sexual prejudice and abuse from all walks of society.
The author goes on to describe some of the specific challenges she has faced in her life including vicious hate mail, attacks by the press, being in an abusive marriage, and raising a daughter with special needs. In the end however, as a successful businesswoman with a happy family, hers is a story of strength and survival and a message of hope.
As a man, at times I felt that the book—which often returned to themes of female empowerment—perhaps wasn’t intended for me. Then on other occasions I felt that it was as important (if not more important) for me and other men as for anyone else to absorb these stories of sexist bullying, discrimination and abuse told from the female perspective.
Other core messages of the book were universal: finding your voice, speaking up when it is important to do so, overcoming adversity, and demonstrating tolerance in a divided society.
This was a book I picked up on a whim as a departure from my usual reading subjects, and I’m glad I did.
Cloudinary
Cloudinary is a very handy tool for image and video upload, storage, optimisation and CDN.
Store, transform, optimize, and deliver all your media assets with easy-to-use APIs, widgets, or user interface.
This was brought to my attention by Jason Grigsby at An Event Apart. We were discussing his article series on Responsive Images and I asked if he could recommend a tool which auto-generated all of the images you needed for your responsive image code, if you provide a single source image.
I’ve been trying Cloudinary out and so far, so good.
(via @grigs)
Atomic Design by Brad Frost
The original call-to-arms and manual for Design Systems.
Brad Frost explains why Design Systems are necessary, provides a methodology for Pattern Library creation, discusses Design System benefits and offers strategies for maintenance.
Image Color
A handy tool for identifying colours – provided in numerous different CSS-ready formats – and creating a complimentary colour palette from an image you upload or provide as a URL.
Small Victories
No CMS, no installation, no server, no coding required.
Another quick and clever way of creating a website; this time by collecting a bunch of files (HTML, video, images, bookmarks) into a folder, connecting Dropbox and Small Victories to that, choosing a theme and Hey Presto, you have a website.
I could see this as maybe being useful for some sort of transient campaign idea that doesn’t need a CMS and that you want others to be able to collaborate on.
Note: to get a custom domain and host CSS and JS files, you need to sign up to a paid plan, but at $4/month or $36/year it’s pretty cheap.