Skip to content

Instantly share code, notes, and snippets.

View jacqui's full-sized avatar

Jacqui Lough jacqui

View GitHub Profile
@jacqui
jacqui / alc
Created March 2, 2015 17:08
quick hack to pull concepts, keywords or entities out of any url using AlchemyAPI
#!/usr/bin/env ruby
# USAGE:
#
# ./alc [action] [url]
# ex:
# ./alc keyword http://www.bbc.co.uk/news/magazine-31556802
# ./alc concept http://www.bbc.co.uk/news/magazine-31556802
# ./alc entity http://www.bbc.co.uk/news/magazine-31556802
#
@jacqui
jacqui / keybase.md
Created March 30, 2015 11:44
keybase.md

Keybase proof

I hereby claim:

  • I am jacqui on github.
  • I am jacqui (https://keybase.io/jacqui) on keybase.
  • I have a public key whose fingerprint is C180 D31A A199 8AA8 0A88 A082 2F52 F6A6 CCAE 051A

To claim this, I am signing this object:

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]
[15:40] [jm@tinsel:~/test] $ ls *
clone.git:
zutalors.rb
fauxgit:
zutalors.rb
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
[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
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
@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
module DelegateAttributes
def self.included(base)
base.class_eval do
extend ClassMethods
end
end
module ClassMethods
def delegate_or_override(*methods)
>> 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_