This file contains hidden or 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
module MongoidUtils | |
# Utility module to include in Mogoid documents | |
module Document | |
extend ActiveSupport::Concern | |
module ClassMethods | |
# Do a map/reduce operation on the document's collection and return the results as one big | |
# hash. If a block is given, it is yielded with key and value for every result instead | |
# (this comes in handy if you expect large results) |
This file contains hidden or 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
# Using rails-3.0.0.beta4, mongoid-2.0.0.beta7, mongodb-1.4.4: | |
Article.where(:published_at.gte => Time.utc(2010,7,7)).to_a | |
# => [] | |
Article.where(:published_at.lte => Time.utc(2010,7,7,23,59,59)).to_a | |
# => [#<Article _id: 4c2a75f5468ee3c930000009, created_at: 2010-06-29 22:38:45 UTC, updated_at: 2010-07-07 13:20:00 UTC, published_at: 2010-07-06 23:45:00 UTC, title: "Foo", slug: "foo", text: "Foo", tags: [], views: 0, site_id: BSON::ObjectID('4c2a73f0468ee3c930000006'), author_id: BSON::ObjectID('4c2a75d6468ee3ca6b000001')>] | |
Article.where(:published_at.gte => Time.utc(2010,7,7)).where(:published_at.lte => Time.utc(2010,7,7,23,59,59)).to_a | |
# => [#<Article _id: 4c2a75f5468ee3c930000009, created_at: 2010-06-29 22:38:45 UTC, updated_at: 2010-07-07 13:20:00 UTC, published_at: 2010-07-06 23:45:00 UTC, title: "Foo", slug: "foo", text: "Foo", tags: [], views: 0, site_id: BSON::ObjectID('4c2a73f0468ee3c930000006'), author_id: BSON::ObjectID('4c2a75d6468ee3ca6b000001')>] |
This file contains hidden or 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
From 1d3f5e1c64f96ceede990ad6bdc07ea6f8f925ce Mon Sep 17 00:00:00 2001 | |
From: Andreas Neuhaus <[email protected]> | |
Date: Sat, 19 Jun 2010 15:21:28 +0200 | |
Subject: [PATCH] Workaround for unicorn not being able to fchown unlinked files in Ruby 1.9.2-preview3 (which makes it unable to switch workers to a different user; Ruby bug #3451) | |
--- | |
lib/unicorn.rb | 6 ++++-- | |
lib/unicorn/util.rb | 3 ++- | |
2 files changed, 6 insertions(+), 3 deletions(-) |
This file contains hidden or 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 'active_support' | |
["a","b","a"].sort.join.scan(/a+|b+|c+/).sort_by(&:length).reverse.map(&:first) |
NewerOlder