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 n
name name2 nname name2 n
name name2 ncallroom
 

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
 
test ppt
test ppttest ppt
test ppt
 
name name2 n
name name2 nname name2 n
name name2 n
 

Recently uploaded

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 

Recently uploaded (20)

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 

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