SlideShare a Scribd company logo
1 of 17
Download to read offline
MAKE
                   YOUR OWN
                       TOOLS

   ChristopherCotton.com
           @_cotton
          2013-03-07
Nashville Ruby on Rails Meetup
Why?
             Repetition Sucks
                      Repetition Sucks
 Repetition Sucks
                                             Repetition Repetition Sucks
                                                        Sucks
  Repetition Sucks
              Repetition Sucks    Text                  Repetition Sucks
                                  Repetition Sucks
epetition Sucks                                       Repetition Sucks
                          Repetition Sucks
Repetition Sucks
                                                        Repetition Sucks
petition Sucks
                                                   Repetition Sucks
          Repetition Sucks
                       Repetition Sucks Repetition
Why?




Code Easier than Manual
Why?



       Transfer
       of Knowledge
What?


Simple Lines of Ruby

Command Line Tools

Simple Webapps

Apply lots of Regex, Regex, Regex
HOW?
DOES IT WORK?
NOT PRETTY
   HOW?
I BUILT WHAT?
     HOW?
EXAMPLES
build.rb
                                         Android Building

    OptionParser.new do |o|
  o.on('-d', '--deploy [DIR]', 'Deploy to HST, can pass in directory') { |dir|
$deploy_dir = dir || "#{ENV['HOME']}/Hst/Dropbox"
  o.on('-r', '--release KEYSTORE', 'Keystore for the relase build') { |key|
$keystore = key }
  o.on('-h', 'Print out help') { puts o; exit }
  o.parse!
end

ensure_local_properies(File.join(buildtarget_dir, "facebook"), android_sdk_location)

# modify the AndroidManifest.xml
Replacement.file(File.join(buildtarget_dir, "AndroidManifest.xml")) do |rp|
  rp.buffer.gsub!(/package="#{package_prefix}.#{old_package}"/, "package=
"#{package_prefix}.#{package}"")
end
copy_assets.rb
              Image Asset Copying
  rsync to copy assets

  scale for non-retina versions

  create .h/.m Object C for constants
File.open(File.join(root_dir, "Primer", "AssetConstants.h"),'w') do |file|
  file.puts "// Do not edit this file, it is auto generated by
#{File.basename(__FILE__)}"
  file.puts ""
  image_files.each do |image|
    file.puts "FOUNDATION_EXPORT NSString *const
kAsset_#{File.basename(image, File.extname(image))};"
  end
end
Mini Server
translation helper

   def trans2(eng, language)
  File.open("otherresources/#{ARGV[0]}_trans2.txt", "w") do |o|

    eng.each_with_index.select do |line, index|
      if line =~ /<key>(.+)</key>/
        o.puts("")
        o.puts("Categoryt#{unquote($1)}")
      end

      if line =~ /<string>(.+)</string>/
        o.print("t#{unquote($1)}")
        language[index] =~ /<string>(!?)(.+)</string>/

        o.puts("t#{unquote($2)}t#{$1}")
      end
    end
  end
end
check_assets.rb




     assets = {}
total_dirs = 0

Dir.glob(File.join(dropbox, "*")).each do |root_dir|
!    next unless File.directory?(root_dir)
!    total_dirs += 1
!    dir_name = File.basename(root_dir)
!    Dir.glob(File.join(root_dir, "*")).each do |file|
!    !    name = File.basename(file)
!    !    assets[name] = (assets[name] || []).push(dir_name) !   !
!    end!
end

assets.each do |key,value|!
!    puts "#{key} = #{value.inspect}" unless total_dirs == value.length
end
Image Extraction, Composition




  Spaceward Ho!
Share Your Tool



 Open Source

 Can Happen Much Later

 Version Control
Q &A

More Related Content

Similar to Make Your Own Tools

Ruby from zero to hero
Ruby from zero to heroRuby from zero to hero
Ruby from zero to heroDiego Lemos
 
Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to RubyMark Menard
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perlworr1244
 
WordPress Plugin Localization
WordPress Plugin LocalizationWordPress Plugin Localization
WordPress Plugin LocalizationRonald Huereca
 
RSpec 3.0: Under the Covers
RSpec 3.0: Under the CoversRSpec 3.0: Under the Covers
RSpec 3.0: Under the CoversBrian Gesiak
 
Perl 5.10
Perl 5.10Perl 5.10
Perl 5.10acme
 
Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Aslak Hellesøy
 
Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Aslak Hellesøy
 
Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Aslak Hellesøy
 
name name2 n
name name2 nname name2 n
name name2 ncallroom
 
name name2 n2
name name2 n2name name2 n2
name name2 n2callroom
 

Similar to Make Your Own Tools (20)

Ruby from zero to hero
Ruby from zero to heroRuby from zero to hero
Ruby from zero to hero
 
API Design
API DesignAPI Design
API Design
 
Ruby 101
Ruby 101Ruby 101
Ruby 101
 
Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Ruby
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
WordPress Plugin Localization
WordPress Plugin LocalizationWordPress Plugin Localization
WordPress Plugin Localization
 
An introduction to Ruby
An introduction to RubyAn introduction to Ruby
An introduction to Ruby
 
RSpec 3.0: Under the Covers
RSpec 3.0: Under the CoversRSpec 3.0: Under the Covers
RSpec 3.0: Under the Covers
 
ruby3_6up
ruby3_6upruby3_6up
ruby3_6up
 
ruby3_6up
ruby3_6upruby3_6up
ruby3_6up
 
Ruby
RubyRuby
Ruby
 
Perl 5.10
Perl 5.10Perl 5.10
Perl 5.10
 
Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009
 
Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009
 
Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009
 
ppt7
ppt7ppt7
ppt7
 
ppt2
ppt2ppt2
ppt2
 
name name2 n
name name2 nname name2 n
name name2 n
 
name name2 n2
name name2 n2name name2 n2
name name2 n2
 
test ppt
test ppttest ppt
test ppt
 

Recently uploaded

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
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
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 

Recently uploaded (20)

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
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
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 

Make Your Own Tools

  • 1. MAKE YOUR OWN TOOLS ChristopherCotton.com @_cotton 2013-03-07 Nashville Ruby on Rails Meetup
  • 2. Why? Repetition Sucks Repetition Sucks Repetition Sucks Repetition Repetition Sucks Sucks Repetition Sucks Repetition Sucks Text Repetition Sucks Repetition Sucks epetition Sucks Repetition Sucks Repetition Sucks Repetition Sucks Repetition Sucks petition Sucks Repetition Sucks Repetition Sucks Repetition Sucks Repetition
  • 4. Why? Transfer of Knowledge
  • 5. What? Simple Lines of Ruby Command Line Tools Simple Webapps Apply lots of Regex, Regex, Regex
  • 7. NOT PRETTY HOW?
  • 10. build.rb Android Building OptionParser.new do |o| o.on('-d', '--deploy [DIR]', 'Deploy to HST, can pass in directory') { |dir| $deploy_dir = dir || "#{ENV['HOME']}/Hst/Dropbox" o.on('-r', '--release KEYSTORE', 'Keystore for the relase build') { |key| $keystore = key } o.on('-h', 'Print out help') { puts o; exit } o.parse! end ensure_local_properies(File.join(buildtarget_dir, "facebook"), android_sdk_location) # modify the AndroidManifest.xml Replacement.file(File.join(buildtarget_dir, "AndroidManifest.xml")) do |rp| rp.buffer.gsub!(/package="#{package_prefix}.#{old_package}"/, "package= "#{package_prefix}.#{package}"") end
  • 11. copy_assets.rb Image Asset Copying rsync to copy assets scale for non-retina versions create .h/.m Object C for constants File.open(File.join(root_dir, "Primer", "AssetConstants.h"),'w') do |file| file.puts "// Do not edit this file, it is auto generated by #{File.basename(__FILE__)}" file.puts "" image_files.each do |image| file.puts "FOUNDATION_EXPORT NSString *const kAsset_#{File.basename(image, File.extname(image))};" end end
  • 13. translation helper def trans2(eng, language) File.open("otherresources/#{ARGV[0]}_trans2.txt", "w") do |o| eng.each_with_index.select do |line, index| if line =~ /<key>(.+)</key>/ o.puts("") o.puts("Categoryt#{unquote($1)}") end if line =~ /<string>(.+)</string>/ o.print("t#{unquote($1)}") language[index] =~ /<string>(!?)(.+)</string>/ o.puts("t#{unquote($2)}t#{$1}") end end end end
  • 14. check_assets.rb assets = {} total_dirs = 0 Dir.glob(File.join(dropbox, "*")).each do |root_dir| ! next unless File.directory?(root_dir) ! total_dirs += 1 ! dir_name = File.basename(root_dir) ! Dir.glob(File.join(root_dir, "*")).each do |file| ! ! name = File.basename(file) ! ! assets[name] = (assets[name] || []).push(dir_name) ! ! ! end! end assets.each do |key,value|! ! puts "#{key} = #{value.inspect}" unless total_dirs == value.length end
  • 16. Share Your Tool Open Source Can Happen Much Later Version Control
  • 17. Q &A