Skip to content

Instantly share code, notes, and snippets.

View JuarezLustosa's full-sized avatar
🏠
Working from home

Juarez Lustosa JuarezLustosa

🏠
Working from home
View GitHub Profile
@JuarezLustosa
JuarezLustosa / gist:292b59e3f36155906f1482e2ec9eaa7d
Created December 6, 2016 19:36
Javascript Desempenho entre typeof e direct
var loops = 1e8,
foo;
console.time('typeof');
while(loops--) {
if( typeof foo !== 'undefined' ) {}
}
console.timeEnd('typeof');
loops = 1e8;
require 'rails_helper'
RSpec.describe TodosController, :type => :controller do
describe "GET #index" do
#describe "POST #create" do
#describe "GET #show" do
#describe "PATCH #update" do (or PUT #update)
#describe "DELETE #destroy" do
#describe "GET #new" do
@justinweiss
justinweiss / filterable.rb
Last active January 11, 2024 07:28
Filterable
# Call scopes directly from your URL params:
#
# @products = Product.filter(params.slice(:status, :location, :starts_with))
module Filterable
extend ActiveSupport::Concern
module ClassMethods
# Call the class methods with names based on the keys in <tt>filtering_params</tt>
# with their associated values. For example, "{ status: 'delayed' }" would call
Capybara.add_selector :record do
xpath { |record| XPath.css("#" + ActionController::RecordIdentifier.dom_id(record)) }
match { |record| record.is_a?(ActiveRecord::Base) }
end