Skip to content

Instantly share code, notes, and snippets.

class FirstParser
def self.parse(url)
parser = Inner.new(url)
parser.parse
end
class Inner
def initialize(url)
@url = url
end
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;
$('.js-content-form').one
submit: (event) ->
$(".js-save-btns button").on
click: (event) -> event.preventDefault();
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
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
module ContentBase
extend self
SAFE_CLASSES = [
NewsStory,
Article
]
def safe?(obj)
SAFE_CLASSES.include?(obj.class)
@bricker
bricker / bm
Last active August 29, 2015 13:56
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)
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
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
}
TERM_HANDLERS = [
-> { puts "AAAAAA" },
-> { puts "BBBBBB" }
]
Signal.trap "TERM" do |s|
TERM_HANDLERS.each { |h| h.call }
exit
end