Skip to content

Instantly share code, notes, and snippets.

View lukemorton's full-sized avatar

Luke Morton lukemorton

View GitHub Profile
function g; git $argv; end
function ll; ls -laH $argv; end
function _git_branch_name
set -l branch (command git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||')
if test -n "$branch"
echo $branch
else
set -l commit (command git rev-parse --short HEAD ^/dev/null)
@lukemorton
lukemorton / brew.sh
Last active March 19, 2020 11:13
My brew
#!/bin/sh
echo "Installing brew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
echo "Installing desktop apps..."
brew cask install google-chrome
brew cask install slack
brew cask install atom
brew cask install rowanj-gitx
# Example One: spec/unit/lib/space/flight/ship_gateway_spec.rb
RSpec.describe Space::Flight::ShipGateway do
let(:ship) { FactoryBot.create(:ship) }
let(:gateway) { described_class.new(ship_repository: Ship) }
context 'when finding a ship by id' do
subject { gateway.find_by_id(ship.id) }
it 'returns ship with correct id' do
@lukemorton
lukemorton / 01_DOCKER_LIKE_VAGRANT_README.md
Last active February 8, 2018 10:08
Using Docker like Vagrant

Using Docker like Vagrant

You may consider it heresy to use Docker like Vagrant however hear me out. This setup provides us a number of benefits:

  • We treat Docker as a virtual machine which make it easier to reason about, you know there is only one Docker container in use for the application at all times
  • By default we need to SSH into the Docker container with make ssh which then means subsequent command runs don't require Docker to initialise
  • We can stay logged into Docker so re-running tests is faster, and we can run specific tests, unlike make test
  • We no longer have to prefix commands in documentation with bin/docker_run bundle exec rspec instead we say make sure you are logged into the Docker container and then run commands as normal
  • It also means help on Stackoverflow can be followed more easily without needing to prefix things with bin/docker_run
  • PID issue no longer happens as you're always in the shell session that booted rails
@lukemorton
lukemorton / .gitconfig
Last active March 19, 2020 09:51
Latest git aliases
[alias]
st = status -sb
co = checkout
cp = cherry-pick
ci = commit
br = branch
sub = submodule
ls = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate
ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
undo = reset HEAD^
class MyHTTP
def get(uri)
@response = HTTP.get(uri)
end
def response
@response
end
end
@lukemorton
lukemorton / 01.rb
Last active September 24, 2016 18:12
module Billing
extend self
SENIOR_CITIZEN_DISCOUNT = 5
def billable_accounts
Account.where(free: false)
end
def monthly_bill(account)
function g; git $argv; end
function ll; ls -laH $argv; end
function _git_branch_name
set -l branch (command git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||')
if test -n "$branch"
echo $branch
else
set -l commit (command git rev-parse --short HEAD ^/dev/null)
feature('My feature', function () {
scenario('My scenario')
.when(UserDoesSomething)
.then(UserSeesSomething)
})
function scenario(name) {
var fns = [];
function when(fn) {
--require spec_helper
--color