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
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb |
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.development? | |
Rails.application.assets.logger = Logger.new('/dev/null') | |
Rails::Rack::Logger.class_eval do | |
def before_dispatch_with_quiet_assets(env) | |
before_dispatch_without_quiet_assets(env) unless env['PATH_INFO'].index("/assets/") == 0 | |
end | |
alias_method_chain :before_dispatch, :quiet_assets | |
end | |
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
- any character you use it will literally match it except special characters | |
^ $ ? . / \ [ ] { } ( ) + * - all the special characters that will need escaping if you don't want them to be special | |
// - regexp ruby class | |
Common Patterns (I authored) | |
/[\w+\.~-]+@[\w~-]+.[\w\.]+/ - match emails, conforms to RFC 3986 section 3.3 | |
/\+?(\d)?[-|\.|\s]?\(?(\d{3})\)?[-|\.|\s]?(\d{3})[-|\.|\s]?(\d{4})/ - match phone numbers, https://gist.github.com/1009331 | |
Strategies |
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
Fabricate(:person) do | |
ssn { sequence(:ssn, 111111111) } | |
email { sequence(:email) { |i| "user#{i}@example.com" } } | |
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
module Mongo | |
module Instrumentation | |
def self.instrument(clazz, *methods) | |
clazz.module_eval do | |
methods.each do |m| | |
class_eval %{def #{m}_with_instrumentation(*args, &block) | |
ActiveSupport::Notifications.instrumenter.instrument "mongo.mongo", :name => "#{m}" do | |
#{m}_without_instrumentation(*args, &block) | |
end | |
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
class Message < ActiveRecord::Base | |
include Postgre::Searchable | |
has_many :tags, inverse_of: :message | |
search_on do |message| | |
[ message.subject, | |
message.body, | |
message.tags.map(&:name) ] | |
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
(function ($) { | |
$.event.special.textchange = { | |
setup: function (data, namespaces) { | |
$(this).bind('keyup.textchange', $.event.special.textchange.handler); | |
$(this).bind('cut.textchange paste.textchange input.textchange', $.event.special.textchange.delayedHandler); | |
}, | |
teardown: function (namespaces) { |