Skip to content

Instantly share code, notes, and snippets.

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"
# 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?"
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
# 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
@activefx
activefx / spec_helper.rb
Created October 10, 2011 20:19
Spec helper for use with guard, spork, rspec, factory girl, devise, capybara, and mongoid
require 'rubygems'
def start_simplecov
require 'simplecov'
SimpleCov.start 'rails' unless ENV["SKIP_COV"]
end
def spork?
defined?(Spork) && Spork.using_spork?
end
@activefx
activefx / gist:3712368
Created September 13, 2012 06:33 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@activefx
activefx / resque.rake
Created January 22, 2013 03:36
resque.rake with error monitoring, resque scheduler and queue clearer
require 'resque/tasks'
require 'resque_scheduler/tasks'
require 'resque/failure/multiple'
require 'resque/failure/redis'
# https://github.com/lantins/resque-exceptional
# Configuration Options
# Required
# api_key - your getexceptional.com api key.
# HTTP Proxy Options (optional)
@activefx
activefx / resque.rb
Created January 22, 2013 03:39
resque initializer
# Require to rescue Resque::TermException errors in the perfrom method
require 'resque/errors'
# Load the servers to enable to web interfaces
require 'resque/server'
require 'resque_scheduler/server'
# Create a global variable to access the Redis DB
$redis = Rails.env == 'test' ? Redis.new : configatron.redis.server
# Tell Resque to use the defined Redis DB
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
scheduler: bundle exec rake resque:scheduler
worker: env TERM_CHILD=1 RESQUE_TERM_TIMEOUT=10 bundle exec rake jobs:work
require 'formula'
class CloogPpl015 < Formula
homepage 'http://repo.or.cz/w/cloog-ppl.git'
url 'http://gcc.cybermirror.org/infrastructure/cloog-ppl-0.15.11.tar.gz'
sha1 '42fa476a79a1d52da41608a946dcb47c70f7e3b9'
keg_only 'Conflicts with cloog in main repository.'
depends_on 'gmp4'