SlideShare a Scribd company logo
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

PDF
Gitkata fish shell
PDF
Portafolio Profesional
KEY
Free graphics, by Christopher Cotton
PPTX
McKinsey: Understanding shifts in consumer behavior
PDF
PDF Ruby on Rails 3 Day BC
PDF
how to rate a Rails application
PDF
Rails as a Pattern Language
PDF
12 hours to rate a rails application
Gitkata fish shell
Portafolio Profesional
Free graphics, by Christopher Cotton
McKinsey: Understanding shifts in consumer behavior
PDF Ruby on Rails 3 Day BC
how to rate a Rails application
Rails as a Pattern Language
12 hours to rate a rails application

Similar to Make Your Own Tools (20)

PDF
Happy Coding with Ruby on Rails
KEY
Becoming a more Productive Rails Developer
KEY
Your fist RubyMotion Application
KEY
Becoming a more productive Rails Developer
KEY
API Design
PPTX
Adventures of java developer in ruby world
PDF
Rails 3 Beginner to Builder 2011 Week 1
PDF
Kon nichi wa_ruby
KEY
Make GUI Apps with Shoes
PDF
Ruby 入門 第一次就上手
PDF
MISC TOPICS #2: I18n Data Programming Pearls Random Records Rpx Now Susher St...
PDF
Teaching code literacy
PDF
RoR_2_Ruby
PDF
Rubyconf 2014 recap
PDF
IJTC%202009%20JRuby
PDF
IJTC%202009%20JRuby
PDF
Beyond The Timesheet
PDF
Ruby presentasjon på NTNU 22 april 2009
PDF
Ruby presentasjon på NTNU 22 april 2009
PDF
Ruby presentasjon på NTNU 22 april 2009
Happy Coding with Ruby on Rails
Becoming a more Productive Rails Developer
Your fist RubyMotion Application
Becoming a more productive Rails Developer
API Design
Adventures of java developer in ruby world
Rails 3 Beginner to Builder 2011 Week 1
Kon nichi wa_ruby
Make GUI Apps with Shoes
Ruby 入門 第一次就上手
MISC TOPICS #2: I18n Data Programming Pearls Random Records Rpx Now Susher St...
Teaching code literacy
RoR_2_Ruby
Rubyconf 2014 recap
IJTC%202009%20JRuby
IJTC%202009%20JRuby
Beyond The Timesheet
Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009
Ad

Recently uploaded (20)

PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Modernizing your data center with Dell and AMD
PPTX
Big Data Technologies - Introduction.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Cloud computing and distributed systems.
PPTX
A Presentation on Artificial Intelligence
PPT
Teaching material agriculture food technology
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Empathic Computing: Creating Shared Understanding
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
cuic standard and advanced reporting.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
Network Security Unit 5.pdf for BCA BBA.
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Modernizing your data center with Dell and AMD
Big Data Technologies - Introduction.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Machine learning based COVID-19 study performance prediction
Cloud computing and distributed systems.
A Presentation on Artificial Intelligence
Teaching material agriculture food technology
Agricultural_Statistics_at_a_Glance_2022_0.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Diabetes mellitus diagnosis method based random forest with bat algorithm
Empathic Computing: Creating Shared Understanding
Mobile App Security Testing_ A Comprehensive Guide.pdf
MYSQL Presentation for SQL database connectivity
Building Integrated photovoltaic BIPV_UPV.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
cuic standard and advanced reporting.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Digital-Transformation-Roadmap-for-Companies.pptx
Ad

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