Last active
August 29, 2015 13:56
-
-
Save mathildathompson/9317796 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| TERNARY OPERATOR | |
| n.abs == 1 ? 'bottle' : 'bottles' | |
| #This is saying if the number of bottles is 1 return bottle, if not return bottles; | |
| # In Ruby we have open classes; | |
| #You can take any class at any point and add extra data into it; | |
| #MONKEY MATCHING adding something later to something that exists already; | |
| def self.song(num_bottles=99) | |
| end | |
| #You can provide a default number of bottles of beer; | |
| #If you call the method with an argument then it will use this, otherwise it will use the default value; | |
| ## DNS, IP, HTTP | |
| # Type in a URL and DNS turns the URL into a IP address in dotted quad notation (each of the numbers in the range 0-255); | |
| # After getting IP back from DNS sends a HTTP request to the server; | |
| # The http request has the clients IP address and also the servers IP address; | |
| # Get the static files, dynamic data from the database and combines into HTML to send back to the client; | |
| # IPV6, next IP generation - instead of going to 0-255 we will go from 0-356 (we will have an IP address for every atom in the universe!); | |
| ##IFCONFIG | |
| # Type ifconfig into terminal; | |
| # inet = internet address; | |
| # python -m SimpleHTTPServer (what ever folder you are in it will serve these as http); | |
| # Type 10.22.20.117:8000 (the port number is 8000); | |
| ##RESOURCES | |
| ##SINATRA | |
| # DSL to describe any easy way that web servers should work; | |
| # Sinara is a web server; | |
| # You need to require 'sinatra' at the top of your file; | |
| # Sinatra is on port 4567; | |
| # Ports, different services can be provided from different ports; | |
| # Port 80 is webstuff, port 23 is email, port 22 type commands on machine; | |
| # require 'sinatra/reloader' you do not have to keep re-running the file, it checks for changes; | |
| # localhost: 4567 (telling the computer which machine and which port); | |
| # WEbrick and Thin are modules that do the heavy lifting stuff between the browser and server; | |
| ##PLACEHOLDER (passing dynamic data into a URL) | |
| get '/name/:first' do | |
| "hello #{params[:first]} " | |
| end | |
| # The placeholder is denoted by a colon in front; | |
| # :first is the key which is accessible in the params hash; | |
| # mkdir public (static files) | |
| # mkdir views (have erb in here, this is html with embedded Ruby); | |
| # erb stands for embedded (it is html embedded with ruby); | |
| # <%= %> -> This is not part of html, allows you to embedd ruby code into the code; | |
| # <% %> syntax (without the = sign) means run the ruby code, but dont show it on the screen; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment