Skip to content

Instantly share code, notes, and snippets.

View PatrickJS's full-sized avatar

PatrickJS PatrickJS

View GitHub Profile
@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 / 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 / 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 / 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

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 / 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();
@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);
exports.handler = function(event, context) {
// We'd get this from the Lambda event in reality
var sampleInput = {
from: 1,
to: 39,
bucketName: 'test-bucket',
imageSizes: [{
width: 600,
height: 400,
description: 'A medium thumbnail',
exports.handler = function(event, context) {
var sampleInput = {
totalPhotos: 496,
imagesPerLambda: 100,
bucketName: 'sample-bucket',
imageSizes: [{
width: 600,
height: 400,
description: 'A medium thumbnail',
@PatrickJS
PatrickJS / hyper-nitty-gritty.js
Created November 7, 2017 14:38 — forked from WebReflection/hyper-nitty-gritty.js
hyperHTML, the nitty gritty
// used to retrieve template content
const templates = new Map;
// used to retrieve node updates
const updates = new WeakMap;
// hyperHTML, the nitty gritty
function hyperHTML(chunks, ...interpolations) {
// if the static chunks are unknown