Skip to content

Instantly share code, notes, and snippets.

View wheresrhys's full-sized avatar

Rhys Evans wheresrhys

View GitHub Profile
@wheresrhys
wheresrhys / ft-observable.md
Last active October 15, 2018 22:45
Logging/metrics idea

Basic motivation

  • We want to observe our systems. Sometimes we may want a log with messages in it, other times just a metric is fine. BUT the times we want either of these can be arbitrary... don't want to have to make a release of an app just because we're in the middle of an incident and want more detailed logs of something.
  • Want to untangle next-metrics from express
  • BUT ideally want any new thing to be reasonably backwards compatible

Sketch proposal

ft-observable

  • collects both logs & metrics in a unified interface
@wheresrhys
wheresrhys / you might not need lodash.md
Last active July 27, 2018 11:09
You might not need lodash

You might not need lodash

_.chunk

(arr, size) => [...Array(Math.ceil(arr.length/size))].map(() => arr.splice(0, size))

_.compact

(arr) => arr.filter(it => !!it)

_.concat

(arr, values) => arr.concat(...values)

@wheresrhys
wheresrhys / sw.md
Last active February 5, 2018 23:07
Service workers union

Service Workers Union, Financial Times branch

Report of the Extraordinary Working Group on Controlling the Means of Releasing to Production

Contents:

  1. Introduction - Comrade Evans
  2. Universal test coverage - Comrade Florisca
  3. Cooperation, and freedom, among independent features - Comrade Legg
  4. Some workers are more equal than others - Comrade Phillips
  5. The purge of service worker traitors - Comrade Militaru
  6. Any other business
@wheresrhys
wheresrhys / reckie.js
Last active November 8, 2017 23:23
reckie
Transform handlers compatible with express, lambda etc to each other
e.g.
reckie.lambdaToExpress = handler => {
return (req, res) => {
const event = eventFromRequest(req);
const callback = callbackFromResponse(res);
handler(event, null, callback);
@wheresrhys
wheresrhys / fix-json.sh
Last active June 27, 2017 13:06
json tabs to spaces
for file in $(find . -name '*.json');
do
node -e "fs.writeFileSync('$file', JSON.stringify(require('./$file'), null, 2) + '\n')"
done
@wheresrhys
wheresrhys / pipeline
Last active May 7, 2017 15:39
Experimental pipeline for preflight
// 1. want an object of promises kicked off by each task
// 2. each task declares its dependencies
// 3. if no dependencies it runs immediately
// 4. if dependencies, waits for them
// 5. unified pattern
const tasks = {};
// str, arr, (req, headers, deps) => headers
const taskRunner = {
register: ({name, dependencies, catchable, task}) => {
next-geebee.ft.com/assets --> www.ft.com/__assets/creatives
next-geebee.ft.com/hashed-assets --> www.ft.com/__assets/hashed
next-geebee.ft.com/n-ui --> www.ft.com/__assets/n-ui
next-geebee.ft.com/image/v1 --> www.ft.com/__origami/service/image/v2 (but double check the output is as expected)
next-geebee.ft.com/build --> www.ft.com/__origami/service/build
next-geebee.ft.com/polyfill --> www.ft.com/__origami/service/polyfill
Remember to also search the codebase for uri encoded versions of the urls as these will need updating too.
We don't have a switch off date for next-geebee yet, but as it's a next project experiment, rather than a platform,
@wheresrhys
wheresrhys / gist:5823198
Created June 20, 2013 14:28
Adds outer/innerHeight/Width methods to Zepto Adapted from https://gist.github.com/alanhogan/3935463
(function($) {
// Add inner and outer width to zepto (adapted from https://gist.github.com/alanhogan/3935463)
var ioDim = function(dimension, includeBorder) {
return function (includeMargin) {
var sides, size, elem;
if (this) {
elem = this;
size = elem[dimension]();
sides = {
width: ["left", "right"],
(function(response) {
var output = [];
for (var i = 0; i < response.length; i++) {
if (response[i].type === 'PullRequestEvent') {
output.push(response[i])
}
}
return output;
})
To go to a file:
Cmd ⌘ + P (Mac)
Go to a symbol:
Cmd ⌘ + R (Mac)
Go to a line:
Ctrl ⌃ + G (Mac) (or Cmd ⌘ + P (Mac) then :)
EXPAND SELECTION TO SCOPE LINK
Cmd ⌘ + Shift ⇧ + Space ␣ (Mac)