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 FirstParser | |
def self.parse(url) | |
parser = Inner.new(url) | |
parser.parse | |
end | |
class Inner | |
def initialize(url) | |
@url = url | |
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
map $uri $site { | |
~^/about/jobs 0; | |
~^/accounts 0; | |
~^/admin 0; | |
~^/social-media 0; | |
~^/about/press 0; | |
~^/archive 0; | |
~^/in 0; | |
~^/network 0; | |
~^/specials/jackson/slideshow 0; |
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
$('.js-content-form').one | |
submit: (event) -> | |
$(".js-save-btns button").on | |
click: (event) -> event.preventDefault(); |
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 url_with_params(url, params={}) | |
uri = URI.parse(url) | |
query = URI.decode_www_form(uri.query.to_s) | |
params.each { |k, v| query << [k.to_s, v.to_s] } | |
uri.query = URI.encode_www_form(query) | |
uri.to_s | |
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 open_and_close_present_together | |
[:mon, :tue, :wed, :thur, :fri, :sat, :sun].each do |day| | |
if send("#{day}_o").blank? ^ send("#{day}_c").blank? | |
errors.add(day, "must have open and close times") | |
end | |
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
module ContentBase | |
extend self | |
SAFE_CLASSES = [ | |
NewsStory, | |
Article | |
] | |
def safe?(obj) | |
SAFE_CLASSES.include?(obj.class) |
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
No index (lol): | |
0.110000 0.010000 0.120000 ( 45.035484) | |
source: | |
0.170000 0.020000 0.190000 ( 0.205475) | |
0.190000 0.020000 0.210000 ( 0.233402) | |
0.170000 0.010000 0.180000 ( 0.215058) | |
source, published_at: | |
0.170000 0.020000 0.190000 ( 0.213173) |
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 'openssl' | |
require 'open-uri' | |
url = "https://i1.ytimg.com/vi/2K-8FJ114kU/hqdefault.jpg" | |
# Errors | |
response = open(url, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE) | |
tempfile = Tempfile.new('youtube', encoding: "ascii-8bit") | |
tempfile.write response.read |
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
hsh = {} | |
ary = ['02:40', '04:20'] | |
first, last = [ary.first.split(":").map(&:to_i), ary.last.split(":").map(&:to_i)] | |
hsh = { | |
first[0] => (60 - first[1])*60, | |
last[0] => (60-last[1])*60 | |
} |
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
TERM_HANDLERS = [ | |
-> { puts "AAAAAA" }, | |
-> { puts "BBBBBB" } | |
] | |
Signal.trap "TERM" do |s| | |
TERM_HANDLERS.each { |h| h.call } | |
exit | |
end |
OlderNewer