Different services I can suggest when a non-tech friend or family member asks me how they can cheaply make a website and possibly use it to sell stuff online.
Website Hosting
#!/usr/bin/ruby | |
## JetBlue AYCJ Notifier | |
# So JetBlue doesn't want to tell us exactly when AYCJ-ers can book flights. | |
# This script polls my inbox for any new e-mail from JetBlue and continually | |
# contacts http://www.jetblue.com/aycj and sees if the "come back tomorrow" image is still there. | |
# If anything has changed or an error occurs, use's Mac OS "say" to dictate text and wake me up | |
# so I can book my damn flights. I really wonder how many people are going to stay up tonight hitting the | |
# refresh button every 10 seconds. |
# Don't like for's? | |
# | |
module RubyScribe | |
module Transformers | |
class Eachifier < Transformer | |
def transform(e) | |
if e.is_a?(Sexp) && e.kind == :for | |
transform_for_to_each(e) | |
else | |
super |
# = For to Each Block Transform | |
# Finds instances using "for something in collection"-style of iteration and converts | |
# it to using a standard collection.each block. | |
# | |
# Example: | |
# | |
# for element in collection | |
# do_something(element) | |
# end | |
# |
Different services I can suggest when a non-tech friend or family member asks me how they can cheaply make a website and possibly use it to sell stuff online.
Website Hosting
# MODEL | |
class Theater | |
named_scope :with_recent_comments, | |
:select => "*, recent_comments.created_at AS last_comment_at", | |
:joins => "INNER JOIN (SELECT id, entity_id, created_at FROM comments WHERE entity_type = 'Theater' LIMIT 100) | |
AS recent_comments ON recent_comments.entity_id = theaters.id", | |
:order => "recent_comments.created_at DESC" | |
end |
# MODEL | |
class Theater | |
named_scope :with_recent_comments, | |
:select => "*, recent_comments.created_at AS last_comment_at", | |
:joins => "INNER JOIN (SELECT id, entity_id, created_at FROM comments WHERE entity_type = 'Theater' ORDER by id DESC LIMIT 100) | |
AS recent_comments ON recent_comments.entity_id = theaters.id", | |
:order => "recent_comments.created_at DESC" | |
end |
#!/usr/bin/env ruby | |
MAPPINGS = { | |
"I" => 1, | |
"V" => 5, | |
"X" => 10, | |
"L" => 50, | |
"C" => 100, | |
"D" => 500, | |
"M" => 1000 | |
} |
class Scale < ActiveRecord::Base | |
include KeyContext | |
has_many :tones, :class_name => 'ScaleTone', :extend => ToneSequence, :dependent => :destroy | |
delegate :notes, :to => :tones | |
end |
class City | |
def freezing? | |
case name | |
when "San Diego" | |
current_temperature < 60 | |
when "Austin" | |
current_temperature < 50 | |
when "Rochester" | |
current_temperature < -10 | |
else |
require "capybara/rails" | |
Capybara.javascript_driver = :webkit | |
class StaffToPng | |
@queue = :staff_to_png | |
def self.perform(chord) | |
visit "/chords/#{chord}" | |
page.driver.render "generations/#{chord}.png" |