Skip to content

Instantly share code, notes, and snippets.

View technicalpickles's full-sized avatar

Josh Nichols technicalpickles

View GitHub Profile
%w(debug? info? warn? error? fatal?).map(&:to_sym).each do |level|
define_method level do
non_nil_loggers = @loggers.find_all{|l| l.level}
matching_loggers = non_nil_loggers.map{|l| l.send(level)}
matching_loggers.any?
end
end
class RegenerateRuntimeDependenciesList < ActiveRecord::Migration
def self.up
Dependency.find_each(:batch_size => 500) do |dep|
if dep.version
$redis.del(Dependency.runtime_key(dep.version.full_name))
dep.save
end
end
end
context 'when the claim fails to save' do
let :checkout do
checkout = Checkout::Base.new(:user => user, :offers => {offer.id => 3}, :root_offer_id => offer.id)
Claim.should_receive(:issue).with(offer, checkout, 3).and_return(claim)
claim.should_receive(:save).and_return(false)
checkout
end
it 'should add an error if the claim cannot be saved' do
module God
module Conditions
class RestartFileTouched < PollCondition
attr_accessor :restart_file
def initialize
super
end
def process_start_time
Time.parse(`ps -o lstart -p #{self.watch.pid} --no-heading`)
# match method names like
# logged_id_super_admin_or_admin?
# or
# logged_in_admin_or_lead?
def method_missing(method_name, *args)
if method_name.to_s.match(/^logged_in_(.*)?$/)
roles = $1.split('_or_')
return false unless logged_in? && current_user.company_id == current_company.id
roles.each do |role|
require 'openssl'
require 'base64'
# Extend sString to include encryption and decryption method
#
# For this to work, you must place this in the lib directory of your Rails project.
# You will also need three files in your config directory:
# * public.pem: Your public key file
# * private.pem: Your private key file
# * passphrase.txt: Your passphrase
require 'twiliolib'
require 'rexml/document'
class MessagesController < ApplicationController
TWILIO_API_VERSION = '2008-08-01'
TWILIO_ACCOUNT_SID = 'ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
TWILIO_ACCOUNT_TOKEN = 'xxxxxxxxxxxxxxxxxxxxxxxxxx'
def create

Moonshine, an open source marriage of Capistrano and Puppet, allows you, the developer, to control the deployment process as carefully as you control the development of your application. Deployment, the final link in the food chain can be fraught with errors and missteps. Do you keep a checklist? Have you forgotten one step along the way creating stress on your team or for your client?

Then you need a partner. And Moonshine is that partner.

With Moonshine, you describe your servers using Ruby code, ensuring a consistent Rails deployment environment. Once you have defined your idyllic Rails environment, you can incrementally change your deployment environment from the comforts of your code source. And like the rest of your application, it is versioned.

And remember, it is just Ruby. You can use all of your favorite tricks. Find yourself always using god to monitor your processes? Extract that to a method, put it in a module, include it everywhere! And if you use the same basic setup for all of your applica

~$ ARCHFLAGS='-arch i386 -arch x86_64'
~$ rvm install 1.8.7 --debug --reconfigure -C --enable-shared=yes
~$ wget http://sourceforge.net/projects/rubycocoa/files/RubyCocoa/1.0.0/RubyCocoa-1.0.0.tar.gz/download
~$ tar xzf RubyCocoa-1.0.0.tar.gz && rm RubyCocoa-1.0.0.tar.gz && cd RubyCocoa-1.0.0
~/RubyCocoa-1.0.0$ ruby install.rb config --build-universal=yes
~/RubyCocoa-1.0.0$ ruby install.rb setup
~/RubyCocoa-1.0.0$ sudo ruby install.rb install
# Created by Eric Lindvall <eric@sevenscale.com>
#
# WHAT: Provides a simple overview of memory allocation occuring during a
# require.
#
# For a longer explanation, see my post at:
#
# http://bitmonkey.net/post/308322913/tracking-initial-memory-usage-by-file-in-ruby
#
# NOTE: The numbers provided are of self + children, meaning the same will