Skip to content

Instantly share code, notes, and snippets.

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
require 'faker'
require 'factory_girl'
require 'test/factories'
require 'message'
Message.collection.drop
Message.create_indexes
Contact.collection.drop
Contact.create_indexes
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})
))
if [[ -a Gemfile ]]; then
bundle exec rake $*
else
command rake $*
fi
class Event < Node
end
@tomafro
tomafro / instrumentation.rb
Created February 18, 2011 09:13
Experimental Mongo Instrumentation for Rails 3
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
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
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
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)
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.