Skip to content

Instantly share code, notes, and snippets.

View robatwilliams's full-sized avatar

Robat Williams robatwilliams

View GitHub Profile
@robatwilliams
robatwilliams / github-backup.sh
Last active April 12, 2020 16:55
Backup GitHub repositories as Git bundles
#!/usr/bin/env bash
declare -a repositories=(
'awesome-webhid'
'config'
'correct'
'decent-code'
'diff-hero'
'differential-loading-poc'
'enforce-frontend-architecture'
@robatwilliams
robatwilliams / compound-words-case-style.md
Last active June 23, 2020 09:12
Compound words and programming case styles

Compound words and programming case styles

A compound word is formed by joining together two or more other words.

A closed-form compound word (e.g. keyboard) does that without any additional punctuation. These are truly words in their own right, and so should be treated as such when applying programming casing conventions such as camelCase, PascalCase, kebab-case, or snake_case.

Open-form (e.g. living room) and hyphenated-form (e.g. long-term) compound words are less susceptible to incorrect casing.

Examples of incorrect camelCase

@robatwilliams
robatwilliams / frontendne2019.md
Created April 11, 2019 19:11
Notes from Frontend NE 2019 conference

Going Offline (Jeremy Keith)

  • Good libraries aim to make themselves redundant: consider jQuery > querySelector.
  • Users don't expect sites to work offline.

Using a Modern Web to Recreate 1980s Screens... (Remy Sharp)

  • Typed arrays are much quicker. Fixed length and known types mean they can be in contiguous memory.
  • "Crapify"
@robatwilliams
robatwilliams / D3Adapter.js
Last active April 18, 2019 19:19
Framework adapters: D3-for-React + React-for-D3
import * as d3 from 'd3';
import PropTypes from 'prop-types';
import React, { PureComponent } from 'react';
/**
* Adapter for using D3 components in React.
*
* To be compatible, D3 components must follow the reusable component convention
* as proposed by Mike Bostock: https://bost.ocks.org/mike/chart/
*
@robatwilliams
robatwilliams / webpack.blocks.js
Created November 28, 2018 09:54
Organising webpack config
const dependencyCssRule = {
};
function sassRule(options) {
return {
test: 1,
use: [
// use options.prod to turn off sourcemaps
// use options.prod to set sass outputStyle compressed/not
# put in ~/.bashrc
alias git='gitwrapper'
gitwrapper () {
if [ "$1" == 'reset' ] && [ "$2" == '--hard' ]; then
\git status --short
read -n 1 -p 'Continue with hard reset (y/n)? ' answer
if [ "$answer" == 'y' ]; then
@robatwilliams
robatwilliams / README.md
Last active January 18, 2018 21:13
Compound annual growth rates (dynamic scale)

Displays investment compound annual growth rates over all time frames. Rows represent start years from 1986, columns represent number of years the investment was held for.

Dynamic scale using ckmeans data clustering algorithm. This assigns the colours to groups with minimal differences in their values. A dynamic scale makes the visualisation usable on a wide variety of data, but makes it difficult to compare different sets of data (the scales would be different). In this implementation, it also results in a non-nice scale.

Inspired by the Portfolio Charts website's heat map - calculator, explanation.

FTSE All-Share Index yearly return data from http://www.swanlowpark.co.uk/ftseannual.jsp

References for CAGR calculation in code comments.

@robatwilliams
robatwilliams / README.md
Last active January 17, 2018 22:17
Compound annual growth rates

Displays investment compound annual growth rates over all time frames. Rows represent start years from 1986, columns represent number of years the investment was held for.

Inspired by the Portfolio Charts website's heat map - calculator, explanation.

FTSE All-Share Index yearly return data from http://www.swanlowpark.co.uk/ftseannual.jsp

References for CAGR calculation in code comments.

@robatwilliams
robatwilliams / README.md
Last active December 27, 2018 12:33
Currencies, then and now (2)

Companion gist for blog post: Mapping currency strength changes with D3

Displays currency strengthening or weakening against other world currencies, between a reference date in the past and today.

Try it out - click to change the base country, use the picker to change the reference date. Data is available from the start of 2000.

Uses ES6 features, so you need a modern browser.

Improvements over v1

  • Optionally use currencylayer for data, which has more countries (see "Data sources" below)