View gist:2399749
module Mustache | |
class << self | |
import com.github.mustachejava.DefaultMustacheFactory | |
import com.github.mustachejava.jruby.JRubyObjectHandler | |
def template_dir | |
Rails.root.join('app', 'templates') | |
end | |
def factory |
View benchmark.rb
require 'faker' | |
require 'factory_girl' | |
require 'test/factories' | |
require 'message' | |
Message.collection.drop | |
Message.create_indexes | |
Contact.collection.drop | |
Contact.create_indexes |
View rescue-messages.rb
start_time = Time.utc(2011, 07, 04, 12, 18) | |
mps = MessagePart.where(:timestamp.gt => start_time).collect do |mp| | |
account_msisdn = Subscriber.find(mp.subscriber_id).account.msisdn | |
attributes = mp.attributes.slice("content", "total_parts", "message_id", "part", "contact_msisdn", "sent") | |
%{ | |
MessagePart.create!(#{attributes.inspect}.merge( | |
:subscriber_id => Account.find_by_msisdn(#{account_msisdn.inspect}).subscriber.id, | |
:timestamp => Time.parse(#{mp.timestamp.to_s.inspect}) | |
)) |
View gist:1054999
if [[ -a Gemfile ]]; then | |
bundle exec rake $* | |
else | |
command rake $* | |
fi |
View event.rb
class Event < Node | |
end |
View instrumentation.rb
module Mongo | |
module Instrumentation | |
def self.instrument(clazz, *methods) | |
clazz.module_eval do | |
methods.each do |m| | |
class_eval %{def #{m}_with_instrumentation(*args, &block) | |
ActiveSupport::Notifications.instrumenter.instrument "mongo.mongo", :name => "#{m}" do | |
#{m}_without_instrumentation(*args, &block) | |
end | |
end |
View Hacked mongo instrumentation
module Mongoid | |
class LogSubscriber < ActiveSupport::LogSubscriber | |
def self.runtime=(value) | |
Thread.current["mongoid_mongo_runtime"] = value | |
end | |
def self.runtime | |
Thread.current["mongoid_mongo_runtime"] ||= 0 | |
end |
View gist:789707
context "when logged in" do | |
setup do | |
@account = Factory(:provisioned_account) | |
sign_in @account | |
end | |
context "GET index" do | |
setup do | |
@messages = 5.times.map { message(:subscriber => @account.subscriber, :favourite => true) } | |
end |
View user_helper.rb
module UserHelper | |
attr_accessor :current_user | |
class Credentials < Struct.new(:email, :password) | |
def self.parse(arg) | |
return arg if arg.is_a?(Credentials) | |
new(arg) | |
end | |
def initialize(credentials) |
View gist:601402
Hi Sean, | |
It's been more than 7 years since I last looked for a Java job. I'm not interested any positions you have now, and won't be at any time in the future. I've moved on. | |
When I get these emails from you, it's a painful reminder of the life I once led; a life I am trying to forget. Please please please remove me from your mailing list. |
NewerOlder