RudyGems
- Matthew Rudy Jacobs
- see me swim
- Github
- see some of my code
- WorkingWithRails
- see me working with rails
Google Goggles are good enough for me?
On Monday its the LRUG quiz.
Can Google’s entry into drunken embarassment prevention really hold out against my mathematical skills?
Am I just too elite?
At level 5 (the hardest) we still get sums like “6x9”!
Does my mathematical ability really drop that much?
We’ll see tomorrow!
What would happen if you ripped out your Db server?
Does your application and architecture really have failover?
If I broke into your datacentre, ripped out, and hid one of your servers, what would happen?
Is your architecture the biggest hurdle to scaling your web app?
Blain Cook and Joe Stump not talking about Twitter’s scaling issues.
Need to install MySQL gem for OSX?
… but getting errors?
matthew@iRudy:~/code/rails211again $ sudo gem install mysql Password: Building native extensions. This could take a while... ERROR: Error installing mysql: ERROR: Failed to build gem native extension. /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb install mysql checking for mysql_query() in -lmysqlclient... no checking for main() in -lm... yes checking for mysql_query() in -lmysqlclient... no checking for main() in -lz... yes checking for mysql_query() in -lmysqlclient... no checking for main() in -lsocket... no checking for mysql_query() in -lmysqlclient... no checking for main() in -lnsl... no checking for mysql_query() in -lmysqlclient... no *** extconf.rb failed *** ... Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.7 for inspection. Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.7/gem_make.out
Found the fix
sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
a better :delegate method?
So we have;
class Bum
attr_accessor :pants
delegate :smelly?, :to => :pants
end
We want to ask;
bum.smelly?
clearly if the bum has pants, then it’s only smelly if the pants are smelly
that’s cool,
but what if the bum has no pants?
>> bum.pants
=> nil
>> bum.smelly?
NoMethodError: You have a nil object when you didn't expect it!
The error occurred while evaluating nil.smelly?
from (__DELEGATION__):2:in `__send__'
from (__DELEGATION__):2:in `smelly?'
from (irb):7
this needs to be fixed,
but how?
by default we’d expect it to be nil,
but perhaps we want to assume that actually they’re smelly by default
but what syntax?
delegate :smelly, :to => :pants, :default => true
perhaps?
ActsAsSolr index out of sync?
Faced with a shocking
>> Phrase.find_by_solr ‘book’
RuntimeError: Out of sync!
The id 296452 is in the Solr index but
missing in the database!
Fix it
>> Phrase.solr_delete(“Phrase:296452”)
>> Phrase.solr_commit()
BOOM!!!