Skip to content

Instantly share code, notes, and snippets.

View jeffrafter's full-sized avatar
You are amazing

Jeff Rafter (he/him) jeffrafter

You are amazing
View GitHub Profile
#
# .autotest
# Autotest Growl Notifications for Rspec and Test::Unit
#
# Created by Rein Henrichs on 2007-09-12.
# Copyright 2007 Rein Henrichs.
# http://pastie.caboo.se/96573/download
#
require 'logger'
SELECT r.patient_id, arv_number.identifier as 'arv_number', nat_id.identifier as 'nat_id', patient.gender, s.age_at_initiation, patient.birthdate, n.given_name, n.family_name
FROM patient_registration_dates AS r
INNER JOIN patient ON r.patient_id = patient.patient_id
LEFT JOIN patient_start_dates AS s ON r.patient_id = s.patient_id
LEFT JOIN patient_identifier AS arv_number ON arv_number.identifier_type = 18 AND arv_number.patient_id = r.patient_id AND arv_number.voided = 0
LEFT JOIN patient_identifier AS nat_id ON nat_id.identifier_type = 1 AND nat_id.patient_id = r.patient_id AND arv_number.voided = 0
LEFT JOIN patient_name AS n ON n.patient_id = r.patient_id AND n.voided = 0
GROUP BY r.patient_id
ORDER BY CONVERT(RIGHT(arv_number.identifier, LENGTH(arv_number.identifier)-3), UNSIGNED)
#!/usr/bin/ruby
require 'fastercsv'
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
def set_patient_esitmated_age(patient, age, date_of_registration)
age = age.to_i
patient_estimated_birthyear = date_of_registration.year - age
patient_estimated_birthmonth = 7
patient_estimated_birthday = 1
patient.birthdate = Date.new(patient_estimated_birthyear, patient_estimated_birthmonth, patient_estimated_birthday)
Scenario: When logging in as a valid user # features/authentication.feature:16
Given I visit the login page # features/step_definitions/authentication_steps.rb:10
And a user with the login "Ninjas" and the password "zombies" exists # features/step_definitions/authentication_steps.rb:1
When I fill in "login" with "Ninjas" # features/step_definitions/webrat_steps.rb:14
And I fill in "password" with "zombies" # features/step_definitions/webrat_steps.rb:14
And I press "Log me in" # features/step_definitions/webrat_steps.rb:6
invalid hash (BCrypt::Errors::InvalidHash)
/opt/local/lib/ruby/gems/1.8/gems/bcrypt-ruby-2.0.3/lib/bcrypt.rb:136:in `initialize'
/private/var/www/relay/app/behaviours/user/authentication.rb:40:in `new'
/private/var/www/relay/app/behaviours/user/authentication.r
def should_raise(options = {}, &block)
yield block
flunk options[:message] || "should raise an exception, but none raised"
rescue Exception => e
assert e.kind_of?(options[:kind_of]), options[:message] || "should raise exception of type #{options[:kind_of]}, but got #{e.class} instead" if options[:kind_of]
end
#!/usr/bin/env ruby
$path = nil
$name = nil
$window = nil
$total_idle = 0
$curr_idle = 0
$start = nil
$interval = 2
(17:33:1229131989) /Macintosh HD/Developer/Applications/Xcode.app/ (Xcode) process.rb
Total process time: 2.517889
Total activity: 27
Total idle: 73
(17:33:1229131991) /Macintosh HD/Applications/Utilities/Terminal.app/ (Terminal) Terminal — script — 140×40
Total process time: 7.617722
Total activity: 14
Total idle: 86
arr = []
t = @start_time
while (t < @end_time)
arr << [t, t.next_interval]
t = t.next_interval
end
## Time ext
class Time
arr = []
t = @start_time
while (t < @end_time)
arr << [t, t.next_interval]
t = t.next_interval
end
## Time ext
class Time
@jeffrafter
jeffrafter / env.rb
Created January 23, 2009 19:12
Using cucumber, shoulda and factory_girl to check logging in and signing up against clearance
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
require 'shoulda'
require 'webrat'
require 'factory_girl'
require 'test/factories/clearance'
require 'clearance/../../shoulda_macros/clearance'
require 'cucumber/rails/world'
Cucumber::Rails.use_transactional_fixtures