Skip to content

Instantly share code, notes, and snippets.

View wheresrhys's full-sized avatar

Rhys Evans wheresrhys

View GitHub Profile
@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}) => {
(function(response) {
var output = [];
for (var i = 0; i < response.length; i++) {
if (response[i].type === 'PullRequestEvent') {
output.push(response[i])
}
}
return output;
})
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,
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)
[...document.querySelectorAll('.State:not([title="Status: Open"])')].map(e=>e.closest('.js-branch-row').querySelector('.js-branch-delete-target').click())
@wheresrhys
wheresrhys / history.md
Last active June 17, 2016 16:03
Preflight redirect caching

#1st generation

Request arrives in fastly, backend is set to point to our preflight app, response comes back, we decorate the request with headers (including a flag to indicate preflight has successfully happened) then restart. This time it goes through to our router, or cached response if it exists Note - code examples simplified to exclude error handling etc

vcl_recv () {
   if (req.http.preflighted) {
  1. At start of n-ui/main.js have
window.ftNextDummySymbol = function (){return {iterator: {}}};

This will mean any typeofs called before polyfill shave loaded don't error. Safe to do as any typeof calls looking for Symbol in our application before polyfills have loaded shodul be made to fail anyway

  1. Create an npm component, which has two files
  • assume-symbol/symbol contains
Install
- We'll never know which resources to cache
- ... apart from (maybe) shared js bundle
- ... but only if the shared js bundle is tied to the sw version