This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1) Put 's3' gem in Gemfile. | |
# 2) Create as3.yml configuration for S3 | |
# 3) Create initializer for as3.yml | |
# 4) Make "assets" folder inside your bucket | |
# 5) After running task run "RAILS_ENV=production rake assets:precompile" | |
# 6) Invoke task by running "rake as3:upload" | |
namespace :as3 do | |
desc "Uploads compiled assets (public/assets) to Amazone AS3" | |
task :upload do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scope :ordered_by_article_count, | |
select("users.*, c.count as article_count"). | |
joins("LEFT JOIN (SELECT user_id, COUNT(user_id) as count | |
FROM articles WHERE state = 'active' GROUP BY user_id) as c ON c.user_id = users.id"). | |
where("c.count IS NOT NULL"). | |
order("c.count DESC") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Gemfile | |
… | |
gem 'uuidtools' | |
… |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query = BSON::OrderedHash.new.tap do |query| | |
query["geoNear"]="locations" | |
query["near"] = lon_lat | |
end | |
lon,lat =lon_lat | |
query = Location.collection.db.command(query)['results'].sort_by do |r| | |
r['distance'] = Haversine.distance(lat,lon,r['obj']['lon_lat'][1],r['obj']['lon_lat'][0]) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'nokogiri' | |
class World | |
attr_reader :continents | |
def initialize(world_xml="cia-1996.xml") | |
@continents = [] | |
if File.exists?(world_xml) | |
@noko = Nokogiri::XML(File.open world_xml ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'eventmachine' | |
require 'feedzirra' | |
require 'restclient' | |
feeds_url = [ "http://stackoverflow.com/feeds/tag/ruby-on-rails", | |
"http://stackoverflow.com/feeds/tag/ruby", | |
"http://stackoverflow.com/feeds/tag/git", | |
"http://stackoverflow.com/feeds/tag/mongodb", | |
"http://stackoverflow.com/feeds/tag/nginx", |
NewerOlder