Skip to content

Instantly share code, notes, and snippets.

View activefx's full-sized avatar

Matt Solt activefx

View GitHub Profile
# Configure Rails to use jQuery by default
# Set up a jquery.rb file in config/initializers and add:
ActionView::Helpers::AssetTagHelper.javascript_expansions.clear
ActionView::Helpers::AssetTagHelper.register_javascript_expansion :defaults => ['jquery', 'jquery-ui', 'rails']
# Alternatively use
# ActionView::Helpers::AssetTagHelper.register_javascript_expansion :jquery => ['jquery', 'jquery-ui', 'rails']
# and then in the head of your application layout
# javascript_include_tag :jquery
class Account
include Mongoid::Document
include Mongoid::Timestamps
field :subdomain, :type => String
embeds_many :users
accepts_nested_attributes_for :users
validates_presence_of :name, :subdomain
validates_uniqueness_of :subdomain, :case_sensitive => false
# download, from_repo, and commit_state methods swiped from
# http://github.com/Sutto/rails-template/blob/07b044072f3fb0b40aea27b713ca61515250f5ec/rails_template.rb
require 'open-uri'
def download(from, to = from.split("/").last)
#run "curl -s -L #{from} > #{to}"
file to, open(from).read
rescue
puts "Can't get #{from} - Internet down?"
require 'feedzirra'
# fetching a single feed
feed = Feedzirra::Feed.fetch_and_parse("http://feeds.feedburner.com/PaulDixExplainsNothing")
# feed and entries accessors
feed.title # => "Paul Dix Explains Nothing"
feed.url # => "http://www.pauldix.net"
feed.feed_url # => "http://feeds.feedburner.com/PaulDixExplainsNothing"
feed.etag # => "GunxqnEP4NeYhrqq9TyVKTuDnh0"