Skip to content

Instantly share code, notes, and snippets.

View christiannelson's full-sized avatar

Christian Nelson christiannelson

  • West Monroe
  • San Francisco, CA
View GitHub Profile
Uninstall any existing node and nodenv brew packages
$ brew uninstall node nodenv nodenv-default-packages node-build-update-defs
Move any existing nodenv config out of the way
$ mv ~/.nodenv ~/.nodenv.orig
Start a new shell
Clone the nodenv repo in a scratch directory
$ cd Code/scratch
@christiannelson
christiannelson / haproxy-ssl.cfg
Created October 16, 2012 17:35
HAProxy Configurations
# References:
# http://blog.mixu.net/2011/08/13/nginx-websockets-ssl-and-socket-io-deployment/
# http://blog.exceliance.fr/2012/09/10/how-to-get-ssl-with-haproxy-getting-rid-of-stunnel-stud-nginx-or-pound/
#
global
nbproc 2
maxconn 16384
defaults
#!/bin/sh
echo "\nBootstrapping this machine...\n"
# Install HomeBrew
# HOMEBREW_PREFIX="/opt/homebrew"
if ! command -v brew >/dev/null; then
echo "- Installing Homebrew..."
@christiannelson
christiannelson / application_controller.rb
Last active January 26, 2021 12:14
Code samples for a post on the Carbon Emitter (http://blog.carbonfive.com).
class ApplicationController < ActionController::Base
include Pundit
# Verify that controller actions are authorized. Optional, but good.
after_filter :verify_authorized, except: :index
after_filter :verify_policy_scoped, only: :index
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
private
@christiannelson
christiannelson / README.md
Last active November 1, 2020 04:02
Docker in 10 Minutes - Lightning Talk

Docker in 10 Minutes

What is Docker?

Docker is an open-source project to easily create lightweight, portable, self-sufficient containers. The same container that a developer builds and tests on a laptop can run at scale, in production, on VMs, bare metal, OpenStack clusters, public clouds and more.

What can you do with Docker?

@christiannelson
christiannelson / 0.config
Created November 26, 2012 00:08
Using HAProxy with Node.js, Socket.io and SSL
global
nbproc 1
maxconn 65536
defaults
timeout connect 5s
timeout queue 5s
timeout server 30s
timeout tunnel 1h
@christiannelson
christiannelson / better.rb
Last active September 19, 2018 13:40
Rails Database Best Practices
class Client < ActiveRecord::Base
has_many :projects
scope :active, -> { where(active: true) }
end
class Project < ActiveRecord::Model
belongs_to :client
scope :active, -> {
@christiannelson
christiannelson / commands.sh
Created March 29, 2018 16:09
Upgrading a Heroku DB
# The steps for upgrading a Heorku PostgreSQL database.
#
# https://devcenter.heroku.com/articles/upgrading-heroku-postgres-databases
# https://elements.heroku.com/addons/heroku-postgresql
heroku addons:create heroku-postgresql:hobby-basic -r production
heroku pg:info -r production
# Note the database names, we'll call them HEROKU_POSTGRESQL_NEW_URL and HEROKU_POSTGRESQL_OLD_URL
heroku maintenance:on -r production
@christiannelson
christiannelson / c5merge
Last active March 23, 2018 16:50
A shell script that merges (--no-ff) a feature branch after rebasing it.
#!/bin/sh
# This script captures a series of git commands that emcompass merging a feature into a target branch, like
# development or master. It updates the target branch and rebases the feature before merging with --no-ff.
# The end result is that there's always a merge commit and all of the commits are at the top of the timeline.
# This makes for easier to read git histories, especially with active teams.
# Is this a git repo?
if [[ ! -d .git ]]; then
echo "\nDirectory is not a git repo. Exiting...\n"
@christiannelson
christiannelson / steps.sh
Last active September 26, 2016 00:10
Opinionated instructions for setting up a laptop for development at Carbon Five. Not intended to be run wholesale; read, interpret, tweak (maybe), then run piece by piece.
# Opinionated instructions for setting up a laptop for development at Carbon Five.
# Not intended to be run wholesale; read, interpret, tweak (maybe), then run piece by piece.
#
# Tested against Yosemite 10.10.
#--------------------------------------
# Install Homebrew.
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"