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
n = 100 | |
primes = (1..n).map{ |i| i if (2..i-1).map{ |j| j if i%j == 0}.compact.count == 0}.compact | |
puts primes.inspect # => [1, 2, 3, 5, 7, ..., 97] |
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
n = 100000 | |
primes = (0..n).select{ |i| i if (2..i-1).select{ |j| j if i%j == 0}.count == 0} | |
puts primes.inspect # => [1, 2, 3, 5, 7, ..., 9973] |
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 PaginatingDecorator < Draper::CollectionDecorator | |
delegate :current_page, :total_pages, :limit_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
class AnimalsController < ApplicationController | |
inherit_resources | |
.. | |
protected | |
def build_resource_params | |
animal_params = params.fetch(:animal, {}).permit(:name, :age, :family) | |
[prepare_animal_params(animal_params)] |
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 'yaml' | |
def excluded_dir?(filename) | |
filename == "." || filename == ".." | |
end | |
%w(javascript ruby).each do |lang| | |
puts "Renaming #{lang} snapshots..." | |
Dir.foreach(lang+"/") do |subfolder| |
OlderNewer