Skip to content

Instantly share code, notes, and snippets.

View robatwilliams's full-sized avatar

Robat Williams robatwilliams

View GitHub Profile
@robatwilliams
robatwilliams / README.md
Last active December 27, 2018 12:32
Currencies, then and now

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.

Data sources

World map: https://github.com/topojson/world-atlas

@robatwilliams
robatwilliams / README.md
Last active January 10, 2018 12:24
Asset allocation glide path chart

Reproduction of a real asset allocation glide path chart using D3 and D3FC.

It shows the investment fund moving towards safer assets as the target date nears.

Uses ES6 features, so you need a modern browser.

// Based on https://spectreattack.com/spectre.pdf, sections 3 mainly, 4, 4.3
// Also see: https://webkit.org/blog/8048/what-spectre-and-meltdown-mean-for-webkit/
const array1 = [1, 2, 3];
const array1_size = 3;
const array2_size = (64 * 1024) / 8;
const array2 = new Array(array2_size); // 8192 empty 8-byte entries = 64KB. 64KB is 256*256
function run() {
setup();
@robatwilliams
robatwilliams / expected.txt
Created December 19, 2017 14:11
Check expected & unexpected HTTP headers
HTTP/1.1 200 OK
Content-Encoding: gzip
@robatwilliams
robatwilliams / HtmlModuleScriptWebpackPlugin.js
Created December 3, 2017 23:25
Plugin to create HTML page which loads ES5 or ES6 build according to browser capability
const { concat, mapKeys, merge, uniq } = require('lodash');
/**
* Tweaked from original by Mike Engel
* https://github.com/jantimon/html-webpack-plugin/issues/782#issuecomment-331229728
*
* Use this with multiple Webpack configurations that generate different builds
* for modern and legacy browsers. But use the same instance of the plugin in both configurations.
*
* It keeps track of assets seen in each build configuration, and appends script tags for
@robatwilliams
robatwilliams / useful-names.md
Last active March 29, 2023 12:32
List of names that tend to be useful in programming

Useful names

List of names that tend to be useful in programming. On their own, or for building names.

A thesaurus is also useful.

Things

  • action, operation
  • attribute, property
  • buffer, queue
@robatwilliams
robatwilliams / repoSize.sh
Created November 3, 2017 17:31
Get size of Git repo
git gc
git count-objects -vH
@robatwilliams
robatwilliams / deleteOldBranches.sh
Created November 3, 2017 17:30
Delete old local Git branches
# manually
git remote update origin --prune
git branch -vv | grep "gone]"
git branch -d theBranchName anotherBranch andAnotherBranch
# automatically
git branch -vv | grep "gone]" | awk '{print $1}' | xargs git branch -d
@robatwilliams
robatwilliams / index.html
Last active August 29, 2015 13:57
Binding the document head with KnockoutJS: http://bl.ocks.org/robatwilliams/raw/9833970/
<!doctype html>
<html>
<head>
<title data-bind="text: title">App: Loading ...</title>
<link rel="stylesheet" id="themeLink" data-bind="attr: { href: selectedTheme().url }"
href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/black-tie/jquery-ui.min.css" />
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.0/jquery.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.4/jquery-ui.js"></script>
@robatwilliams
robatwilliams / build.targets
Last active March 23, 2022 00:44
Get the names of directories under a specified directory in MSBuild
<PropertyGroup>
<ParentDir>$(MSBuildProjectDirectory)\some\folder</ParentDir><!-- This folder has subfolders folders a, b, c-->
</PropertyGroup>
<Target>
<ItemGroup>
<SubfolderFullPaths Include="$([System.IO.Directory]::GetDirectories('$(ParentDir)'))" />
<SubfolderNames Include="@(SubfolderFullPaths->'$([System.IO.Path]::GetFileName('%(SubfolderFullPaths.Identity)'))')" />
</ItemGroup>