Skip to content

Instantly share code, notes, and snippets.

View KelseyDH's full-sized avatar

Kelsey Hannan KelseyDH

  • Bite Interactive
  • Vancouver
View GitHub Profile
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 -
// @namespace Violentmonkey Scripts
// @match *://**
// @grant none
// @version 1.2.0
// @author @chaoticvibing - GH @busybox11
// @description 11/9/2022, 11:45:28 PM
// @updateURL
// @downloadURL
KelseyDH /
Created May 19, 2021 03:06 — forked from tombigel/
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

The last time i visited this link it was dead (403), so I cloned it here from the latest snapshot in's Wayback Machine

Mac OS X

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

KelseyDH /
Created February 4, 2020 20:30 — forked from nsbingham/
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 /
Created January 14, 2020 19:30 — forked from dannysmith/
Sensible defaults for New Mac
#!/usr/bin/env bash
# ~/.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 &
# 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."
def available_balance, available_balance_currency)
class User < ApplicationRecord
def savings_account
self.accounts.where(savings: true).first ||
def chequing_account
self.accounts.where(chequing: true).first ||
# .present?
if user.savings_account.present?
# .try
user.try(:savings_account).(:available_balance_cents) || 0
KelseyDH / null_object_example.rb
Created August 23, 2019 09:59
Using Null Object pattern in Ruby on Rails apps
# E.g. for a banking app where users might not have bank accounts yet.
# Not having accounts could mean lots of code like this:
if user.savings_account.present?
# But with the NullObject pattern I can confidently call:
KelseyDH / service_object.rb
Created January 27, 2018 08:26
How to write a Rails Service Object with logging
# # A Plain Old Ruby Object (poro) with Rails logger support:
class ServiceObject
def initialize(foo)
@logger =
@foo = foo
def call
KelseyDH / thread_safe.rb
Created July 18, 2017 22:30 — forked from mikbe/thread_safe.rb
Stops collisions but it's ugly
require 'thread'
module ThreadSafe
def self.included(base)
base.threadsafe_class_mutex =
module ThreadSafeClassMethods