SlideShare una empresa de Scribd logo
1 de 30
Descargar para leer sin conexión
From Ruby Installation
                         to Deploy
                            this is gonna hurt your head




Tuesday, October 19, 2010
About Me

                            Speaker.new({
                               :name        =>   "Scotty Motte",
                               :email       =>   "scott@spitfiresky.com",
                               :twitter     =>   "@spitfiresky",
                               :works_on    =>   "http://smartevents.com"
                            })




Tuesday, October 19, 2010
Building Web Apps
                    • Server Side
                            •   Server Side Programming Language - Ruby

                            •   Database - MySQL

                            •   Versioning Software - GIT


                    • Browser Side
                            •   HTML - HAML

                            •   Javascript - jQuery

                            •   AJAX




Tuesday, October 19, 2010
Server Side




Tuesday, October 19, 2010
Programming Languages
                    •       Ruby (writes like english. great community. hotter than
                            your mom. nuff said.)

                    • PHPbrackets)like someone shat all over the page with
                      curly
                            (looks


                    • Java (configuration weirdos)
                    • .NET (put a gun to my head already)
                    • Perl (WTF)
Tuesday, October 19, 2010
Why Ruby
                    • Created by Matz - he’s Japanese
                    • Programmer Happiness! - written for
                            humans not for computers
                    • Easy to read and write
                            5.times { puts "Have some chunky bacon Matz."}

                            ['riverside', 'japan', 'america'].each {|locale|
                            puts locale.capitalize }


                    • Popularized by Ruby on Rails
Tuesday, October 19, 2010
Install Ruby
                    • Mac Users, I say rejoice, for thou haveth
                            Ruby already!
                    • Windows users - are you prejudiced
                             towards Japan or something?! Let’s fix that
                             by installing Ruby:
                            • http://www.ruby-lang.org/en/downloads/ - run the one-click installer
                                and make sure to de-check the SciTE and check enable ruby gems.
                                Important.

                            •   (http://docs.heroku.com/windows) - very helpful. video.


                                                 Remember - friends don’t let friends use internet explorer.
Tuesday, October 19, 2010
Database

                    • Where we store our data
                    • MySQL popular
                    • skip


Tuesday, October 19, 2010
Git
                    • Keeps track of all the code you write
                    • http://code.google.com/p/msysgit/
                            (windows)
                    • http://code.google.com/p/git-osx-installer/
                            (mac)
                    • http://github.com (keep your code safe)

Tuesday, October 19, 2010
Hello World app

                    • [sudo] gem install sinatra
                    • [sudo] gem install unicorn
                    • [sudo] gem install haml
                    • mkdir hello_world
                    • cd hello_world

Tuesday, October 19, 2010
Hello World app cont.
                    • Create and edit app.rb
                              require 'rubygems'
                              require 'sinatra'

                              get '/' do
                                "Hello World!"
                              end




Tuesday, October 19, 2010
Hello World app cont.
                    • Create and edit config.ru file
                             require 'app'
                             run Sinatra::Application




Tuesday, October 19, 2010
Hello World app cont.
                    • Create and edit .gems file for heroku

                            sinatra --version '>= 0.9.4'
                            haml




Tuesday, October 19, 2010
Hello World app cont.

                    • Run the local server: unicorn -p 3000
                    • Browse to: http://localhost:3000/
                    • Congrats! Drink a beer!


Tuesday, October 19, 2010
Deploy


                    • Sign up on Heroku: http://heroku.com
                    • [sudo] gem install heroku


Tuesday, October 19, 2010
Deploy cont.

                    • cd into your hello_world project
                    • git init
                    • git add .
                    • git commit -am “initial import”

Tuesday, October 19, 2010
Deploy cont.


                    • ssh-keygen -C “you@email.com” -t rsa
                    • (leave the passphrase blank unless it’s your
                            computer)




Tuesday, October 19, 2010
Deploy cont.

                    • heroku create
                    • git push heroku master
                    • heroku rename yourchoice
                    • browse to http://yourchoice.heroku.com

Tuesday, October 19, 2010
Deploy cont.
                    • Other things you can do
                       • Add an about page
                       • Switch to haml
                       • Add a layout file
                       • Add images under a public folder
                       • Move onto ajax
Tuesday, October 19, 2010
views/layout.haml
                    !!!
                    %html
                      %head
                        %title Your App
                        %link{:rel=>'stylesheet', :href=>'/stylesheets/
                    layout.css', :type => "text/css"}
                        / javascripts
                        %script{:type => "text/javascript", :src => "/javascripts/
                    jquery.js"}
                        %script{:type => "text/javascript", :src => "/javascripts/
                    index.js"}
                      %body
                        = yield




Tuesday, October 19, 2010
views/index.haml
                               %h1
                                 Hello World!




                                get '/' do
                                  haml :index
                                end




Tuesday, October 19, 2010
Browser Side




Tuesday, October 19, 2010
public/javascripts


                    • Add jquery.js - download from jquery.com
                    • Add index.js


Tuesday, October 19, 2010
public/javascripts/
                                 index.js

                            $(document).ready(function() {
                              alert("It works!");
                            });




Tuesday, October 19, 2010
views/index.haml
             %h1 Hello World

             %h2 Search

             %form{:id => "search_form", :method => "get", :action => "/search"}
               %input{:type => "text", :id => "search_field", :name => "search_field"}
               %input{:type => "submit", :value => "Search", :id => "search_btn"}

             %ul#search_field_value
               %li= @search_field_value




Tuesday, October 19, 2010
app.rb (add route)
                            get '/search' do
                              @search_field_value = params[:search_field]
                              haml :index
                            end




Tuesday, October 19, 2010
public/javascripts/
                                   index.js
                            $(document).ready(function() {
                              $("#search_btn").click(function() {
                                var search_text = $("#search_field").val();
                                alert(search_text);
                                return false;
                              });
                            });




Tuesday, October 19, 2010
public/javascripts/
                                 index.js
                            $(document).ready(function() {
                              $("#search_btn").click(function() {
                                var search_text = $("#search_field").val();
                                // alert(search_text);

                                $.ajax({
                                  url: "/search?search_field="+search_text,
                                  success: function(responseText, statusText, xhr) {
                                     $('#search_field_value').append(responseText);
                                  },
                                  error: function(request, statusText, xhr) {
                                     alert("There was an error!");
                                  }
                                });

                                return false;
                              });
                            });




Tuesday, October 19, 2010
public/javascripts/
                                  index.js
                            get '/search' do
                              @search_field_value = params[:search_field]
                              "<li>#{@search_field_value}</li>"
                            end




Tuesday, October 19, 2010
The End




Tuesday, October 19, 2010

Más contenido relacionado

Destacado (8)

Romans 8 2 mms 11 13 and 20 22011
Romans 8 2 mms  11 13 and 20 22011Romans 8 2 mms  11 13 and 20 22011
Romans 8 2 mms 11 13 and 20 22011
 
Map It! 090717
Map It! 090717Map It! 090717
Map It! 090717
 
Epwp E Londen 17 June2008
Epwp E Londen 17 June2008Epwp E Londen 17 June2008
Epwp E Londen 17 June2008
 
Rubattino Portfolio
Rubattino PortfolioRubattino Portfolio
Rubattino Portfolio
 
Kon nichi wa_ruby
Kon nichi wa_rubyKon nichi wa_ruby
Kon nichi wa_ruby
 
Luke 1 1 4 42.3 mms 03 06 2012 jesus in the old testment
Luke 1 1 4 42.3   mms 03 06 2012 jesus in the old testmentLuke 1 1 4 42.3   mms 03 06 2012 jesus in the old testment
Luke 1 1 4 42.3 mms 03 06 2012 jesus in the old testment
 
Philippians 3 outline now
Philippians  3 outline nowPhilippians  3 outline now
Philippians 3 outline now
 
Belajar cara belajar
Belajar cara belajarBelajar cara belajar
Belajar cara belajar
 

Similar a From Ruby Installation to Deploy and Beyond

Dojo Basics Js UserGroup Chicago
Dojo Basics Js UserGroup ChicagoDojo Basics Js UserGroup Chicago
Dojo Basics Js UserGroup Chicagowolframkriesing
 
通用JS时代的模块机制和编译工具
通用JS时代的模块机制和编译工具通用JS时代的模块机制和编译工具
通用JS时代的模块机制和编译工具Dexter Yang
 
Gaelyk - SpringOne2GX - 2010 - Guillaume Laforge
Gaelyk - SpringOne2GX - 2010 - Guillaume LaforgeGaelyk - SpringOne2GX - 2010 - Guillaume Laforge
Gaelyk - SpringOne2GX - 2010 - Guillaume LaforgeGuillaume Laforge
 
Codemotion 2013 - presentación cocoa pods
Codemotion  2013 -  presentación cocoa podsCodemotion  2013 -  presentación cocoa pods
Codemotion 2013 - presentación cocoa podsJorge Maroto
 
Casual and Social Games with Unity
Casual and Social Games with UnityCasual and Social Games with Unity
Casual and Social Games with UnityTadej Gregorcic
 
Tomboy Web Sync Explained
Tomboy Web Sync ExplainedTomboy Web Sync Explained
Tomboy Web Sync ExplainedMohan Krishnan
 
iBizLog. Smalltalking the Web
iBizLog. Smalltalking the WebiBizLog. Smalltalking the Web
iBizLog. Smalltalking the WebESUG
 
Leweb09 Building Wave Robots
Leweb09 Building Wave RobotsLeweb09 Building Wave Robots
Leweb09 Building Wave RobotsPatrick Chanezon
 
或るWebサービス開発のこれから - "オープンWebサービス"という妄想 -
或るWebサービス開発のこれから - "オープンWebサービス"という妄想 -或るWebサービス開発のこれから - "オープンWebサービス"という妄想 -
或るWebサービス開発のこれから - "オープンWebサービス"という妄想 -Kei Shiratsuchi
 
Dockerizing IoT Services
Dockerizing IoT ServicesDockerizing IoT Services
Dockerizing IoT Servicesmsyukor
 
Ruby, Rails, and the Open Source Community
Ruby, Rails, and the Open Source CommunityRuby, Rails, and the Open Source Community
Ruby, Rails, and the Open Source CommunityJim Myhrberg
 
Eclipse Orion: The IDE in the Clouds (JavaOne 2013)
Eclipse Orion: The IDE in the Clouds (JavaOne 2013)Eclipse Orion: The IDE in the Clouds (JavaOne 2013)
Eclipse Orion: The IDE in the Clouds (JavaOne 2013)Murat Yener
 
Compiling and Optimizing Your Own Browser with WebKit
Compiling and Optimizing Your Own Browser with WebKitCompiling and Optimizing Your Own Browser with WebKit
Compiling and Optimizing Your Own Browser with WebKitSencha
 
Appcelerator Titanium Intro
Appcelerator Titanium IntroAppcelerator Titanium Intro
Appcelerator Titanium IntroNicholas Jansma
 
UI Beyond the Browser - Software for Hardware Projects
UI Beyond the Browser - Software for Hardware ProjectsUI Beyond the Browser - Software for Hardware Projects
UI Beyond the Browser - Software for Hardware Projectspchristensen
 
GOTO Paris | @see Gopher
GOTO Paris | @see GopherGOTO Paris | @see Gopher
GOTO Paris | @see GopherJan Klat
 

Similar a From Ruby Installation to Deploy and Beyond (20)

Dojo Basics Js UserGroup Chicago
Dojo Basics Js UserGroup ChicagoDojo Basics Js UserGroup Chicago
Dojo Basics Js UserGroup Chicago
 
Html5 Apps
Html5 AppsHtml5 Apps
Html5 Apps
 
通用JS时代的模块机制和编译工具
通用JS时代的模块机制和编译工具通用JS时代的模块机制和编译工具
通用JS时代的模块机制和编译工具
 
Processing
ProcessingProcessing
Processing
 
Gaelyk - SpringOne2GX - 2010 - Guillaume Laforge
Gaelyk - SpringOne2GX - 2010 - Guillaume LaforgeGaelyk - SpringOne2GX - 2010 - Guillaume Laforge
Gaelyk - SpringOne2GX - 2010 - Guillaume Laforge
 
Codemotion 2013 - presentación cocoa pods
Codemotion  2013 -  presentación cocoa podsCodemotion  2013 -  presentación cocoa pods
Codemotion 2013 - presentación cocoa pods
 
Casual and Social Games with Unity
Casual and Social Games with UnityCasual and Social Games with Unity
Casual and Social Games with Unity
 
Tomboy Web Sync Explained
Tomboy Web Sync ExplainedTomboy Web Sync Explained
Tomboy Web Sync Explained
 
Node and SocketIO
Node and SocketIONode and SocketIO
Node and SocketIO
 
iBizLog. Smalltalking the Web
iBizLog. Smalltalking the WebiBizLog. Smalltalking the Web
iBizLog. Smalltalking the Web
 
Vagrant at LA Ruby
Vagrant at LA RubyVagrant at LA Ruby
Vagrant at LA Ruby
 
Leweb09 Building Wave Robots
Leweb09 Building Wave RobotsLeweb09 Building Wave Robots
Leweb09 Building Wave Robots
 
或るWebサービス開発のこれから - "オープンWebサービス"という妄想 -
或るWebサービス開発のこれから - "オープンWebサービス"という妄想 -或るWebサービス開発のこれから - "オープンWebサービス"という妄想 -
或るWebサービス開発のこれから - "オープンWebサービス"という妄想 -
 
Dockerizing IoT Services
Dockerizing IoT ServicesDockerizing IoT Services
Dockerizing IoT Services
 
Ruby, Rails, and the Open Source Community
Ruby, Rails, and the Open Source CommunityRuby, Rails, and the Open Source Community
Ruby, Rails, and the Open Source Community
 
Eclipse Orion: The IDE in the Clouds (JavaOne 2013)
Eclipse Orion: The IDE in the Clouds (JavaOne 2013)Eclipse Orion: The IDE in the Clouds (JavaOne 2013)
Eclipse Orion: The IDE in the Clouds (JavaOne 2013)
 
Compiling and Optimizing Your Own Browser with WebKit
Compiling and Optimizing Your Own Browser with WebKitCompiling and Optimizing Your Own Browser with WebKit
Compiling and Optimizing Your Own Browser with WebKit
 
Appcelerator Titanium Intro
Appcelerator Titanium IntroAppcelerator Titanium Intro
Appcelerator Titanium Intro
 
UI Beyond the Browser - Software for Hardware Projects
UI Beyond the Browser - Software for Hardware ProjectsUI Beyond the Browser - Software for Hardware Projects
UI Beyond the Browser - Software for Hardware Projects
 
GOTO Paris | @see Gopher
GOTO Paris | @see GopherGOTO Paris | @see Gopher
GOTO Paris | @see Gopher
 

Último

Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
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
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 

Último (20)

Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
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
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 

From Ruby Installation to Deploy and Beyond

  • 1. From Ruby Installation to Deploy this is gonna hurt your head Tuesday, October 19, 2010
  • 2. About Me Speaker.new({ :name => "Scotty Motte", :email => "scott@spitfiresky.com", :twitter => "@spitfiresky", :works_on => "http://smartevents.com" }) Tuesday, October 19, 2010
  • 3. Building Web Apps • Server Side • Server Side Programming Language - Ruby • Database - MySQL • Versioning Software - GIT • Browser Side • HTML - HAML • Javascript - jQuery • AJAX Tuesday, October 19, 2010
  • 5. Programming Languages • Ruby (writes like english. great community. hotter than your mom. nuff said.) • PHPbrackets)like someone shat all over the page with curly (looks • Java (configuration weirdos) • .NET (put a gun to my head already) • Perl (WTF) Tuesday, October 19, 2010
  • 6. Why Ruby • Created by Matz - he’s Japanese • Programmer Happiness! - written for humans not for computers • Easy to read and write 5.times { puts "Have some chunky bacon Matz."} ['riverside', 'japan', 'america'].each {|locale| puts locale.capitalize } • Popularized by Ruby on Rails Tuesday, October 19, 2010
  • 7. Install Ruby • Mac Users, I say rejoice, for thou haveth Ruby already! • Windows users - are you prejudiced towards Japan or something?! Let’s fix that by installing Ruby: • http://www.ruby-lang.org/en/downloads/ - run the one-click installer and make sure to de-check the SciTE and check enable ruby gems. Important. • (http://docs.heroku.com/windows) - very helpful. video. Remember - friends don’t let friends use internet explorer. Tuesday, October 19, 2010
  • 8. Database • Where we store our data • MySQL popular • skip Tuesday, October 19, 2010
  • 9. Git • Keeps track of all the code you write • http://code.google.com/p/msysgit/ (windows) • http://code.google.com/p/git-osx-installer/ (mac) • http://github.com (keep your code safe) Tuesday, October 19, 2010
  • 10. Hello World app • [sudo] gem install sinatra • [sudo] gem install unicorn • [sudo] gem install haml • mkdir hello_world • cd hello_world Tuesday, October 19, 2010
  • 11. Hello World app cont. • Create and edit app.rb require 'rubygems' require 'sinatra' get '/' do "Hello World!" end Tuesday, October 19, 2010
  • 12. Hello World app cont. • Create and edit config.ru file require 'app' run Sinatra::Application Tuesday, October 19, 2010
  • 13. Hello World app cont. • Create and edit .gems file for heroku sinatra --version '>= 0.9.4' haml Tuesday, October 19, 2010
  • 14. Hello World app cont. • Run the local server: unicorn -p 3000 • Browse to: http://localhost:3000/ • Congrats! Drink a beer! Tuesday, October 19, 2010
  • 15. Deploy • Sign up on Heroku: http://heroku.com • [sudo] gem install heroku Tuesday, October 19, 2010
  • 16. Deploy cont. • cd into your hello_world project • git init • git add . • git commit -am “initial import” Tuesday, October 19, 2010
  • 17. Deploy cont. • ssh-keygen -C “you@email.com” -t rsa • (leave the passphrase blank unless it’s your computer) Tuesday, October 19, 2010
  • 18. Deploy cont. • heroku create • git push heroku master • heroku rename yourchoice • browse to http://yourchoice.heroku.com Tuesday, October 19, 2010
  • 19. Deploy cont. • Other things you can do • Add an about page • Switch to haml • Add a layout file • Add images under a public folder • Move onto ajax Tuesday, October 19, 2010
  • 20. views/layout.haml !!! %html %head %title Your App %link{:rel=>'stylesheet', :href=>'/stylesheets/ layout.css', :type => "text/css"} / javascripts %script{:type => "text/javascript", :src => "/javascripts/ jquery.js"} %script{:type => "text/javascript", :src => "/javascripts/ index.js"} %body = yield Tuesday, October 19, 2010
  • 21. views/index.haml %h1 Hello World! get '/' do haml :index end Tuesday, October 19, 2010
  • 23. public/javascripts • Add jquery.js - download from jquery.com • Add index.js Tuesday, October 19, 2010
  • 24. public/javascripts/ index.js $(document).ready(function() { alert("It works!"); }); Tuesday, October 19, 2010
  • 25. views/index.haml %h1 Hello World %h2 Search %form{:id => "search_form", :method => "get", :action => "/search"} %input{:type => "text", :id => "search_field", :name => "search_field"} %input{:type => "submit", :value => "Search", :id => "search_btn"} %ul#search_field_value %li= @search_field_value Tuesday, October 19, 2010
  • 26. app.rb (add route) get '/search' do @search_field_value = params[:search_field] haml :index end Tuesday, October 19, 2010
  • 27. public/javascripts/ index.js $(document).ready(function() { $("#search_btn").click(function() { var search_text = $("#search_field").val(); alert(search_text); return false; }); }); Tuesday, October 19, 2010
  • 28. public/javascripts/ index.js $(document).ready(function() { $("#search_btn").click(function() { var search_text = $("#search_field").val(); // alert(search_text); $.ajax({ url: "/search?search_field="+search_text, success: function(responseText, statusText, xhr) { $('#search_field_value').append(responseText); }, error: function(request, statusText, xhr) { alert("There was an error!"); } }); return false; }); }); Tuesday, October 19, 2010
  • 29. public/javascripts/ index.js get '/search' do @search_field_value = params[:search_field] "<li>#{@search_field_value}</li>" end Tuesday, October 19, 2010