Skip to content

Instantly share code, notes, and snippets.

View jwaldrip's full-sized avatar
:octocat:

Jason Waldrip jwaldrip

:octocat:
View GitHub Profile
class Contact < ActiveRecord::Base
def label
matter_contactable_id
attribute :label
rescue NameError
raise MissingAssociationError, "labels are only accessible through a created matter relationships"
end
# Instance Methods
class UserSession
class << self
attr_reader :client
def authorize_url
client.authorize_url
end
def report_object_space
@last_report ||= {}
current_report = Hash[ObjectSpace.each_object.group_by(&:class).map { |klass, objects| [klass, objects.map(&:object_id)] }]
leftovers = {}
changes = current_report.reduce({}) do |hash, (klass, ids)|
last = @last_report[klass] || []
next hash unless [last.count, ids.count].all? { |i| i.is_a? Integer }
change = ids.count - last.count
leftovers[klass] = (ids - last).map { |id| ObjectSpace._id2ref(id) rescue nil }.compact
hash[klass] = last.count..ids.count unless change == 0
# Yummy Splats
def say(person, communication, volume)
...
end
say *['jeff', 'I love splats', :loud] == say('jeff', 'I love splats', :loud)
rxp = ActiveSupport::Duration.name.split('::').map do |name|
"(module |class |::)#{name}"
end.join('(\s*#.*\n)*\s*')
%r{#{rxp}}
#cloud-config
coreos:
units:
- name: etcd.service
command: start
- name: docker-tcp.socket
command: start
runtime: true
content: |
[Unit]
Her::API.setup url: "https://api.example.com" do |c|
c.use :instrumentation
end
ActiveSupport::Notifications.subscribe('request.faraday') do |name, start_time, end_time, _, env|
url = env[:url]
http_method = env[:method].to_s.upcase
Rails.log.info "String of your choice"
end

Installing Ruby on OSX

Install Homebrew

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Install RbEnv

brew install rbenv

Add the following to ~/.bash_profile

randDir=/tmp/github-migrate/$(openssl rand -hex 16)
mkdir -p $randDir
read -p "Enter the github remote: " ghremote
read -p "Enter the stash remote: " stashremote
echo ""
echo "Pulling from $ghremote"
echo ""
git clone $ghremote --mirror $randDir
$ brew install jwaldrip/utils/git-get -v --HEAD
==> Installing git-get from jwaldrip/homebrew-utils
==> Cloning https://github.com/jwaldrip/git-get.git
git --git-dir /Library/Caches/Homebrew/git-get--git/.git status -s
Updating /Library/Caches/Homebrew/git-get--git
git config remote.origin.url https://github.com/jwaldrip/git-get.git
git config remote.origin.fetch +refs/heads/master:refs/remotes/origin/master
git fetch origin
git checkout -f master
Already on 'master'