Skip to content

Instantly share code, notes, and snippets.

View PatrickJS's full-sized avatar
💻
codex coding

PatrickJS PatrickJS

💻
codex coding
View GitHub Profile
@PatrickJS
PatrickJS / lambda-edge.js
Last active December 7, 2017 05:14 — forked from evanderkoogh/gist:f9012bc0163b6d9f2bde49046d8cf720
Example Edge@Lambda in AWS Cloudfront. Change URI based on host header
'use strict';
/*
* HTTP headers are case-insensitive. So 'Host' is a valid header, but so
* is 'host' or 'hOst'. To make sure we don't miss a header we first lowerCase
* all of them and then check for the lowercase version of the header
*/
const normaliseHeaders = (headers) => {
const normalisedHeaders = {};
const fields = Object.keys(headers);
@PatrickJS
PatrickJS / cache_storage_size.js
Created December 16, 2017 07:50 — forked from ebidel/sw_caching_size.js
Print service worker cache sizes and overall bytes cached.
/**
* @author ebidel@ (Eric Bidelman)
* License Apache-2.0
*/
// Prints the size of each cache in the Cache Storage API and the overall bytes cached.
async function getCacheStoragesAssetTotalSize() {
// Note: opaque (i.e. cross-domain, without CORS) responses in the cache will return a size of 0.
const cacheNames = await caches.keys();

Effective Engineer - Notes

What's an Effective Engineer?

  • They are the people who get things done. Effective Engineers produce results.

Adopt the Right Mindsets

@PatrickJS
PatrickJS / gist:91cef262e5092e186fe449e2d66776f8
Created January 28, 2018 18:10 — forked from vladimirtsyupko/gist:10964772
Git force pull to overwrite local files
git fetch --all
git reset --hard origin/master
git pull origin master
@PatrickJS
PatrickJS / falcor stuff
Created April 18, 2018 21:47 — forked from jhusain/falcor stuff
falcor stuff
https://github.com/Netflix/falcor-path-utils/blob/master/lib/toTree.js
[
["list",{from:0,to:9],["name","rating"]],
["list", "length"]
]
->
{
@PatrickJS
PatrickJS / current-dir-in-iterm-tab-title.sh
Created April 20, 2018 23:31 — forked from phette23/current-dir-in-iterm-tab-title.sh
Set the iTerm tab title to the current directory, not full path.
# put this in your .bash_profile
if [ $ITERM_SESSION_ID ]; then
export PROMPT_COMMAND='echo -ne "\033];${PWD##*/}\007"; ':"$PROMPT_COMMAND";
fi
# Piece-by-Piece Explanation:
# the if condition makes sure we only screw with $PROMPT_COMMAND if we're in an iTerm environment
# iTerm happens to give each session a unique $ITERM_SESSION_ID we can use, $ITERM_PROFILE is an option too
# the $PROMPT_COMMAND environment variable is executed every time a command is run
# see: ss64.com/bash/syntax-prompt.html
@PatrickJS
PatrickJS / gh-pages-deploy.md
Created May 30, 2018 06:34 — forked from cobyism/gh-pages-deploy.md
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

@PatrickJS
PatrickJS / tutorial.md
Created July 18, 2018 23:25 — forked from swalkinshaw/tutorial.md
Designing a GraphQL API

Tutorial: Designing a GraphQL API

This tutorial was created by Shopify for internal purposes. We've created a public version of it since we think it's useful to anyone creating a GraphQL API.

It's based on lessons learned from creating and evolving production schemas at Shopify over almost 3 years. The tutorial has evolved and will continue to change in the future so nothing is set in stone.

@PatrickJS
PatrickJS / buildSitemap.js
Created July 27, 2018 06:29 — forked from evantahler/buildSitemap.js
35 lines to build a sitemap for next.js projects
#! /usr/bin/env node
// I am ./bin/buildSitemap.js
const path = require('path')
const glob = require('glob')
const fs = require('fs')
const SITE_ROOT = process.env.SITE_ROOT || 'https://www.actionherojs.com'
const SOURCE = process.env.SOURCE || path.join(__dirname, '..', 'pages', '/**/*.js')
const DESTINATION = process.env.DESTINATION || path.join(__dirname, '..', 'static', 'sitemap.xml')
@PatrickJS
PatrickJS / Event-stream based GraphQL subscriptions.md
Created August 22, 2018 17:23 — forked from OlegIlyenko/Event-stream based GraphQL subscriptions.md
Event-stream based GraphQL subscriptions for real-time updates

In this gist I would like to describe an idea for GraphQL subscriptions. It was inspired by conversations about subscriptions in the GraphQL slack channel and different GH issues, like #89 and #411.

Conceptual Model

At the moment GraphQL allows 2 types of queries:

  • query
  • mutation

Reference implementation also adds the third type: subscription. It does not have any semantics yet, so here I would like to propose one possible semantics interpretation and the reasoning behind it.