Skip to content

Instantly share code, notes, and snippets.

View wbrady's full-sized avatar

Will Brady wbrady

  • Palantir
  • Washington, D.C.
View GitHub Profile
@wbrady
wbrady / how-to-set-up-stress-free-ssl-on-os-x.md
Last active August 29, 2015 14:26 — forked from jed/how-to-set-up-stress-free-ssl-on-os-x.md
How to set up stress-free SSL on an OS X development machine

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

@wbrady
wbrady / Example.md
Last active August 29, 2015 14:07
Amazon SQS Example in Go

Amazon SQS Example in Go

Here is an example sending and receiving messages. The first commands sends two messages. The next receive command receives both messages (but it could have just gotten one of them) and deletes them. The next receive command doesn't get any because there aren't any left in the queue.

The queue name ("test" in my case) and AWS region is hard-coded in this example. I set the queue up manually in AWS beforehand.

http://godoc.org/github.com/crowdmob/goamz/sqs

> go run connect.go send.go -access_key="MY_ACCESS_KEY" -secret_key="MY_SECRET_KEY"
@wbrady
wbrady / postgres_headaches.txt
Created November 14, 2013 02:12
postgres headaches
uninstall current postgresql and postgis
brew tap homebrew/versions
brew install postgis20 (which will also install postgresql92)
startup postgresql
reinstall pg gem - not enough
reinstall activerecord pg adapter
ran into problem of having old server running - answer http://stackoverflow.com/questions/16264973/postgis-homebrew-installation-referencing-an-old-path
@wbrady
wbrady / problem.coffee
Created October 24, 2013 14:47
Why I hate coffeescript
featureMap = this.model.get('provider_feature_map')
$('.feature-row').each(->
featureCode = $(this).data('code')
$('input', this).each(->
bookingMapCode = $(this).data('code')
featureMap[featureCode][bookingMapCode] = $(this).is(':checked') # this loop will only run until this call returns false because of the implicit return and "eventedness" of javascript
)
)
@wbrady
wbrady / gemfile_spec.rb
Last active December 22, 2015 20:19
Spec to test that your Gemfile locks all of its gems
# In your Gemfile:
#
# group :test do
# gem 'gemnasium-parser', '0.1.9'
# end
#
require 'spec_helper'
describe 'Gemfile' do
@wbrady
wbrady / fix-confluence-spaces.rb
Created April 3, 2013 13:02
Fix confluence space names
#!/usr/bin/env ruby
require 'xmlrpc/client'
puts "Please enter your Confluence base URL:"
base = STDIN.gets.chomp
puts "Please enter your username:"
user_name = STDIN.gets.chomp
@wbrady
wbrady / create-confluence-spaces.rb
Created March 29, 2013 18:54
Ruby script to create Confluence personal spaces for users who don't have one
#!/usr/bin/env ruby
require 'xmlrpc/client'
puts "Please enter your Confluence base URL:"
base = STDIN.gets.chomp
puts "Please enter your username:"
user_name = STDIN.gets.chomp
@wbrady
wbrady / post-merge
Created March 12, 2013 14:34
Website (rails) post-merge hook
#!/bin/sh
diff=`git diff --name-only HEAD@{1} HEAD`
gemfile=`expr "$diff" : ".*Gemfile.*"`
if [ ! "$gemfile" -eq 0 ]
then
echo "Running bundle install"
bundle install
fi
@wbrady
wbrady / post-merge
Last active December 11, 2015 18:09
NIC+ post-merge git hook
#!/bin/sh
diff=`git diff --name-only HEAD@{1} HEAD`
packages=`expr "$diff" : ".*package.json.*"`
if [ ! "$packages" -eq 0 ]
then
echo "Installing new packages"
npm install
fi
@wbrady
wbrady / canvas-logo.html
Last active December 11, 2015 06:48
Near Infinity logo using HTML5 canvas
<canvas id='logo' width="250" height="100">
</canvas>
<script>
var canvas = document.getElementById('logo');
if (canvas.getContext) {
var ctx = canvas.getContext("2d");
// Draw black oval
ctx.save();