This file contains hidden or 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 Summarizer | |
def self.call(raw_text, percentage = 25) | |
@@text = raw_text | |
arrayify.sort_by_length.get_middle_percent(percentage).glean_important_sentences.make_pretty | |
@@text | |
end | |
def self.arrayify |
This file contains hidden or 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 SummaryGenerator | |
def self.summarize(raw_text) | |
sentences = raw_text.gsub(/\s+/, ' ').strip.split(/\.|\?|!/) | |
sentences_sorted = sentences.sort_by { |sentence| sentence.length } | |
one_third = sentences_sorted.length / 3 | |
middle_third = sentences_sorted.slice(one_third, one_third + 1) | |
ideal_sentences = sentences_sorted.select { |sentence| sentence =~ /is|are/ } | |
ideal_sentences.join(".") | |
end |
This file contains hidden or 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
RSpec.describe Game do | |
it 'accepts an initial seed pattern' do | |
seed = [ | |
[1, 1], | |
[1, 1] | |
] | |
@game = Game.new(seed) |
This file contains hidden or 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 Refile | |
class << self | |
def attachment_url(object, name, *args, prefix: nil, filename: nil, format: nil, host: nil, disposition: nil) | |
attacher = object.send(:"#{name}_attacher") | |
file = attacher.get | |
return unless file | |
host ||= Refile.host | |
prefix ||= Refile.mount_point | |
filename ||= attacher.basename || name.to_s |
This file contains hidden or 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
$(document).ready -> | |
$("#post_content").keyup -> | |
urls = findUrls($("#post_content").text()) | |
youtube_pattern = ///http://(?:www\.)?youtu(?:be\.com/watch\?v=|\.be/)(\w*)(&(amp;)?[\w\?=]*)?/// | |
flickr_pattern = ///flickr.com\/photos/// | |
soundcloud_pattern = ///w.soundcloud.com/// | |
check_for_assets(youtube_pattern, urls, $("#post_has_video")) | |
check_for_assets(flickr_pattern, urls, $("#post_has_picture")) | |
check_for_assets(soundcloud_pattern, urls, $("#post_has_audio")) |
This file contains hidden or 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 'byebug' | |
lambda { | |
setups = [] | |
events = {} | |
Kernel.send :define_method, :event do |name, &block| | |
events[name] = block | |
end |
NewerOlder