Skip to content

Instantly share code, notes, and snippets.

View adkron's full-sized avatar

Amos King adkron

View GitHub Profile
module ApiEndpoint
def endpoint_for(id)
id.constantize.eval do
has_many self.underscore, :through => :api_objects, :source => :endpoint, :source_type => self.to_s
end
has_many :api_objects, :as => :endpoint
has_many id, :through => :api_objects
end
end
@adkron
adkron / Berkshelf
Last active December 15, 2015 11:58
# -*- mode: ruby -*-
# vi: set ft=ruby :
site :opscode
cookbook "build-essential"
cookbook "mysql"
cookbook "openssl"
cookbook "ohai"
cookbook "yum"
@adkron
adkron / gist:5723823
Created June 6, 2013 18:35
alfred links for searches
ruby alfredapp://customsearch/Ruby%20Api%20Dock/ruby/ascii/url=http://apidock.com/ruby/search?query={query}
rails alfredapp://customsearch/Rails%20Api%20Dock/rails/ascii/url=http://apidock.com/rails/search?query={query}
rspec alfredapp://customsearch/Rspec%20Api%20Dock/rspec/ascii/url=http://apidock.com/rspec/search?query={query}
rb alfredapp://customsearch/search%20ruby-doc/rb/ascii/url=http://ruby-doc.org/search.html?cx=011815814100681837392%3Awnccv6st5qk&sa=Search&cof=FORID%3A9&q={query}
github alfredapp://customsearch/Search%20Github%20For/github/ascii/url=http://github.com/search?q={query}
@adkron
adkron / vimrc
Created July 6, 2013 02:08
Auto-reload of vim config as it changes
aug AutoloadVimrc
au!
au BufWritePost ~/dotfiles/vim.symlink/vimrc.symlink source $MYVIMRC
au BufWritePost ~/dotfiles/vim.symlink/*.vim source $MYVIMRC
aug END
@adkron
adkron / bob.rb
Last active December 20, 2015 14:39 — forked from anonymous/bob.rb
I edited this in the browser so I might not be quite right, but I think I got it.
class << Silent = Object.new
def heard?(other)
other.empty?
end
def respond
"Fine. Be that way."
end
end
@adkron
adkron / block_calls.rb
Created August 9, 2013 17:21
custom matchers for testing blocks
RSpec::Matchers.define :yield_arguments do |*expected_arguments|
chain :in do |block_method, *args|
@block_method = block_method
@method_args = args
end
match do |subject|
@actual_arguments = :no_arguments
block = ->(*args) { @actual_arguments = args }
subject.send(@block_method, *@method_args, &block)
class CreditInclusionType < IDontCare
Null = Object.new
class << Null
def by_term?
false
end
def by_credits?
false
class Notify
include Weechat
def notify_msg( data, buffer, date, tags, visible, highlight, prefix, message )
if highlight.to_i != 0
TerminalNotifier.execute(verbose = false, message: message)
end
return WEECHAT_RC_OK
end
class Notify
include Weechat
def notify_msg( data, buffer, date, tags, visible, highlight, prefix, message )
if highlight.to_i != 0
TerminalNotifier.execute(verbose = false, message: message)
end
return WEECHAT_RC_OK
end
require "data_bank"
class Node < Struct.new(:question, :yes, :no)
def call(*)
puts question
answer = gets
case answer.chomp
when ?y
yes.call(self)