Skip to content

Instantly share code, notes, and snippets.

View ZempTime's full-sized avatar

Chris Zempel ZempTime

View GitHub Profile
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
@ZempTime
ZempTime / gist:0b5995e8ec30f69738de
Last active August 29, 2015 14:20
SummaryGenerator for RebootU
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
RSpec.describe Game do
it 'accepts an initial seed pattern' do
seed = [
[1, 1],
[1, 1]
]
@game = Game.new(seed)
@ZempTime
ZempTime / refile_patch.rb
Last active August 29, 2015 14:13
Refile Attachment Disposition
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
@ZempTime
ZempTime / gist:859706f2b63d6e1fecba
Last active August 29, 2015 14:13
Check for video, audio, picture content
$(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"))
require 'byebug'
lambda {
setups = []
events = {}
Kernel.send :define_method, :event do |name, &block|
events[name] = block
end