Skip to content

Instantly share code, notes, and snippets.

Avatar

Michael Pearson mipearson

View GitHub Profile
View gist:371872
# this is a DSL example, anonymized from a production usecase, showing
# deployment to an A/B shared server system from multiple sources.
# note that in this example that while there are many servers to restart,
# the code is deployed to a shared drive.
application 'example' do
server_set = environment.example_test_server
cgi_bin_dir = environment.example_dir + '/cgi_bin' + server_set
web_dir = environment.example_dir + '/web'
# remove some paths in the destination
View gist:466267
# in config/environments/production.rb
config.after_initialize do
SshTunnel.establish
end
# in lib/ssh_tunnel.rb
class SshTunnel
@@process_id = nil
COMMAND = "ssh mpearson@redacted.locationB -R 9988:localhost:3000 -N -T -o PasswordAuthentication=no"
View gist:668557
[2010-11-09 11:42:08] ./installer -a /Users/mpearson/.rvm/rubies/ree-1.8.7-2010.02 --dont-install-useful-gems
./configure: line 4633: : command not found
rm: conftest.dSYM: is a directory
rm: conftest.dSYM: is a directory
configure: WARNING: Could not find the PC. Will not output failed addresses...
In file included from src/base/commandlineflags.h:55,
from src/tcmalloc.cc:114:
./src/base/basictypes.h: In constructor ‘AssignAttributeStartEnd::AssignAttributeStartEnd(const char*, char**, char**)’:
./src/base/basictypes.h:251: warning: ‘_dyld_present’ is deprecated (declared at /usr/include/mach-o/dyld.h:237)
./src/base/basictypes.h:251: warning: ‘_dyld_present’ is deprecated (declared at /usr/include/mach-o/dyld.h:237)
View progress_emo_formatter.rb
# See https://github.com/dchelimsky/rspec/wiki/Custom-Formatters for info on how to use custom formatters in rspec 1.x
require 'spec/runner/formatter/progress_bar_formatter'
class ProgressEmoFormatter < Spec::Runner::Formatter::ProgressBarFormatter
@@num_consecutive_failures = 0
FAILURES_BEFORE_EMO = 4
def example_failed(example, counter, failure)
@mipearson
mipearson / gist:794570
Created Jan 25, 2011
Hi to RORO Members
View gist:794570
I am looking for a Senior Ruby Developer with a Java background to
start as soon as possible, you will be working in a paired agile
environment developing Ruby coding. Using Selenium/Cucumber for
automation testing.
Immediate Start
3 Month Contract
Competitive Rate circa $600 per day including Super (PAYG/ABN: PTY
LTD)
@mipearson
mipearson / ci.rb
Created Feb 3, 2011
Chatty hudson blamer
View ci.rb
#!/usr/bin/env ruby
require 'fileutils'
def last_committer
@last_committer ||= `git log --format="%an" -1`.strip
end
INSULTS = %{
%s is a bad programmer and
View lolwut jruby stacktrace
log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: /var/log/puge/puge.log (Permission denied)
at java.io.FileOutputStream.openAppend(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:207)
at java.io.FileOutputStream.<init>(FileOutputStream.java:131)
at org.apache.log4j.FileAppender.setFile(FileAppender.java:290)
at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:164)
at org.apache.log4j.DailyRollingFileAppender.activateOptions(DailyRollingFileAppender.java:216)
at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:257)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:133)
@mipearson
mipearson / cfn_dsl_mockup.rb
Created Feb 28, 2011
Mockup for a DSL to generate Amazon CloudFormation configurations
View cfn_dsl_mockup.rb
# Based on half of https://s3.amazonaws.com/cloudformation-templates-us-east-1/WordPress-1.0.0.template
# Methods beginning with a lowercase letter are 'native' and have special behaviour.
# Methods beginning with an uppercase letter get literally transformed into JSON
templates do
Alarm do
EvaluationPeriods 1
Statistic 'Average'
Period 60
AlarmActions: ref('AlarmTopic')
@mipearson
mipearson / config.rb
Created Mar 15, 2011
.. an example of mocking gone too far.
View config.rb
## configuration_spec.rb
require 'spec_helper'
describe Configuration do
context "with the configuration variable set " do
before do
@config = Configuration.new(:key => 'hello', :value => 'goodbye')
mock(Configuration).find_by_key('hello') { @config }
end
View mongoid dm.rb
class Match
include Mongoid::Document
include Mongoid::Timestamps # adds created_at and updated_at fields
field :scheduled_start, :type => Date
field :status
embeds_one :home_team
embeds_one :away_team
end
You can’t perform that action at this time.