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
class CommentsController | |
def create | |
@comment = Comment.create(params[:comment]) | |
if @comment.previous_comment? | |
reply_to_user = comment.previous_comment.author | |
CommentCreatedWorker.perform_async(@comment.id, reply_to_user.id) | |
end | |
respond_with @comment | |
end | |
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
class CommentsController | |
def create | |
@comment = Comment.create(params[:comment]) | |
CommentCreatedWorker.perform_async(@comment.id) | |
respond_with @comment | |
end | |
end | |
class CommentCreatedWorker | |
include Sidekiq::Worker |
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
class CommentsController | |
def create | |
comment = Comment.new(params[:comment]) | |
@comment = CommentCreator.new(comment).create! | |
respond_with @comment | |
end | |
end | |
class CommentCreator | |
def initialize(comment) |
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
class CommentCreator | |
#... | |
def perform | |
ThreadParticipantsNotifier.new(@comment).notify | |
if comment.previous_comment? | |
in_reply_to_user = comment.previous_comment.author | |
ReplyMailer.notification(in_reply_to_user, comment).deliver | |
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
class CommentCreator | |
#... | |
def perform | |
ThreadParticipantsNotifier.new(@comment).notify | |
CommentReplyNotifier.new(@comment).notify | |
Kissmetrics.record(comment.author, 'Added Comment') | |
end | |
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
git=$(sh /etc/profile; which git) | |
latest_tag=$("$git" describe --tags --always --abbrev=0) | |
version_string="${git_release_version#*v}" # assumes the following tag format: v1.2.3 | |
number_of_commits=$("$git" rev-list <$$$$$$-YOUR DEVELOPMENT BRANCH NAME HERE-$$$$$$> | wc -l | tr -d ' ') | |
target_plist="$TARGET_BUILD_DIR/$INFOPLIST_PATH" | |
dsym_plist="$DWARF_DSYM_FOLDER_PATH/$DWARF_DSYM_FILE_NAME/Contents/Info.plist" | |
for plist in "$target_plist" "$dsym_plist"; do | |
if [ -f "$plist" ]; then | |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $number_of_commits" "$plist" |
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 'sinatra/metal' | |
class SinatraMetal < Sinatra::Base | |
include Sinatra::Metal | |
get '/sinatra' do | |
'hello sinatra!' | |
end | |
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
module EventMachine | |
# A simple iterator for concurrent asynchronous work. | |
# | |
# Unlike ruby's built-in iterators, the end of the current iteration cycle is signaled manually, | |
# instead of happening automatically after the yielded block finishes executing. For example: | |
# | |
# (0..10).each{ |num| } | |
# | |
# becomes: | |
# |
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
namespace :harmony do | |
desc "Munges the data" | |
task :munge => :environment do | |
docs_with_publish = Item.collection.find({'publish' => {'$exists' => true}}).to_a | |
puts "Item count: #{Item.count}" | |
puts "Items with publish key: #{docs_with_publish.size}" | |
docs_with_publish.each do |hash| | |
hash.delete('publish') |
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
# crappy server implementation using technoweenie/oauth2 (server branch) | |
# http://github.com/technoweenie/oauth2/compare/master...server | |
# | |
# ruby oauth2_example.rb -p 4568 | |
# ruby oauth2_example.rb | |
# open http://localhost:4567/auth/facebook | |
require 'rubygems' | |
require 'sinatra' | |
require 'oauth2/client' |
OlderNewer