Skip to content

Instantly share code, notes, and snippets.

Kevin Poorman noeticpenguin

View GitHub Profile
View custom_readers
attr_writer :dob, :anniversary
self.instance_variables.each do |x|
next unless self.methods.include? /#{x}=/
def x
return ---insert a call to your custom method here---
end
end
View gist:917814
property :id, Serial
# property :account, String
# property :case_comments, String #needs a new model
# property :case_milestones, String #needs a new model
property :closed_date, DateTime
property :case_number, String
property :reason, String
property :description, String
property :subject, String
property :created_date, DateTime
View gist:918075
SalesforceAdapter::Connection::Errors::FieldNotFound: You specified case_id as a field, but neither case_id or CaseId or case_id__c exist. Either manually specify the field name with :field, or check to make sure you have provided a correct field name.
from /Users/kevinpoorman/.rvm/gems/ruby-1.9.2-p180@portal/bundler/gems/dm-sfdc-adapter-26449a3733c2/lib/dm-sfdc-adapter/connection.rb:59:in `field_name_for'
from /Users/kevinpoorman/.rvm/gems/ruby-1.9.2-p180@portal/bundler/gems/dm-sfdc-adapter-26449a3733c2/lib/dm-sfdc-adapter/adapter.rb:16:in `block in initialize'
from /Users/kevinpoorman/.rvm/gems/ruby-1.9.2-p180@portal/gems/dm-core-1.0.2/lib/dm-core/property.rb:481:in `call'
from /Users/kevinpoorman/.rvm/gems/ruby-1.9.2-p180@portal/gems/dm-core-1.0.2/lib/dm-core/property.rb:481:in `field'
from /Users/kevinpoorman/.rvm/gems/ruby-1.9.2-p180@portal/bundler/gems/dm-sfdc-adapter-26449a3733c2/lib/dm-sfdc-adapter/adapter.rb:129:in `block in execute_select'
from /Users/kevinpoorman/.rvm/gems/ruby-1.9.2-p180@por
View gist:918169
class Case
include DataMapper::Salesforce::Resource
def self.reload
instance_methods.each { |x| undef_method(x) }
Kernel::load(__FILE__)
end
def self.default_repository_name
View gist:918175
class CaseComment
include DataMapper::Salesforce::Resource
def self.reload
instance_methods.each { |x| undef_method(x) }
Kernel::load(__FILE__)
end
def self.default_repository_name
:salesforce
@noeticpenguin
noeticpenguin / switch.rb
Created May 12, 2011 — forked from jbr/switch.rb
ruby 1.9.2 case-like switch
View switch.rb
# In response to:
# http://mlomnicki.com/ruby/tricks-and-quirks/2011/02/10/ruby-tricks2.html
# Ruby 1.9.2 has some neat stuff that lets us make a readable
# alternative case statement that calls each method in turn.
# 1.9.2 features used:
# * hashes are ordered in 1.9.2
# * cool JSON-style hash syntax
# * concise lambda syntax
View gist:1104037
def jira_api_get(base = "#{JIRA_URL}/#{JIRA_REST_ENDPOINT}", resource = "issue", sub_resource = nil)
ap JIRA_URL
effective_url = "#{base}#{resource}/#{@ticket_key}/#{sub_resource}"
ap effective_url
request = Typhoeus::Request.get(effective_url,
:disable_ssl_peer_verification => true,
:params => {:os_username => JIRA_USER, :os_password => JIRA_PASS})
return JSON.parse(request.body) if request.success?
if request.timed_out?
View gist:1104051
def jira_api_get(base, resource = "issue", sub_resource = nil)
base ||= "#{JIRA_URL}/#{JIRA_REST_ENDPOINT}"
effective_url = "#{base}#{resource}/#{@ticket_key}/#{sub_resource}"
ap effective_url
request = Typhoeus::Request.get(effective_url,
:disable_ssl_peer_verification => true,
:params => {:os_username => JIRA_USER, :os_password => JIRA_PASS})
return JSON.parse(request.body) if request.success?
if request.timed_out?
View snippet.rb
def clone
options[:instance].each do |ami_to_clone|
if options[:ami] then
ami_id = options[:ami]
else
ami_id
View snippet.rb
require 'rubygems'
require 'fssm'
require 'thor'
class Watcher < Thor
include Thor::Actions
def initialize(*args)
super
end
You can’t perform that action at this time.