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
| map = <<EOF | |
| function() { | |
| this.tags.forEach(function(z) {emit(z,{count:1});}); | |
| } | |
| EOF | |
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
| # with EOF put at first character position | |
| map = <<EOF | |
| function() { | |
| this.tags.forEach(function(z) {emit(z,{count:1});}); | |
| } | |
| EOF |
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
| # with EOF indented, using <<- | |
| map = <<-EOF | |
| function() { | |
| this.tags.forEach(function(z) {emit(z,{count:1});}); | |
| } | |
| EOF |
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
| puts 'Empty the MongoDB database, exclude System stuff' | |
| Mongoid.master.collections.select do |collection| | |
| include = collection.name !~ /system/ | |
| puts 'Dropping ' + collection.name if include | |
| include | |
| end.each(&:drop) |
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
| class UserAccountsController < ApplicationController | |
| def signin | |
| auth = request.env['rack.auth'] | |
| user_for_provider_and_uid = UserAccount.find_by_provider_and_uid(auth['provider'], auth['uid']).first() | |
| new_auth = Authorization.new(:user_id => auth['user_id'], :provider => auth['provider'], :uid => auth['uid'], :user_info => auth['user_info'], :credentials => auth['credentials']) | |
| if user_for_provider_and_uid.nil? | |
| user = signed_in? ? self.current_user : UserAccount.new(:name => auth['user_info']['name']) | |
| user.authorizations << new_auth |
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
| source 'http://rubygems.org' | |
| gem 'rails', '3.0.0' | |
| gem "mongoid", "2.0.0.beta.17" | |
| gem "bson_ext", "1.0.4" | |
| gem 'omniauth' | |
| $heroku = ENV['USER'] ? !! ENV['USER'].match(/^repo\d+/) : ENV.any?{|key, _| key.match(/^HEROKU_/)} | |
| unless $heroku |
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
| public class ControllerFactory : IControllerFactory | |
| { | |
| readonly IWindsorContainer container; | |
| public ControllerFactory() : this(((IContainerAccessor) HttpContext.Current.ApplicationInstance).Container) | |
| { | |
| } | |
| public ControllerFactory(IWindsorContainer container) | |
| { |
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
| @posts.paginate(:page => params[:page], | |
| :per_page => 20, | |
| :sort => [['added', :asc]]) |
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
| match 'post/by_tag/:tag', | |
| :to => 'posts#by_tag', | |
| :as => 'posts_by_tag', | |
| :tag => /[A-Za-z0-9\-_\.]*/ |
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
| if last_vote_date.nil? || last_vote_date.utc < 1.day.ago | |
| self.last_vote_date = Time.now | |
| self.votes_per_day = 1 | |
| else | |
| self.votes_per_day += 1 | |
| end | |
| if self.votes_per_day <= 10 | |
| self.reputation += 1 | |
| end |
OlderNewer