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
module TimeSplits | |
extend ActiveSupport::Concern | |
module ClassMethods | |
def not_null?(attribute) | |
where(arel_table[attribute].not_eq(nil)) | |
end | |
def in_future?(attribute, default_threshold = Time.current) | |
not_null?(attribute).where(arel_table[attribute].gt(default_threshold)) |
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
# Set the host name for URL creation | |
SitemapGenerator::Sitemap.default_host = 'http://www.pycosystems.com' | |
SitemapGenerator::Sitemap.create do | |
# Put links creation logic here. | |
# | |
# The root path '/' and sitemap index file are added automatically for you. | |
# Links are added to the Sitemap in the order they are specified. | |
# | |
# Usage: add(path, options={}) |
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
{ | |
"auto_complete_selector": "text.html.erb, source - comment, meta.tag - punctuation.definition.tag.begin", | |
"bold_folder_labels": true, | |
"caret_style": "solid", | |
"color_scheme": "Packages/User/Cobalt (SL).tmTheme", | |
"default_line_ending": "unix", | |
"ensure_newline_at_eof_on_save": false, | |
"expand_tabs_on_save": true, | |
"file_exclude_patterns": | |
[ |
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
validates_existence_of: | |
This method can be used for both Active records as well as Active Resources - ie anything that responds to 'exists?'. It has been tested to work with Rails v2.2+ and supports all options that validates_each does (like allow_nil, if, unless, etc) and a couple of additional ones (resource_name => the attribute name that might be based on a domain concept; and resource_class => that could be derived from the resource name, but could be namespaced, etc). Here is the code: | |
def validates_existence_of(*attributes) | |
options = {:message => 'does not exist'}.merge(attributes.extract_options!) | |
validates_each(attributes, options) do |record, attr, value| | |
resource_name = options[:resource_name] | |
resource_name ||= attr.to_s.gsub(/_id$/, "") if attr.to_s =~ /_id$/ | |
resource_name || attr.to_s # last resort |
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
#!/usr/bin/env ruby | |
require 'open3' | |
def system_puts(command) | |
puts command | |
system command | |
end | |
branches = `git branch`.split("\n") | |
current_branch = branches.select{|l| l =~ /^\*/}.first.gsub("\* ", "") |
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
module Spec | |
module Extension | |
def using_constants(klass, new_constants) | |
old_constants = {} | |
begin | |
new_constants.each_pair do |name, value| | |
old_constants[name] = klass.__send__(:remove_const, name) | |
klass.const_set(name, value) | |
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
require 'i18n/backend/base' | |
module I18n | |
module Backend | |
module Base | |
def translate(locale, key, options = {}) | |
raise InvalidLocale.new(locale) unless locale | |
entry = key && lookup(locale, key, options[:scope], options) | |
if options.empty? |
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
require 'active_resource/base' | |
require 'active_resource/log_subscriber' | |
module ActiveResource | |
class LogSubscriber < ActiveSupport::LogSubscriber | |
def request_with_filtered_logging(event) | |
request_uri = event.payload[:request_uri] | |
start_of_query_string = request_uri.index("?") | |
request_uri_without_query_string = request_uri[0, start_of_query_string] | |
query_string = request_uri[(start_of_query_string + 1)..-1] |
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
Show hidden characters
// ~/.jshintrc | |
{ | |
// -------------------------------------------------------------------- | |
// JSHint Configuration, Strict Edition | |
// -------------------------------------------------------------------- | |
// | |
// This is a options template for [JSHint][1], using [JSHint example][2] | |
// and [Ory Band's example][3] as basis and setting config values to | |
// be most strict: |
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
require: | |
- rubocop-rspec | |
AllCops: | |
Include: | |
- '**/Capfile' | |
- '**/Gemfile' | |
- '**/Rakefile' | |
- '**/config.ru' | |
- '**/app/**/*' |
OlderNewer