+ R1: A good test suite increases confidence that code changes won't cause
+ unexpected side effects without being noticed.
+ R2: Tests reduce the cost of structural changes in later stages of a project
+ because fewer bugs sneak into a system unnoticed.
- R3: Brittle tests can increase the cost of refactoring if they focus on
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Public: A module to be mixed in another class with common methods to index | |
# records in ElasticSearch. | |
# | |
# The host object needs to respond to 'indexed_attributes', which will return | |
# an array of the attributes names to be indexed. | |
# | |
# It's also recommended to override the 'save?' method to make sure only | |
# records that match some specifications are indexed. | |
# | |
# The type used for the ElasticSearch index will be extracted from the name of |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# But why not just this? | |
# More straightfoward and faster to write... | |
class Job < ActiveRecord::Base | |
def publish | |
update_attribute(:status, "published") | |
JobActivityFeed.create("#{title} has been published", id) | |
JobMailer.info_consultant(id, "consultant@cp.com").deliver | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--colour | |
-I app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'singleton' | |
# outputs a colored call-trace graph to the Rails logger of the lines of ruby code | |
# invoked during a single request. | |
# | |
# Example: | |
# | |
# 1) Make sure this file is loaded in an initializer | |
# | |
# 2) Add the following to your application.rb in Rails3: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Build script for Jenkins. This builds the checked out code and will deploy it if the commit came from | |
# an environment defined by the DeployEnvironment class. | |
# | |
# Scroll down to the bottom of this script to trace how it works. | |
require 'open-uri' | |
class StandardOutLogger | |
# Logs a message to standard out in red | |
# | |
# @param [ String ] msg The message to log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mike@rbci:~$ psql -U postgres | |
psql (9.0.3) | |
Type "help" for help. | |
postgres=# update pg_database set datallowconn = TRUE where datname = 'template0'; | |
UPDATE 1 | |
postgres=# \c template0 | |
You are now connected to database "template0". | |
template0=# update pg_database set datistemplate = FALSE where datname = 'template1'; | |
UPDATE 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Media Queries in Sass 3.2 | |
// | |
// These mixins make media queries a breeze with Sass. | |
// The media queries from mobile up until desktop all | |
// trigger at different points along the way | |
// | |
// And important point to remember is that and width | |
// over the portrait width is considered to be part of the | |
// landscape width. This allows us to capture widths of devices | |
// that might not fit the dimensions exactly. This means the break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RecruitmentPipeline | |
end | |
# Stage is a progression or step on a candidate's job application. | |
# It represents the state the application is in and offers several | |
# statistic on the effectiveness of consultant at this stage. | |
# | |
# For example, Stage 1 might be AppliedStage, or NewStage | |
# depending on whether candidate applied himself or consultant | |
# selected him. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- PostgreSQL 9.2 beta (for the new JSON datatype) | |
-- You can actually use an earlier version and a TEXT type too | |
-- PL/V8 http://code.google.com/p/plv8js/wiki/PLV8 | |
-- JSON Types need to be mapped into corresponding PG types | |
-- | |
-- Number => INT or DOUBLE PRECISION | |
-- String => TEXT |