SlideShare ist ein Scribd-Unternehmen logo
1 von 45
Downloaden Sie, um offline zu lesen
It’s Time to Repay Your Debt
Windy City Rails

September 11, 2010
Kevin W. Gisi
Key Points



✤   Releasing Gems is ridiculously easy!

✤   You don’t have to be Matz!

✤   If you’ve ever DRYed your codebase, you’re probably ready
Before Hook



✤   before_filter :filter_method

✤   before_filter :filter_method, :only => [:foo, :bar]

✤   before_filter :filter_method, :except => :baz
class Foo
  include Filters

  before_filter :before_method
  after_filter :after_method, :only => :bar
  
  def foo(x)
    puts "foo #{x}"
  end

  def bar
    puts "bar"
  end

  def before_method
    puts "before_method" and return true
  end

  def after_method
    puts "after_method" and return true
  end

end
module Filters
  class << self
    def included(mod)
      mod.extend(Filters::ClassMethods)
      mod.instance_methods(false).each do |method|
        mod.add_global_hook(method)
      end
    end
  end

  module ClassMethods
    # Real methods
  end
end
befo
                                      re_filte
                                              r :me
                                      # op          thod
                                          tions           , :onl
                                                 [:onl
                                                       y] => y => :foo
                                                              [:foo
module ClassMethods                                                 ]
  def before_filter(hook_method,options={})
    options.keys.each{|k|options[k] = [options[k]].flatten}
   (@@before_hooks||={})[hook_method.to_sym] = options
  end

  def after_filter(hook_method,options={})
   options.keys.each{|k|options[k] = [options[k]].flatten}
   (@@after_hooks||={})[hook_method.to_sym] = options
  end

end
                                             > [:foo]
                           ethod, : except =
          afte r_ filter :m             > [:foo]
                             [:only] =
                  # options
Hook Tactics


✤   Alias the original method :foo => :__foo

✤   Rewrite :foo

    ✤   Run any before_hooks

    ✤   Run the original method (if the before_hooks returned true)

    ✤   Run any after_hooks
def add_global_hook(method)
  alias_method "__#{method}", method
  define_method method do |*args,&block|
    @@before_hooks ||= {}
    @@after_hooks ||= {}
    @@before_hooks.keys.each do |hook|
      unless (@@before_hooks[hook][:except]||[]).include?(method) ||
        (@@before_hooks[hook][:only] &&
          !@@before_hooks[hook][:only].include?(method))
        return unless send(hook)
      end
    end unless @@before_hooks[method] || @@after_hooks[method]

    returnable = send("__#{method}",*args,&block)

    @@after_hooks.keys.each do |hook|
      unless (@@after_hooks[hook][:except]||[]).include?(method) ||
        (@@after_hooks[hook][:only] &&
          !@@after_hooks[hook][:only].include?(method))
        return unless send(hook)
      end
    end unless @@before_hooks[method] || @@after_hooks[method]
    return returnable
  end
end
def add_global_hook(method)
  alias_method "__#{method}", method
  define_method method do |*args,&block|
    @@before_hooks ||= {}
    @@after_hooks ||= {}
    @@before_hooks.keys.each do |hook|
      unless (@@before_hooks[hook][:except]||[]).include?(method) ||
        (@@before_hooks[hook][:only] &&
          !@@before_hooks[hook][:only].include?(method))
        return unless send(hook)
      end
    end unless @@before_hooks[method] || @@after_hooks[method]

    returnable = send("__#{method}",*args,&block)

    @@after_hooks.keys.each do |hook|
      unless (@@after_hooks[hook][:except]||[]).include?(method) ||
        (@@after_hooks[hook][:only] &&
          !@@after_hooks[hook][:only].include?(method))
        return unless send(hook)
      end
    end unless @@before_hooks[method] || @@after_hooks[method]
    return returnable
  end
end
module Filters
  class << self
    def included(mod)
      mod.extend(Filters::ClassMethods)
      mod.instance_methods(false).each do |method|
        mod.add_global_hook(method)
      end
    end
  end

  module ClassMethods
    # ...
    def method_added(method)
      add_global_hook(method) unless
        method.to_s[0,2] == "__" ||
        instance_methods.include?("__#{method}".to_sym)
    end
  end
end
class Foo
  include Filters

  before_filter :before_method
  after_filter :after_method, :only => :bar
  
  def foo(x)
    puts "foo #{x}"
  end

  def bar
    puts "bar"
  end

  def before_method
    puts "before_method" and return true
  end

  def after_method
    puts "after_method" and return true
  end

end
Let’s Make It A Gem!

 filt.gemspec
 Gem::Specification.new do |s|
   s.name    = "filt"
   s.version = "0.0.1"
   s.summary = "before and after filters for Ruby"
   s.files   = ["lib/filt"]
 end
Let’s Share The Gem!



✤   gem build filt.gemspec

✤   gem push filt-0.0.1.gem

✤   http://rubygems.org/gems/filt
John Doe Programmer


✤   Windows 7 machine (moderate hardware)

✤   Visual Studio

✤   Microsoft SQL Server

✤   A little bit of PHP

✤   Minimal web experience
This Isn’t Bad!



✤   Choice is important!

✤   There are many “right ways”

✤   Flexibility allows us to create better solutions
OpenPGP

   module OpenPGP
     class Message
       include Enumerable

       # ...

       def self.decrypt(data, options = {}, &block)
         raise NotImplementedError # TODO
       end
     end
   end
What Is A Product?



✤   Utility

✤   Aesthetics
Aesthetics
map.resources :products, :member => {:short
=> :post}, :collection => {:long => :get} do |products|
  products.resource :category
end
resources :products do
  resource :category
 
  member do
    post :short
  end
 
  collection do
    get :long
  end
end
 
match "/posts/github" => redirect("http://github.com/rails.atom")
Utility




✤   Solves a problem
Agile (according to rumor)




✤   Do the absolute bare minimum to get something delivered
Agile




✤   Do the absolute bare minimum to get something delivered*
Delivered, n.

✤   Coded

✤   Deployed

✤   Supported

✤   Tested

✤   Extensible

✤   Usable by the client
Open-Source Is A Marketplace
The Lazy Programmer’s Manifesto


✤   I want to write code once

✤   I want to be able to read code without having to refer to external docs

✤   I want to be able to rely on other libraries

✤   I want to use adaptable solutions for numerous problems

✤   I want to always be working on something new
Products For A Lazy Market
Development For A Lazy Market
Idea Filtering

✤   To share

    ✤   Business value

    ✤   Practical use

✤   To learn

    ✤   No requirements!

    ✤   Don’t post it publicly!
Testing



✤   We all say we do it!

✤   RSpec and Cucumber are both easy to set up for gems

✤   Design verification tool
Extensible


✤   Write clean code (don’t post a spike)

✤   Have a peer review your stuff

✤   Follow the Unix philosophy: do one thing really well

    ✤   Leverage other gems!
Documented


✤   Who’s looking at your code if it’s on GitHub, RubyGems?

✤   RDoc, YARD, etc

✤   Getting Started

✤   Blog posts!
Supported



✤   Put your name on it

✤   Answer your emails, damnit

✤   Accept patches (at minimum)
Be Honest


✤   Don’t be too proud to hand over the reins

✤   If your project is worth supporting, someone will step up

✤   Be a net-positive for the community

✤   Don’t announce things if they’re not done
But, But, But!!!



✤   Don’t post it

✤   Post it in a limited venue

✤   Put a disclaimer on your project
How Does The Internet Filter
Stupid?


✤   It doesn’t?

✤   Making tasks difficult

✤   Having enough eyes
Matz Wisdom




✤   “Ruby treats you like a grown-up programmer”
What Happens When Grown-Ups
Have Too Much Fun?
How To Be A Good Parent

✤   Don’t create sensory overload

✤   Spoon-feed sometimes

✤   Remember you’re used to the
    status quo

✤   Be a mentor

✤   Provide solutions to problems,
    not blocks of code
It’s Time To Repay Your Debt
Thank You!



✤   Kevin W. Gisi

✤   Twitter: @gisikw

✤   http://spkr8.com/t/4414

Weitere ähnliche Inhalte

Kürzlich hochgeladen

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 

Kürzlich hochgeladen (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 

Empfohlen

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Empfohlen (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

It's Time to Repay Your Debt

  • 1. It’s Time to Repay Your Debt Windy City Rails September 11, 2010
  • 3. Key Points ✤ Releasing Gems is ridiculously easy! ✤ You don’t have to be Matz! ✤ If you’ve ever DRYed your codebase, you’re probably ready
  • 4. Before Hook ✤ before_filter :filter_method ✤ before_filter :filter_method, :only => [:foo, :bar] ✤ before_filter :filter_method, :except => :baz
  • 5. class Foo   include Filters   before_filter :before_method   after_filter :after_method, :only => :bar      def foo(x)     puts "foo #{x}"   end   def bar     puts "bar"   end   def before_method     puts "before_method" and return true   end   def after_method     puts "after_method" and return true   end end
  • 6. module Filters   class << self     def included(mod)       mod.extend(Filters::ClassMethods)       mod.instance_methods(false).each do |method|         mod.add_global_hook(method)       end     end   end   module ClassMethods     # Real methods   end end
  • 7. befo re_filte r :me # op thod tions , :onl [:onl y] => y => :foo [:foo module ClassMethods ] def before_filter(hook_method,options={})   options.keys.each{|k|options[k] = [options[k]].flatten}    (@@before_hooks||={})[hook_method.to_sym] = options end def after_filter(hook_method,options={})    options.keys.each{|k|options[k] = [options[k]].flatten}    (@@after_hooks||={})[hook_method.to_sym] = options end end > [:foo] ethod, : except = afte r_ filter :m > [:foo] [:only] = # options
  • 8. Hook Tactics ✤ Alias the original method :foo => :__foo ✤ Rewrite :foo ✤ Run any before_hooks ✤ Run the original method (if the before_hooks returned true) ✤ Run any after_hooks
  • 9. def add_global_hook(method)   alias_method "__#{method}", method   define_method method do |*args,&block|     @@before_hooks ||= {}     @@after_hooks ||= {}     @@before_hooks.keys.each do |hook|       unless (@@before_hooks[hook][:except]||[]).include?(method) || (@@before_hooks[hook][:only] && !@@before_hooks[hook][:only].include?(method))         return unless send(hook)       end     end unless @@before_hooks[method] || @@after_hooks[method]     returnable = send("__#{method}",*args,&block)     @@after_hooks.keys.each do |hook|       unless (@@after_hooks[hook][:except]||[]).include?(method) || (@@after_hooks[hook][:only] && !@@after_hooks[hook][:only].include?(method))         return unless send(hook)       end     end unless @@before_hooks[method] || @@after_hooks[method] return returnable   end end
  • 10. def add_global_hook(method)   alias_method "__#{method}", method   define_method method do |*args,&block|     @@before_hooks ||= {}     @@after_hooks ||= {}     @@before_hooks.keys.each do |hook|       unless (@@before_hooks[hook][:except]||[]).include?(method) || (@@before_hooks[hook][:only] && !@@before_hooks[hook][:only].include?(method))         return unless send(hook)       end     end unless @@before_hooks[method] || @@after_hooks[method]     returnable = send("__#{method}",*args,&block)     @@after_hooks.keys.each do |hook|       unless (@@after_hooks[hook][:except]||[]).include?(method) || (@@after_hooks[hook][:only] && !@@after_hooks[hook][:only].include?(method))         return unless send(hook)       end     end unless @@before_hooks[method] || @@after_hooks[method] return returnable   end end
  • 11. module Filters   class << self     def included(mod)       mod.extend(Filters::ClassMethods)       mod.instance_methods(false).each do |method|         mod.add_global_hook(method)       end     end   end   module ClassMethods     # ... def method_added(method)   add_global_hook(method) unless method.to_s[0,2] == "__" || instance_methods.include?("__#{method}".to_sym) end   end end
  • 12. class Foo   include Filters   before_filter :before_method   after_filter :after_method, :only => :bar      def foo(x)     puts "foo #{x}"   end   def bar     puts "bar"   end   def before_method     puts "before_method" and return true   end   def after_method     puts "after_method" and return true   end end
  • 13. Let’s Make It A Gem! filt.gemspec Gem::Specification.new do |s|   s.name = "filt"   s.version = "0.0.1"   s.summary = "before and after filters for Ruby" s.files = ["lib/filt"] end
  • 14. Let’s Share The Gem! ✤ gem build filt.gemspec ✤ gem push filt-0.0.1.gem ✤ http://rubygems.org/gems/filt
  • 15.
  • 16.
  • 17. John Doe Programmer ✤ Windows 7 machine (moderate hardware) ✤ Visual Studio ✤ Microsoft SQL Server ✤ A little bit of PHP ✤ Minimal web experience
  • 18.
  • 19.
  • 20. This Isn’t Bad! ✤ Choice is important! ✤ There are many “right ways” ✤ Flexibility allows us to create better solutions
  • 21. OpenPGP module OpenPGP   class Message     include Enumerable     # ...     def self.decrypt(data, options = {}, &block)       raise NotImplementedError # TODO     end  end end
  • 22. What Is A Product? ✤ Utility ✤ Aesthetics
  • 23. Aesthetics map.resources :products, :member => {:short => :post}, :collection => {:long => :get} do |products|   products.resource :category end resources :products do   resource :category     member do     post :short   end     collection do     get :long   end end   match "/posts/github" => redirect("http://github.com/rails.atom")
  • 24. Utility ✤ Solves a problem
  • 25. Agile (according to rumor) ✤ Do the absolute bare minimum to get something delivered
  • 26. Agile ✤ Do the absolute bare minimum to get something delivered*
  • 27. Delivered, n. ✤ Coded ✤ Deployed ✤ Supported ✤ Tested ✤ Extensible ✤ Usable by the client
  • 28. Open-Source Is A Marketplace
  • 29. The Lazy Programmer’s Manifesto ✤ I want to write code once ✤ I want to be able to read code without having to refer to external docs ✤ I want to be able to rely on other libraries ✤ I want to use adaptable solutions for numerous problems ✤ I want to always be working on something new
  • 30. Products For A Lazy Market
  • 31. Development For A Lazy Market
  • 32. Idea Filtering ✤ To share ✤ Business value ✤ Practical use ✤ To learn ✤ No requirements! ✤ Don’t post it publicly!
  • 33. Testing ✤ We all say we do it! ✤ RSpec and Cucumber are both easy to set up for gems ✤ Design verification tool
  • 34. Extensible ✤ Write clean code (don’t post a spike) ✤ Have a peer review your stuff ✤ Follow the Unix philosophy: do one thing really well ✤ Leverage other gems!
  • 35. Documented ✤ Who’s looking at your code if it’s on GitHub, RubyGems? ✤ RDoc, YARD, etc ✤ Getting Started ✤ Blog posts!
  • 36. Supported ✤ Put your name on it ✤ Answer your emails, damnit ✤ Accept patches (at minimum)
  • 37. Be Honest ✤ Don’t be too proud to hand over the reins ✤ If your project is worth supporting, someone will step up ✤ Be a net-positive for the community ✤ Don’t announce things if they’re not done
  • 38.
  • 39. But, But, But!!! ✤ Don’t post it ✤ Post it in a limited venue ✤ Put a disclaimer on your project
  • 40. How Does The Internet Filter Stupid? ✤ It doesn’t? ✤ Making tasks difficult ✤ Having enough eyes
  • 41. Matz Wisdom ✤ “Ruby treats you like a grown-up programmer”
  • 42. What Happens When Grown-Ups Have Too Much Fun?
  • 43. How To Be A Good Parent ✤ Don’t create sensory overload ✤ Spoon-feed sometimes ✤ Remember you’re used to the status quo ✤ Be a mentor ✤ Provide solutions to problems, not blocks of code
  • 44. It’s Time To Repay Your Debt
  • 45. Thank You! ✤ Kevin W. Gisi ✤ Twitter: @gisikw ✤ http://spkr8.com/t/4414