Michael Sofaer's blog
Ask for Help
"Why did my .profile stop being sourced? It still works if I source it by hand.
You may have created a .bash_profile, which supercedes the .profile. One solution is to include your .profile from your .bash_profile. A pattern we sometimes use for this is to include every file in ~/.bash_profile_includes from the .bash_profile
"How do I get bash to automatically answer yes to questions programs ask?
There are various ways to do this, but the short answer is to use the "yes" program built into bash. yes | my_program
"How do you delete a file called ~ Not by typing rm -rf ~ The simplest thing is to do this through the OS file system GUI.
Interesting Things
Canvas Slow on Chrome
Canvas can get very slow on Chrome sometimes. If this happens, the only thing found to work so far is to delete the Library/Application Support/Google directory
Facebook Connect De-Auth rules
It was claimed that when a user de-authorizes your Facebook application, the Facebook API terms of service require you to delete all data about the user that you got from the API. This includes fields you pre-filled that the user then submitted.
Facebook does provide you with a de-auth callback if you want one, but there is no explicit mention of it in the ToS. The ToS does say you must remove user data "upon request" and that you have to provide a way to make such a request.
Ask for Help
"How can I turn off logging of email attachments in ActionMailer?"
You're not the only person ever to ask that.
Actionmailer's deliver method looks like this:
# File vendor/rails/actionmailer/lib/action_mailer/base.rb, line 473
473: def deliver!(mail = @mail)
474: raise "no mail object available for delivery!" unless mail
475: unless logger.nil?
476: logger.info "Sent mail to #{Array(recipients).join(', ')}"
477: logger.debug "\n#{mail.encoded}"
478: end
479:
480: begin
481: __send__("perform_delivery_#{delivery_method}", mail) if perform_deliveries
482: rescue Exception => e # Net::SMTP errors or sendmail pipe errors
483: raise e if raise_delivery_errors
484: end
485:
486: return mail
487: end
And the actual delivery methods look like this:
# File vendor/rails/actionmailer/lib/action_mailer/base.rb, line 594 594: def perform_delivery_smtp(mail) 595: destinations = mail.destinations 596: mail.ready_to_send 597: sender = mail['return-path'] || mail.from 598: 599: Net::SMTP.start(smtp_settings[:address], smtp_settings[:port], smtp_settings[:domain], 600: smtp_settings[:user_name], smtp_settings[:password], smtp_settings[:authentication]) do |smtp| 601: smtp.sendmail(mail.encoded, sender, destinations) 602: end 603: end
If you compare lines 477 and 601, you will see that they both hook directly into the "encoded" method on the Tmail object. If you want to fix this, you're going to have to patch (or monkeypathch) ActionMailer
"Why is Selenium running tests before Jelly has finished loading?"
The answer to this was that Webrat has a waiting period, and if you have a long load time you need to increase it.
try this to fix your selenium timeout problem (in your selenium_spec_helper.rb or equivalent):
Webrat.configure do |config| config.mode = :selenium config.selenium_browser_startup_timeout = 60 end
Interesting Things
- RVM hooks into Textmate. You can set up Textmate to run tests using an RVM Ruby. See this, for example.
- There are WWDC videos on iTunes if you have a Developer account.
- Garbage Collection: If you are using REE you need to pay attention to your garbage collection strategies. Even at low load levels it can make a difference in request time.
- Syslog-ng templates: If you have multiple servers, and you are using syslog-ng and Splnuk (you should be) you can format your syslog-ng log lines using templates.
- mail_safe: This is a gem that whitelists domains so all outbound email instead goes to you. Just install it and then
config.gem mail_safe
Of course, if you do this in production your emails won't work. Use it wisely.
