Skip to content

Instantly share code, notes, and snippets.

require 'rubygems'
require 'tlsmail'
RAILS_ROOT = "/Users/reggie/src/new_altomic/altomic"
FETCHER_SCRIPT = "RAILS_ENV=production #{RAILS_ROOT}/script/mailer_daemon_fetcher"
Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
# mail settings
God::Contacts::Email.message_settings = {
buba:new_altomic reggie$ god -c monitor_mail_deamon.god -D
I [2009-04-06 22:24:44] INFO: Using pid file directory: /Users/reggie/.god/pids
I [2009-04-06 22:24:44] INFO: Started on drbunix:///tmp/god.17165.sock
I [2009-04-06 22:24:44] INFO: fetcher-daemon move 'unmonitored' to 'init'
I [2009-04-06 22:24:44] INFO: fetcher-daemon moved 'unmonitored' to 'init'
I [2009-04-06 22:24:44] INFO: fetcher-daemon [trigger] process is not running (ProcessRunning)
I [2009-04-06 22:24:44] INFO: fetcher-daemon move 'init' to 'start'
I [2009-04-06 22:24:44] INFO: fetcher-daemon before_start: no pid file to delete (CleanPidFile)
I [2009-04-06 22:24:44] INFO: fetcher-daemon start: RAILS_ENV=production /Users/reggie/src/new_altomic/altomic/script/mailer_daemon_fetcher start
W [2009-04-06 22:24:44] WARN: fetcher-daemon start command exited with non-zero code = 1
@andreareginato
andreareginato / hash_style.rb
Created July 20, 2012 10:55
Hash guidestyle
# I'm trying to search the 'cleanest' solution to create an hash.
# The different guidestyles I've found around does not satisfy me at all.
# Tell me which ones you like between those options
# solution 1 (favorite at the moment)
let!(:params) do
{ response_type: 'code',
client_id: application.id.to_s,
redirect_uri: application.redirect_uri,
@andreareginato
andreareginato / spec_helper.rb
Created October 2, 2012 16:48
Rails Spec Helper (using Spork, Mongoid, Factory Girls, Draper, Webmock and Capybara)
require 'rubygems'
require 'spork'
# This code runs once when you run your test suite
Spork.prefork do
ENV['RAILS_ENV'] ||= 'test'
# Mongoid models reload
require 'rails/mongoid'
Spork.trap_class_method(Rails::Mongoid, :load_models)
@andreareginato
andreareginato / Guardfile
Created October 2, 2012 16:49
Rails Guardfile (handle Spork and RSpec automatic tests)
guard 'spork', :rspec_env => { 'RAILS_ENV' => 'test' } do
watch('config/application.rb')
watch('config/environment.rb')
watch(%r{^config/environments/.+\.rb$})
watch(%r{^config/initializers/.+\.rb$})
watch(%r{^config/locales/.+\.yml$})
watch('Gemfile')
watch('Gemfile.lock')
watch('spec/spec_helper.rb')
end
@andreareginato
andreareginato / events.js
Created October 31, 2012 11:32
mongodb native driver for node.js patch to work with capped collections
// -------------------------------------------------
// MongoDB extension to get back the new records
// added to a capped collection. This code will not
// be used if mongoose is found out to be reliable
//
// var events = require('./lib/events');
//
// events.connect(function(collection) {
// events.execute(collection);
// });
@andreareginato
andreareginato / cacheable.rb
Created November 29, 2012 14:42
Searchable cache key
def self.cache_key
Digest::MD5.hexdigest "#{scoped.max(:updated_at).to_i}-#{scoped.min(:updated_at)}-#{scoped.count}"
end
@andreareginato
andreareginato / device_properties_spec.rb
Created December 11, 2012 14:24
Lelylan automatic pending status definition.
describe 'when updates a property' do
let(:resource) { FactoryGirl.create :device }
let(:property_id) { resource.properties.first.id }
describe 'when :pending was false' do
before { resource.update_attributes(properties_attributes: [{ id: property_id, pending: false }]) }
describe 'when updates :value' do
@andreareginato
andreareginato / oauth2.js
Created January 26, 2013 16:29
OAuth2 app with a Node.js library
/**
*
* OAuth usage example.
*
**/
var http = require("http");
var Url = require("url");
var querystring = require("querystring");
2013-02-07T21:46:13+00:00 heroku[nginx]:
23.23.21.5 - - [07/Feb/2013:21:46:13 +0000]
"OPTIONS /devices/50c61ff1d033a9b610000001
HTTP/1.1" 411 576 "http://localhost:8000/app/index.html"
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8)
AppleWebKit/537.17 (KHTML, like Gecko)
Chrome/24.0.1312.57 Safari/537.17" devices.lelylan.com