Skip to content

Instantly share code, notes, and snippets.

View marclove's full-sized avatar

Marc Love marclove

View GitHub Profile
class CommentsController
def create
comment = Comment.new(params[:comment])
@comment = CommentCreator.new(comment).create!
respond_with @comment
end
end
class CommentCreator
def initialize(comment)
class CommentCreator
#...
def perform
ThreadParticipantsNotifier.new(@comment).notify
CommentReplyNotifier.new(@comment).notify
Kissmetrics.record(comment.author, 'Added Comment')
end
end
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
class CommentsController
def create
comment = Comment.new(params[:comment])
@comment = CommentCreator.new(comment).create!
respond_with @comment
end
end
class CommentCreator
def initialize(comment)
class CommentsController
def create
@comment = Comment.create(params[:comment])
CommentCreatedWorker.perform_async(@comment.id)
respond_with @comment
end
end
class CommentCreatedWorker
include Sidekiq::Worker
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
# Steps to implement:
# 1. Ensure you're using >= coffeescript-1.6.1
#
# 2. Put this file in an initializer.
#
# 3. Edit an environment's config to turn on source maps:
#
# `config.assets.sourcemaps = true`
#
# 4. Add /public/sourcemaps to your .gitignore
@marclove
marclove / gist:4080337
Created November 15, 2012 18:34 — forked from zenkay/gist:3237860
Installation tips for RVM/Ruby on OSX 10.8 Mountain Lion

Ruby, RVM and Mountain Lion

Key problems

Mountain Lion (10.8) has three main difference compared to Lion (10.7):

  • XCode 4.4 does not install Command Line Tools by default
  • X11 isn't available anymore
  • The installed version of OpenSSL has some bugs

How to work around

@marclove
marclove / theme.html
Created May 8, 2012 03:13 — forked from soemarko/theme.html
embed github gist to tumblr
<!-- Add the following lines to theme's html code right before </head> -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script src="http://static.tumblr.com/fpifyru/VCxlv9xwi/writecapture.js"></script>
<script src="http://static.tumblr.com/fpifyru/AKFlv9zdu/embedgist.js"></script>
<!--
Usage: just add <div class="gist">[gist URL]</div>
Example: <div class="gist">https://gist.github.com/1395926</div>
-->