Skip to content

Instantly share code, notes, and snippets.

View BrandAndCelebrities's full-sized avatar

Kolsquare legacy BrandAndCelebrities

View GitHub Profile
config.time_zone #ActiveRecord fetches the UTC time from the database and converts it to the time zone in
DateTime #if you need support for times very far from the present
# Good practices
2.hours.ago # => Thu, 27 Aug 2015 14:39:36 AFT +04:30
1.day.from_now # => Fri, 28 Aug 2015 16:39:36 AFT +04:30
Time.zone.parse("2015-08-27T12:09:36Z") # => Thu, 27 Aug 2015 16:39:36 AFT +04:30
Time.current # => Thu, 27 Aug 2015 16:39:36 AFT +04:30
Time.current.utc.iso8601 # When supliyng an API ("2015-08-27T12:09:36Z")
@yannvery
yannvery / log_level.rb
Created June 25, 2014 07:54
Manage log level in a Rails console
#To turn it off
old_logger = ActiveRecord::Base.logger
ActiveRecord::Base.logger = nil
#To turn it back on
ActiveRecord::Base.logger = old_logger
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@undees
undees / salesforce_oauth_first.rb
Created February 10, 2010 09:23
Connect Ruby to Salesforce via OAuth
require 'oauth'
consumer_key = '...' # from SalesForce
consumer_secret = '...' # from SalesForce
oauth_options = {
:site => 'https://login.salesforce.com',
:scheme => :body,
:request_token_path => '/_nc_external/system/security/oauth/RequestTokenHandler',
:authorize_path => '/setup/secur/RemoteAccessAuthorizationPage.apexp',