Skip to content

Instantly share code, notes, and snippets.

desc "pings my domain every x mimnutes"
task :pings do
require 'net/http'
require 'uri'
Net::HTTP.get URI("http://mikesilvis.com")
end
@MikeSilvis
MikeSilvis / gist:3090737
Created July 11, 2012 14:31 — forked from chrismanderson/gist:3090735
Titleize.coffee
String::titleize = ->
titleized = this.split(" ")
UNCAPITALIZED = ['a', 'an']
titleized = (
for word, index in titleized
if word and word.toUpperCase
if word in UNCAPITALIZED && index != 0
word
else
class YamlParser
require 'yaml'
def initialize(file)
YamlParser.access_methods(YAML.load(file))
end
def self.access_methods(data)
data.each do |key, value|
YamlParser.define_method_for_key(key,value)
@MikeSilvis
MikeSilvis / gist:3612175
Created September 3, 2012 18:49
Sublime setup
{
"color_scheme": "Packages/Made of Code.tmTheme",
"font_face": "Monaco",
"font_size": 16.0,
"tab_size": 2,
"translate_tabs_to_spaces": true
}
class PhotoSerializer < ActiveModel::Serializer
attributes :id, :created_at, :photo_url_thumb, :photo_url_large
# Only include these if it is coming from the show action
has_many :likes
has_many :tags
has_many :comments
end
def hello_world
puts "chris maddox lies"
end
if defined? @hello
@hello
else
@hello = "world"
end
@hello ||= "world"
@hello = false
@hello ||= "world"
puts @hello
> "world"
@hello = false
if defined? @hello
@hello
else
"world"
@MikeSilvis
MikeSilvis / hot.rb
Created October 15, 2012 18:36
hot or not
def class_for_cities_deal(deal, opts = {})
@deal_classes ||= {}
@hot_count ||= 0
@shared_count ||= 0
collection_size = opts.fetch(:collection_size){ 10 }
return @deal_classes[deal.id] if @deal_classes.keys.include?(deal.id)
deal_class = case
# when deal_in_campaign_and_banner_title?(deal) then "deal_campaign"
# when deal.sold_out? then 'sold_out'
# when deal.id==top_deal.try(:id) then 'featured_deal'