Skip to content

Instantly share code, notes, and snippets.

View stuartpb's full-sized avatar

Stuart P. Bentley stuartpb

View GitHub Profile
@stuartpb
stuartpb / parseUrl.js
Created December 29, 2013 05:55
A small function to parse URLs without relying on the DOM
function parseUrl(url) {
var urlRegex = /^(?:([A-Za-z]+):)?(\/{0,3})([0-9.\-A-Za-z]+)(?::(\d+))?(?:\/([^?#]*))?(?:\?([^#]*))?(?:#(.*))?$/;
var result = urlRegex.exec(url);
return {
href: result[0], protocol: result[1], slashes: result[2],
hostname: result[3], port: result[4], pathname: result[5],
query: result[6], hash: result[7]};
}
@stuartpb
stuartpb / index.html
Created November 28, 2013 03:51
A bare-bones centered content page, for bootstrapping an initial placeholder
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Coming soon</title>
<style>
html, body {
height: 100%;
width: 100%;
margin: 0;
@stuartpb
stuartpb / convert.js
Created October 11, 2013 04:18
JavaScript to turn any example in an RFC into the most boring erotic slashfic ever
function convertToEroticSlashfic(example) {
return example.replace(/her/g, 'his')
.replace(/Alice/g, 'Harry')
.replace(/Bob/g, 'Draco');
}
var convertToEroticSlashfic_codegolf =
function(s){return s.replace(/Alice/g,'Linda')}
@stuartpb
stuartpb / gist:6929423
Last active December 25, 2015 06:09
An example of two clients connecting via the proposed Chatphrase RESTful signaling flow.

This document is (very) obsolete

Since this example was written, the connection flow used by caress evolved in several ways (not necessarily in this order):

  • POSTs for updating were replaced with PUTs, in closer accordance with the verbs' meanings in HTTP.
  • The multiple layers of UUID were reduced to one, with each UUID containing all its associations on the back end.
  • The Offer-To and Answer-At locations were consolidated into one location that acts as both depending on the method used (and suggested for use with query string differentiation to get around browser concurrency restrictions).
  • Multiple "Answer-To" endpoints for each party reading the offer were consolidated into a single "winner-first" endpoint presented to any inquiring parties (and invalidated after the first response).
  • The "Chatphrase-*" headers were replaced with "Location" (for paths expected to be used with GET) and "Reply-Location" (for paths expected to be exclusively POSTed to).
  • "Cha
@stuartpb
stuartpb / font-comparison.html
Created September 11, 2013 03:15
The page I used for mocking up blot.pw's wordmark in different fonts. #bikeshedding
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>blot.pw</title>
<link href='//fonts.googleapis.com/css?family=Kavoon|Peralta|Margarine|Chicle|Special+Elite|Ceviche+One|Freckle+Face|Skranji|Sarina' rel='stylesheet' type='text/css'>
<link href='//fonts.googleapis.com/css?family=Gorditas|Sansita+One|Pacifico|Norican|Fontdiner+Swanky|Henny+Penny|Wendy+One' rel='stylesheet' type='text/css'>
<link href='//fonts.googleapis.com/css?family=Rock+Salt|Seaweed+Script|Damion' rel='stylesheet' type='text/css'>
<link href='blot.svg' rel='icon' type='image/svg+xml'>
<style>

Some advice on setting up 12-factor apps in different environments. The environment variables suggested to set are based on the ones used by envigor (which are themselves based on common precedent).

General advice

  • Consider your app's environment secret. Most configuration variables (except, maybe, PORT) are imbued with the authentication credentials your app uses to connect to any and all services. Never include a live config in any form with your code. Never place a config somewhere public. Never expose your config.
  • Every place you store your config variables is one more place they can be leaked from. Devops valuing paranoia over convenience should keep config in two places: the live server, and the configuration of the related services themselves

Run environments

Bare processes

@stuartpb
stuartpb / deprecated-petlog.md
Last active May 7, 2017 23:27
Log of changes made to my Linode from after the point where I reinstalled the system image
@stuartpb
stuartpb / deprecated-petlog.md
Last active May 7, 2017 23:26
Log of config actions taken on my old removable Linux setup
@stuartpb
stuartpb / glorw.txt
Created June 4, 2013 22:43
General list of reserved words
### General List of Reserved Words
### Stuart P. Bentley <stuart@testtrack4.com>, June 4, 2013
## This is a general list of words you may want to consider reserving,
## in a system where users can pick any name, in a context where the
## system may use names as well. One prominent example of a system
## where this is the case would be a site that serves pages for users,
## at their username, from the site root, like
## http://twitter.com/stuartpb . In this system, you would want to
## reserve some routes for pages that would commonly be expected to