Skip to content

Instantly share code, notes, and snippets.

Avatar

Jacqui Lough jacqui

View GitHub Profile
View dont make me use this
Ren: [afflicted with Space Madness and holding a bar of soap he's been chewing] Oh, no! I know what you want! You coveteth my ice cream bar!
Stimpy: Easy now...
Ren: [shouts] No you don't! You can't take it from me now!
[starts to cry]
Ren: I've had this ice cream bar since I was a child. People... always trying to take it from me... why... won't they leave me... *alone*!
[grabs a toothbrush]
Ren: [shouts] Don't make me use this! One step closer, I'm warning you! Don't make me use it!
[Stimpy takes one more step]
Ren: Now you've done it! You forced me to use it!
[Brushes his teeth]
View heh... ok.
[15:40] [jm@tinsel:~/test] $ ls *
clone.git:
zutalors.rb
fauxgit:
zutalors.rb
View gist:20436
jm:~/se/app/se (master)$ rake db:test:purge
(in /Users/jm/se/app/se)
jm:~/se/app/se (master)$ rake db:test:clone_structure
(in /Users/jm/se/app/se)
jm:~/se/app/se (master)$ !ruby
ruby spec/models/user_notify_spec.rb
.......
Finished in 0.299443 seconds
View gist:27092
[app@server se]$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.0
- RUBY VERSION: 1.8.6 (2007-09-24 patchlevel 111) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /usr/local/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
View gist:31186
the end of the strace started by the following command, then hitting the server:
$ strace rackup -D -E development -p 8910 -s mongrel config.ru
$ wget http://localhost:8910
## strace output tail end
select(4, [3], [], [], {0, 0}) = 0 (Timeout)
select(4, [3], [], [], {0, 0}) = 0 (Timeout)
open("/home/app/seci/integrity.db", O_RDWR|O_CREAT, 0644) = 5
fstat(5, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
View gist:35029
@search_results = WillPaginate::Collection.create(page, per_page) do |pager|
xs = ActsAsXapian::Search.new(@search_models, @search_term, {:offset => pager.offset, :limit => pager.per_page})
results = xs.results.map {|r| r[:model] }
pager.replace(results)
pager.total_entries = xs.matches_estimated
end
## alternatively
View delegate_attributes.rb
module DelegateAttributes
def self.included(base)
base.class_eval do
extend ClassMethods
end
end
module ClassMethods
def delegate_or_override(*methods)
View gist:77212
>> u = Factory(:user)
ActiveRecord::StatementInvalid: Mysql::Error: Cannot add or update a child row: a foreign key constraint fails (`openmrs_development/users`, CONSTRAINT `user_creator` FOREIGN KEY (`creator`) REFERENCES `users` (`user_id`)): INSERT INTO `users` (`salt`, `creator`, `date_created`, `voided`, `secret_answer`, `changed_by`, `secret_question`, `system_id`, `username`, `void_reason`, `date_changed`, `voided_by`, `first_name`, `date_voided`, `last_name`, `password`, `middle_name`) VALUES('ied6FQj8o8', 1, '2009-03-10 20:03:19', 0, NULL, NULL, NULL, 'Baobab Admin', 'mike1', NULL, '2009-03-10 20:03:19', NULL, 'Mike1', '2009-03-10 20:03:19', 'McKay1', '750bda64556e9178987072b329f4f8a53c37cb9d', NULL)
# factories.rb
Factory.define :user do |u|
u.salt { User.random_string(10) }
u.password { |a| User.encrypt(Sham.password, a.salt) }
u.date_created { Time.now.to_formatted_s(:db) }
u.date_changed { Time.now.to_formatted_s(:db) }
u.date_voided { Time.now.to_formatted_
View gist:78694
SQL (0.001587) INSERT INTO patient_historical_outcomes (patient_id, outcome_date, outcome_concept_id)
SELECT encounter.patient_id, encounter.encounter_datetime, 324
FROM encounter
INNER JOIN orders ON orders.encounter_id = encounter.encounter_id AND orders.voided = 0
INNER JOIN drug_order ON drug_order.order_id = orders.order_id
INNER JOIN drug ON drug_order.drug_inventory_id = drug.drug_id
INNER JOIN concept_set as arv_drug_concepts ON
arv_drug_concepts.concept_set = 460 AND
arv_drug_concepts.concept_id = drug.concept_id
WHERE encounter.patient_id = 4
View gist:91500
drugs_dispensed_last_time = Hash.new
previous_art_drug_orders.collect{|drug_order|
drugs_dispensed_last_time[drug_order.drug] = true
}
drugs_dispensed_last_time = drugs_dispensed_last_time.keys
You can’t perform that action at this time.