Navigation Menu

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 / 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"
#!/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.rb
Last active September 6, 2016 22:52
Using PostgreSQL enums with ActiveRecord enums
require_relative 'boot'
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module EnumTest
class Application < Rails::Application
@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, -> {

Keybase proof

I hereby claim:

  • I am christiannelson on github.
  • I am xianpants (https://keybase.io/xianpants) on keybase.
  • I have a public key ASDLBvmc60ul0izAzkjTOx1ttbTt3MZ4Nx6jC2q49WPx-Qo

To claim this, I am signing this object:

@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)"
@christiannelson
christiannelson / benchmark.md
Last active August 29, 2015 14:01
Comparing "hello world" in node.js under dokku versus bare metal

Dokku vs. Bare Metal

Running on an Aleutia R50 Mini-server with an Intel i3 1.7 Ghz, 16 GB and SSD.

Dokku (docker fronted by nginx)

Running 10s test @ http://node-js-sample.kuju0.carbonfive.com/
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
 Latency 6.57ms 2.04ms 26.01ms 81.91%
@christiannelson
christiannelson / new-project-setup.md
Last active February 15, 2016 00:06
From Nothing to Continuous Deployment in about 10 Minutes

These instructions walk you through using Raygun to generate a new app, pushing it to GitHub, deploying it to Heroku (two envs: production and acceptance), and setting up continuous integration and deployment using CircleCI. There's a preference for command-line operations when possible.

Prerequisties

  • Homebrew
  • Heroku toolbelt (brew install heroku-toolbelt)
  • Postgres installed (brew install postgres) and running
  • Postgres superuser called 'postgres' (createuser -s postgres)
  • PhantomJS installed (brew install phantomjs)
  • GitHub gem (gem install hub)