This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DateTimeSelector | |
include TagHelper | |
POSITIONS = { :year => 1, :month => 2, :day => 3, :hour => 4, :minute => 5, :second => 6 } | |
def initialize(date, options={}) | |
@date = date | |
@options = options | |
@object = @options.delete(:object) | |
@object_name = @options.delete(:object_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---- | |
// Sass (v3.2.18) | |
// Compass (v0.12.4) | |
// Sass List-Maps (v0.9.7) | |
// ---- | |
@import "sass-list-maps"; | |
$baseline: 22px; | |
$category-font-size: 21px; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
say -v Cellos 'The Internet is down, down again, down again, oh noes. The Internet is down, oh noes, oh noes, oh noes, oh noes!' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if Rails.env.test? | |
# inspired by Braintree's original WebhookTestingGateway, but with way more flexibility and complete data | |
class BraintreeWebhookTestingGateway | |
class << self | |
def register_notification(identifier, kind = nil, &builder) | |
@notifications ||= {} | |
kind ||= identifier | |
@notifications[identifier] = [kind, builder] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- with_options(:scope => 'foo') do |i18n| | |
p Some HTML | |
/ will actually look up the value of the key "foo.bar" | |
p = i18n.t('bar') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%- with_options(:scope => 'devise.mailer.confirmation_reminder') do |i18n| -%> | |
<%= email_underlined_title(i18n.t('heading')) %> | |
<%= i18n.t('salutation', :name => @user.first_name) %> | |
<%= i18n.t('text') %> | |
<%= confirmation_url(@user, :locale => I18n.locale, :confirmation_token => @user.confirmation_token) %> | |
----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Invoice < ActiveRecord::Base | |
before_validation :generate_number, on: :create | |
private | |
def generate_number | |
prefix = "R#{Date.today.strftime('%y')}-" | |
last_order_number_this_year = self.class.where("number LIKE ?", "#{prefix}%").order("number DESC").limit(1).pluck(:number).first | |
number = last_order_number_this_year ? last_order_number_this_year.match(/\A#{prefix}(\d+)\z/)[1].to_i : 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
en: | |
number: | |
format: | |
separator: '.' | |
delimiter: ',' | |
precision: 2 | |
date: | |
input: | |
formats: | |
- :default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object.class_eval do | |
def deep_clone | |
Marshal::load(Marshal.dump(self)) | |
end | |
end | |
Array.class_eval do | |
def sum | |
self.inject(0) { |sum, element| sum += element } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
url = 'http://example.com/ ?api_token=a-token&username=USERNAME' # => "http://example.com/ ?api_token=a-token&username=USERNAME" | |
url =~ URI.regexp(%w[http https]) # => 0 | |
URI.parse(url) # => URI::InvalidURIError: bad URI(is not URI?): http://example.com/ ?api_token=a-token&username=USERNAME |
OlderNewer