Skip to content

Instantly share code, notes, and snippets.

View gusridd's full-sized avatar

Gustavo Soto Ridd gusridd

View GitHub Profile
@gusridd
gusridd / filterable.rb
Created April 11, 2016 03:24 — forked from justinweiss/filterable.rb
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 the same name as the keys in <tt>filtering_params</tt>
# with their associated values. Most useful for calling named scopes from
@gusridd
gusridd / nicolasCage.js
Last active January 27, 2016 21:23
Change current web page images by photos of Nicolas Cage
// Get all images
var images = document.getElementsByTagName('img');
for (var i in images){
var img = images[i];
var height = img.height;
var width = img.width;
var url = "https://www.placecage.com/c/" + width + "/" + height;
// Replace an image src by the corresponding placecage url
img.setAttribute('src', url);
}