Rehearsal -----------------------------------------
splat 0.390000 0.000000 0.390000 ( 0.386936)
index 0.770000 0.000000 0.770000 ( 0.775964)
-------------------------------- total: 1.160000sec
user system total real
splat 0.410000 0.000000 0.410000 ( 0.407737)
index 0.750000 0.000000 0.750000 ( 0.751499)
This file contains hidden or 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
#!/bin/bash | |
# This method of running tests in a Rails environment | |
# does not prepare the database first. As a benefit, the | |
# entire test run is much faster; the obvious drawback | |
# is that the test database could be out-of-sync. | |
# | |
# In order to get your test database in sync, you can pass | |
# the -m flag. | |
# |
This file contains hidden or 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
# gratuitously lifted from Vito Botta at http://vitobotta.com/sinatra-contact-form-jekyll/ | |
require 'resolv' | |
def valid_email?(email) | |
if email =~ /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/ | |
domain = email.match(/\@(.+)/)[1] | |
Resolv::DNS.open do |dns| | |
@mx = dns.getresources(domain, Resolv::DNS::Resource::IN::MX) | |
end |
This file contains hidden or 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
add_person = ->(person) { | |
return [nil,"Name is required"] if String(person.(:name)) == '' | |
return [nil,"Birthdate is required"] if String(person.(:birthdate)) == '' | |
return [nil,"Gender is required"] if String(person.(:gender)) == '' | |
return [nil,"Gender must be 'male' or 'female'"] if person.(:gender) != 'male' && | |
person.(:gender) != 'female' | |
id = insert_person.(person.(:name),person.(:birthdate),person.(:gender),person.(:title)) | |
# [new_person.(:with_id,id),nil] # <==== | |
[person.(:with_id,id),nil] # <==== I think it should be this. Right? |
This file contains hidden or 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
#!/bin/bash | |
################################################################# | |
# # | |
# I don't typically use this on an entire Rails log file, # | |
# I usually copy out portions of the log that I am interested # | |
# in and then run it through this script. While this script # | |
# will work on the bare Rails log I don't recommend it, since # | |
# the Rails log includes color formatting information and can # | |
# be quite large. # |
This file contains hidden or 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
#!/bin/bash | |
SOURCE="${BASH_SOURCE[0]}" | |
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done | |
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | |
MONGO="${MONGO:-/usr/local/bin/mongo}" | |
MONGO_USER='<mongo username>' | |
MONGO_PWD='<mongo password>' | |
MONGO_URL="<database server>:<port>/<database name>" |
This file contains hidden or 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 ActiveSupport::TestCase | |
# ... | |
class << self | |
def startup | |
DatabaseCleaner.clean | |
end | |
def shutdown | |
DatabaseCleaner.clean |
This file contains hidden or 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
#!/bin/bash | |
# get the actual directory for this script, resolving links and relative paths | |
SOURCE="${BASH_SOURCE[0]}" | |
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done | |
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | |
ARCH="${ARCH:-x86_64}" | |
RELEASE="${RELEASE:-`date +%Y_%m_%d_%H%M`}" |
This file contains hidden or 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
[global_config] | |
enabled_plugins = CustomCommandsMenu, InactivityWatch, TestPlugin, ActivityWatch, TerminalShot, LaunchpadCodeURLHandler, APTURLHandler, MavenPluginURLHandler, LaunchpadBugURLHandler, LayoutManager | |
title_transmit_bg_color = "#832527" | |
[keybindings] | |
[profiles] | |
[[default]] | |
scrollback_lines = 4000 | |
[layouts] | |
[[default]] | |
[[[child1]]] |
This file contains hidden or 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
module Annotations | |
def override | |
@check_method = true | |
end | |
def singleton_method_added method_name | |
if @check_method | |
clazz = self.ancestors.reject{|e| e == self}.first | |
unless clazz.methods.include? method_name | |
raise "None of #{self}'s ancestors defines ##{method_name}" |