Skip to content

Instantly share code, notes, and snippets.

View waynerobinson's full-sized avatar

Wayne Robinson waynerobinson

View GitHub Profile
@waynerobinson
waynerobinson / gist:904986
Created April 6, 2011 01:48
Address Object
class Address < ActiveRecord::Base
ADDRESS_TYPES = %w(Office Postal Shipping)
default_scope order('created_at DESC')
scope :active, where(active: true)
validates_inclusion_of :address_type, in: ADDRESS_TYPES, message: "must be one of #{ADDRESS_TYPES.to_sentence(last_word_connector: ' or ')}"
belongs_to :source, polymorphic: true
# _job
<div>
<%= fields_for :job do | f |
<%= render :partial => 'waypoints/waypoint', :locals => {:job_form => f} %>
</div>
--------------------------------
# _waypoint
- form_for :branch, @branch, :url => {:action => :create, :id => @branch.id} do |f|
= render :partial => 'form', :locals => {:f => f, :submit_button_caption => "Create Branch"}
require 'rubygems'
require 'irb/completion'
require 'irb/ext/save-history'
# inspired by https://gist.github.com/794915
# I've changed it a bit, it works fine for me now
# but i'm still searching for a better solution
def require_without_bundler(*gems)
unless defined?(::Bundler)
gems.each { |g| require g }
# activerecord logging methods
# very useful for digging into
# queries
require 'logger'
require 'activerecord' if rails?(2)
def enable_logger
log_to(Logger.new(STDOUT))
end
@waynerobinson
waynerobinson / gist:1182760
Created August 31, 2011 03:33
Standalone daemon
class QueueDaemon
class << self
def start!
Thread.new do
EventMachine.run do
puts "Asimov: Attempting Connection"
AMQP.connect(
:on_possible_authentication_failure => Proc.new {puts("Asimov: Possible Authentication Failure")},
@waynerobinson
waynerobinson / gist:1182761
Created August 31, 2011 03:33
In Rails app
class QueueDaemon
class << self
def start!
Thread.new do
EventMachine.run do
puts "Asimov: Attempting Connection"
AMQP.connect(
:on_possible_authentication_failure => Proc.new {puts("Asimov: Possible Authentication Failure")},
require 'rubygems'
require 'eventmachine'
require 'amqp'
class QueueDaemon
class << self
def exchange
@exchange
<html>
<head>
<title>Slide Example</title>
<style>
.viewport {
position: relative;
overflow: hidden;
width: 150px;
height: 200px;
border: 1px solid maroon;
<html>
<body>
<div>
<img style="width:30px;height:60px;vertical-align:middle;border:1px solid blue;">
<span style="">Works.</span>
</div>
</body>
</html>