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
-- fdsafdas | |
- fasdfdsa | |
fdasfdas |
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
# see what the confidence code means here: | |
# http://www.mapquestapi.com/geocoding/geocodequality.html | |
Web::Address.from_params({ :street => "Canal Road", :city => "Orleans", :state => "MA", :country => "US" }) | |
[{"country_name"=>"United States", | |
"city"=>"Orleans", | |
"@name"=>"location", | |
"latitude"=>41.796795, | |
"country"=>"US", |
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
ActiveRecord.where('created_at > ?', Time.now).to_sql |
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 Scope | |
def self.included(base) | |
base.has_scope :with_name_like | |
base.has_scope :with_title_like | |
end | |
end | |
class PostsController < ApplicationController | |
include Scope |
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 UsersController < ApplicationController | |
include User::SearchScope | |
def index | |
search_params = params[:user_search] || {} | |
@users = apply_scopes(User, search_params) | |
end | |
end | |
class User < ActiveRecord::Base |
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 UsersController < ApplicationController | |
def index | |
user_search = UserSearch.new(params[:user_search]) | |
@users = User.by_user_search(user_search) | |
end | |
end | |
# user search form object | |
class UserSearch | |
include Virtus.model |
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 'benchmark' | |
REGEXPS = [ | |
/^no such file to load -- (.+)$/i, | |
/^Missing \w+ (?:file\s*)?([^\s]+.rb)$/i, | |
/^Missing API definition file in (.+)$/i, | |
/^cannot load such file -- (.+)$/i, | |
] |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
foo = :bar if false | |
foo.nil? # => raises an error because...? |
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
ROM::Yesql::Repository.class_eval do | |
def initialize(uri, options = {}) | |
super | |
@connection = Sequel::Model.db | |
initialize_queries | |
ROM::Yesql::Relation.query_proc(query_proc) | |
ROM::Yesql::Relation.load_queries(queries) | |
end | |
end |
OlderNewer