SlideShare una empresa de Scribd logo
1 de 17
Descargar para leer sin conexión
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

Más contenido relacionado

Similar a 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
 

Similar a 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
 
ppt30
ppt30ppt30
ppt30
 

Último

Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationIES VE
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024SkyPlanner
 
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioChristian Posta
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Websitedgelyza
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostMatt Ray
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaborationbruanjhuli
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URLRuncy Oommen
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxMatsuo Lab
 
Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1DianaGray10
 
How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?IES VE
 
Machine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfMachine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfAijun Zhang
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemAsko Soukka
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6DianaGray10
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdfPedro Manuel
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024D Cloud Solutions
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfDianaGray10
 
NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopNIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopBachir Benyammi
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxUdaiappa Ramachandran
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAshyamraj55
 

Último (20)

Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
 
20150722 - AGV
20150722 - AGV20150722 - AGV
20150722 - AGV
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024
 
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and Istio
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Website
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URL
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptx
 
Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1
 
How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?
 
Machine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfMachine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdf
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystem
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdf
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
 
NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopNIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 Workshop
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptx
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
 

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