Skip to content

Instantly share code, notes, and snippets.

View superstructor's full-sized avatar

Isaac Johnston superstructor

View GitHub Profile

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

[alias]
lol = log --graph --decorate --pretty=oneline --abbrev-commit
logola = log --graph --decorate --pretty=oneline --abbrev-commit --all
[user]
name = Isaac Johnston
email = [email protected]
[core]
excludesfile = /Users/isaac/.gitignore_global
editor = vim
[color]
@superstructor
superstructor / gist:765df8bd2eddb02d21eb
Created September 14, 2014 09:58
etcd+git install via Docker
#!/bin/bash
docker run -v /opt/bin:/opt/bin --rm quay.io/joukou/golang /bin/bash -c "git clone https://github.com/coreos/etcd.git && cd etcd && ./build && cp bin/etcd /opt/bin"
function errexit() {
local err=$?
set +o xtrace
local code="${1:-1}"
echo "Error in ${BASH_SOURCE[1]}:${BASH_LINENO[0]}. '${BASH_COMMAND}' exited with status $err"
# Print out the stack trace described by $function_stack
if [ ${#FUNCNAME[@]} -gt 2 ]
then
echo "Call tree:"
for ((i=1;i<${#FUNCNAME[@]}-1;i++))
// This systemd runs iptables-restore on boot:
[Unit]
Description=Packet Filtering Framework
DefaultDependencies=no
After=systemd-sysctl.service
Before=sysinit.target
[Service]
Type=oneshot
ExecStart=/usr/sbin/iptables-restore /opt/docker/scripts/iptables/iptables.rules
@superstructor
superstructor / gist:5754905
Created June 11, 2013 06:47
Or for a coffee order maybe consider that the order and the payment could be independent resources, thus you get
{
"_links": {
"self": {
"href": "/api/orders/123"
},
"profile": {
"href": "/profiles/order"
}
"/rels/payments": {
"href": "/api/orders/123/payments",
@superstructor
superstructor / gist:5754903
Last active December 18, 2015 08:29
"/rels/delete" could tell the client "this is the link to follow to delete the context resource", whereas "/profiles/delete" could tell the client that to do so you DELETE /api/customer/42 ? Since there is no entity body the generic /profiles/delete provides enough semantics for any resource i.e. just use the DELETE method. "/rels/update-form" c…
{
"_links": {
"self": {
"href": "/api/customers/42"
},
"profile": {
"href": "/profiles/customer"
},
"/rels/delete": {
"href": "/api/customers/42",