Skip to content

Instantly share code, notes, and snippets.

if application "Messages" is running then
tell application "Messages"
log in service "transue@gmail.com"
set status of service "transue@gmail.com" to available
set status message to "%Track - %Artist"
end tell
end if
# Load plugins (only those I whitelist)
Pry.config.should_load_plugins = false
Pry.plugins["doc"].activate!
# Launch Pry with access to the entire Rails stack.
# If you have Pry in your Gemfile, you can pass: ./script/console --irb=pry instead.
# If you don't, you can load it through the lines below :)
rails = File.join Dir.getwd, 'config', 'environment.rb'
if File.exist?(rails) && ENV['SKIP_RAILS'].nil?
module TouchMyScheme
after_save :touch_my_scheme
def touch_my_scheme
scheme.touch
end
end
include "lib/touch_my_scheme"
@bill-transue
bill-transue / add_rotator.rb
Created October 26, 2012 16:58
Is this dumb?
def add_rotator_to(hash)
hash.define_singleton_method :rotator do
inject({}) do |rotated, key_value|
if key_value.first =~ /_rotate/
rotated.merge key_value.first[0..-8].to_sym => self[key_value.first].rotate!.first
else
rotated.merge key_value.first => key_value.last
end
end
end
describe "copying" do
context "within a cabinet_template" do
let (:cabinet_template) { FactoryGirl.create :cabinet_template }
let!(:ports) do
FactoryGirl.create_list(:component,
:with_ports,
:number_of_ports => 1,
:cabinet => cabinet_template).collect(&:ports).reduce(&:+).tap do |ports|
FactoryGirl.create :cable, :connections => ports
end
class Strands.Models.Site extends Backbone.Model
url: ->
if this.isNew()
'/sites.json'
else
'/sites/' + this.id + '.json'
link: -> '/sites/' + this.id
name: -> @get('name')
class Cable < ActiveRecord::Base
has_many :connections, :class_name => 'Port', :autosave => false
end
class Cable < CopyableActiveRecord
has_many :ports, :through => :connections
belongs_to :type, :class_name => 'CableType'
end
@bill-transue
bill-transue / .gitignore
Created March 9, 2012 17:37
Self Referential Has Many Through Join
# See http://help.github.com/ignore-files/ for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile ~/.gitignore_global
# Ignore bundler config
/.bundle
# Ignore the default SQLite database.
@bill-transue
bill-transue / application_helper.rb
Created February 7, 2012 16:41
Reverse Nested Layouts...
module ApplicationHelper
def navigator(*columns, &block)
haml_tag :div, :id => "navigator", :class => "table" do
haml_tag :div, :class => "header" do
columns.each do |column|
haml_tag :div do
haml_concat column
end
end
end