Skip to content

Instantly share code, notes, and snippets.

View kbrock's full-sized avatar

Keenan Brock kbrock

View GitHub Profile
@kbrock
kbrock / Gemfile
Created April 8, 2011 03:36
initializer to load debugger
gem 'rdebug', '0.1', :group => :development, :require => false
@kbrock
kbrock / 01_before.txt
Created October 1, 2010 12:23
Hirb example
>> Disease.find(2)
=> #<Disease id: 2, name: "MS", symptom_survey_lifespan: 30, disease_status_id: 3, key: "ms", community_manager_id: 3187, created_at: nil, updated_at: nil>
>> User.first
# => #<User id: 22, verified: true, deleted: false, created_at: "2008-07-03 13:36:57", updated_at: "2010-09-23 03:18:13", first_name: "Justin", last_name: "Smith", title: "wife", disease_id: 2, address: nil, city: "Boston", state: "MA", country: "United States", sex: nil, birth_date: nil, deceased_date: nil, permit_registry: nil, height: nil, display_height_unit: nil, display_weight_unit: nil, allows_public_view: false, lat: #<BigDecimal:1098c57d0,'0.28228671E2',18(18)>, lng: #<BigDecimal:1098c56e0,'-0.81653075E2',18(18)>, postcode: "02142", last_activity_time: "2008-07-03 13:38:10", last_update_time: nil, allows_badge: false, timezone: nil, phone: nil, messaging_privileges: nil, role_id: 5, unsubscribe_token: "21a497dae68b11780871083eddd6a3f201389bd6", welcome_message_sent_on: "2009-03-24", system_welcome_message_sent_o
module ActiveRecord
##idea is from lovdbyless
##These extensions give database specific implementations for common functions
module ConnectionAdaptersExt
module MySQL
def rand
'RANDOM()'
end
def now
'NOW()'
# Apple Script to open google in a new tab
# tell application "Safari"
# make new document
# set URL of first document to "http://www.google.com"
# end tell
# rb-appscript to do the same
# app("Safari").make(:new => :document)
# app("Safari").documents[1].URL.set("http://www.google.com")
@kbrock
kbrock / example.rb
Created June 5, 2009 13:25
copy an irb command to clipboard
copy {
puts "puts 'hello world'"
}
#command V
ep
framework 'ScriptingBridge'
safari = SBApplication.applicationWithBundleIdentifier('com.apple.Safari')
google_tab=safari.windows.first.currentTab
cmd="document.f.q.value='mac ruby'"
safari.performSelector(:"doJavaScript:in:", withObject:cmd, withObject:google_tab)
--applescript
tell application "Safari"
activate
set google_tab to current tab of first window
-- google currently open in the screen
tell google_tab
do JavaScript "document.f.q.value='mac ruby'"
end tell
end tell