Skip to content

Instantly share code, notes, and snippets.

View KelseyDH's full-sized avatar

Kelsey Hannan KelseyDH

  • Zepto Payments
  • Australia
View GitHub Profile
class User < ApplicationRecord
def savings_account
self.accounts.where(savings: true).first || NullAccount.new
end
def chequing_account
self.accounts.where(chequing: true).first || NullAccount.new
end
# app/domain/null_account.rb
class NullAccount
def id
raise "You are calling id on an account that doesn't exist. Make sure the user you're working with has accounts first before trying to call them."
end
def available_balance
Money.new(available_balance_cents, available_balance_currency)
end
@KelseyDH
KelseyDH / osx_setup.sh
Created January 14, 2020 19:30 — forked from dannysmith/osx_setup.sh
Sensible defaults for New Mac
#!/usr/bin/env bash
# ~/.osx — http://mths.be/osx
# Ask for the administrator password upfront
sudo -v
# Keep-alive: update existing `sudo` time stamp until `.osx` has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
@KelseyDH
KelseyDH / local-dnsserver.md
Created February 4, 2020 20:30 — forked from nsbingham/local-dnsserver.md
Testing a CNAME

Setting up a local DNS server with bind on OSX Mavericks

This is really just an approach for locally testing DNS changes, which can easily be done with a HOSTS file if the change involves an IP address, but gets a bit trickier when things like CNAMEs are involved. This is only meant to test locally off a single machine.

  1. Install bind using homebrew

    brew install bind

  2. Follow the installation steps to start up bind

@KelseyDH
KelseyDH / README.md
Created May 19, 2021 03:06 — forked from tombigel/README.md
How to Change Open Files Limit on OS X and macOS Sierra (10.8 - 10.12)

How to Change Open Files Limit on OS X and macOS

This text is the section about OS X Yosemite (which also works for macOS Sierra) from https://docs.basho.com/riak/kv/2.1.4/using/performance/open-files-limit/#mac-os-x

The last time i visited this link it was dead (403), so I cloned it here from the latest snapshot in Archive.org's Wayback Machine https://web.archive.org/web/20170523131633/https://docs.basho.com/riak/kv/2.1.4/using/performance/open-files-limit/

Mac OS X

To check the current limits on your Mac OS X system, run:

@KelseyDH
KelseyDH / twitterblue-nerd.js
Last active November 10, 2022 05:47 — forked from busybox11/twitterblue-nerd.js
create a safe path for using this script
// ==UserScript==
// @name @chaoticvibing Twitter Blue Nerd - twitter.com
// @namespace Violentmonkey Scripts
// @match *://*.twitter.com/*
// @grant none
// @version 1.2.0
// @author @chaoticvibing - GH @busybox11
// @description 11/9/2022, 11:45:28 PM
// @updateURL https://gist.githubusercontent.com/KelseyDH/7478e6fea882a5a685ededdebf0d51ea/raw/76eedc195d471add755e84c71bf92126908b1629/twitterblue-nerd.js
// @downloadURL https://gist.githubusercontent.com/KelseyDH/7478e6fea882a5a685ededdebf0d51ea/raw/76eedc195d471add755e84c71bf92126908b1629/twitterblue-nerd.js