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
def process_flags(flags) | |
primes = [] | |
flags.each_with_index do |value, index| | |
primes << index if value | |
end | |
primes | |
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
def header(max) | |
flags = [true] * (max + 1) | |
flags[0] = flags[1] = false | |
prime = 2 | |
while prime <= Math.sqrt(max) | |
cross_off(flags, prime) | |
prime = next_prime(flags, prime) | |
end | |
process_flags(flags) | |
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 Matrix | |
attr_accessor :rows_header, :columns_header, :table | |
def initialize(args) | |
rows = header(args[:rows]) | |
columns = header(args[:columns]) | |
@table = load_table(rows, columns) | |
@rows_header = rows | |
@columns_header = columns | |
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 Prime | |
class << self | |
def prime?(number) | |
return false if number < 2 | |
sqrt = Math.sqrt(number).to_i | |
(2..sqrt).each do |i| | |
return false if (number % i).zero? | |
end | |
true | |
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 Matrix | |
attr_accessor :rows_header, :columns_header, :table | |
def initialize(args) | |
rows = header(args[:rows]) | |
columns = header(args[:columns]) | |
@table = load_table(rows, columns) | |
@rows_header = rows | |
@columns_header = columns | |
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 Prime | |
class << self | |
def prime?(number) | |
return false if number < 2 | |
(2...number).each do |i| | |
return false if (number % i).zero? | |
end | |
true | |
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
#!/usr/bin/env ruby | |
require 'optparse' | |
require 'methadone' | |
require 'primes_table.rb' | |
class App | |
include Methadone::Main | |
include Methadone::CLILogging |
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
namespace :fetch_github do | |
desc 'Get github content for static pages' | |
task :content_for_static_pages => :environment do | |
GithubStaticPagesJob.run | |
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
<div id="static_page_body"><%= clean_html(@page.body) %></div> |
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
def show | |
return false if redirect_email_blunder | |
@page = StaticPage.friendly.find(get_page_id(params[:id])) | |
@ancestry = @page.self_and_ancestors.map(&:title).reverse | |
end |