Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥

You Should Write a Ruby Gem

Ernie Miller
September 30, 2011

You Should Write a Ruby Gem

Lightning talk given at Ruby Hoedown 2011 and RubyConf 2011. Video from RubyConf is at http://www.confreaks.com/videos/741-rubyconf2011-lightning-talks, at around 18:15.

Ernie Miller

September 30, 2011
Tweet

More Decks by Ernie Miller

Other Decks in Programming

Transcript

  1. You Should Write a Ruby Gem Ernie Miller @erniemiller erniemiller.org

    http://github.com/ernie Sunday, September 23, 12
  2. • Reusable code is awesome • Well-factored code is awesome

    • awesome * n > awesome (for n > 1) Why? Sunday, September 23, 12
  3. • Reusable code is awesome • Well-factored code is awesome

    • awesome * n > awesome (for n > 1) • One more bullet point with awesome Why? Sunday, September 23, 12
  4. • Reusable code is awesome • Well-factored code is awesome

    • awesome * n > awesome (for n > 1) • One more bullet point with awesome • You will learn stuff Why? Sunday, September 23, 12
  5. • Reusable code is awesome • Well-factored code is awesome

    • awesome * n > awesome (for n > 1) • One more bullet point with awesome • You will learn stuff • You can give lightning talks about your gem Why? Sunday, September 23, 12
  6. Why not? • People will see my code! • No,

    really... people will see my code. Sunday, September 23, 12
  7. Why not? • People will see my code! • No,

    really... people will see my code. • Everyone rolls their own Sunday, September 23, 12
  8. Why not? • People will see my code! • No,

    really... people will see my code. • Everyone rolls their own • Someone else has probably done it better Sunday, September 23, 12
  9. Why not? • People will see my code! • No,

    really... people will see my code. • Everyone rolls their own • Someone else has probably done it better • It’s too trivial to bother with Sunday, September 23, 12
  10. Valium • Bypass ActiveRecord instantiation • Direct value access •

    Ridiculously simple http://github.com/ernie/valium Sunday, September 23, 12
  11. Valium • Bypass ActiveRecord instantiation • Direct value access •

    Ridiculously simple • Seriously. Like, <100 LOC simple. http://github.com/ernie/valium Sunday, September 23, 12
  12. Employee.where(:slacker => true).values_of :first_name, :last_name, :hired_at # => [["Ernie", "Miller",

    2009-09-21 08:00:00 -0400], ...] class Animal < ActiveRecord::Base serialize :extra_info end Animal.where(:genus => 'felis').values_of :species, :extra_info # => [["catus", {:domestic => true}], ["lolcatus", {:can_has_cheezburger => true}], ...] Obligatory Usage Examples Sunday, September 23, 12
  13. Months LOC Watchers MetaSearch 19 926 570 MetaWhere 18 948

    565 Ransack 6 1742 130 Squeel 6 2049 265 attr_bucket 8 117 18 ZOMG, A TABLE! (this talk is so information-rich) Sunday, September 23, 12
  14. “I've had times where I would just fork off a

    child process, do all the memory-intensive stuff inside the child process (1000+ AR objects would be instantiated) and then kill off the child when it was finished to remove potential memory leaks.” – A Commenter Sunday, September 23, 12
  15. Lessons Learned • What’s obvious to you is not necessarily

    obvious to someone else Sunday, September 23, 12
  16. Lessons Learned • What’s obvious to you is not necessarily

    obvious to someone else • You can’t predict what others will find useful Sunday, September 23, 12
  17. Lessons Learned • What’s obvious to you is not necessarily

    obvious to someone else • You can’t predict what others will find useful • Don’t ask yourself, “Should I release this?” Sunday, September 23, 12
  18. Lessons Learned • What’s obvious to you is not necessarily

    obvious to someone else • You can’t predict what others will find useful • Don’t ask yourself, “Should I release this?” • Release it. The Internet will answer that question for you. Trust me. Sunday, September 23, 12