Skip to main content

Posts

Showing posts with the label explain!

Study Guide 170

HTTP Describe what HTTP is and the role of the request and the response. HTTP is just a text sent over the internet with a set of rules that governs how computer communicates with each other. It follows a model whereby a client makes a request and then wait for a response from a server. HTTP itself doesn't transmit data, it depends on TCP/IP protocol to get request/response from one machine to another.  What are the components of an HTTP request and an HTTP response? HTTP request and response has a header and body.  HTTP response will contain status code ( 200 OK)  and headers which is a metadata that contain information for content-type (text/html),  Content-Encoding:gzip (type of file compression), server (name of the server), Location (new resource location for redirects) and a HTTP body  HTTP request header contain information on HTTP method (GET/POST) , path and parameter to allow server to know how to find information, along with optional hea...

Explain CSS cascading rules

- within same specificity , the styles further in the bottom take higher precedence, like a water fall cascade. p {     color: red; } p {     color: blue; } The paragraph will be blue. - There are different specificity base on different selector    - ID        1-0-0    - class    0-1-0    - type     0-0-1 ID is the most specific, so its style will take precedence if class and type classed with ID. - You can combine selector , so the highest number will take precedence #num .cili .love {      color: red; } 1-2-0 #num .cili {      color: blue; } 1-1-0 Color will still be black - You can have two class for each element, separated by one space. <p class="btn  btn-success"> </p>

Explain Gemfile and Gemfile.lock

Bundler allow you to specify exactly which third party software is required to run your program. Gemfile will list - all the dependencies/third party program required to run your program. - where to source those gems Gemfile.lock will list the exact version of the third party softwarre Gemfile.lock will be generated the first time you run 'bundle install'

Explain sinatra route

* Sinatra is simply a Ruby Gem that is build specifically for easy web development. Its syntax is generally build around blocks like one below. get '/' do     @value = 'abc'     erb :layout end -sinatra route derived its name from HTTP method like GET, POST, or PUT. - here, '/' means a route for the web application like www.yourapp.com/ , it just specify the last character '/' for brevity. - any instance variable like @value will be accessible inside the templating language , in this case, erb file. - The last line 'erb :layout' will ask Sinatra to execute the template :layout * There are two important variable in Sinatra, namely params and session - session is instructing Sinatra to build a cookie that holds important information/build states that will last between multiple HTTP request, since HTTP is a stateless communication (ie. it forgets after each HTTP request). - You can push any information any information into session bec...

Explain a method

A method is simply a sequence of instruction that the computer will execute from start to finish. Eg: a = 10 def shout( a )     puts "hello!"     a = 15     puts a end shout(a) puts a # hello! # 15 # return nil # 10 - The method will take one or more input and output something after the sequence of instruction. - here, a is passed into the method shout , then assigned to a new variable 'a' and printed out as 15. - the original local var outside is still 10. - the method here has 3 lines of instruction. First one is output hello, second is assignment to number 15 to variable a , third one is output variable a. - The last line in the method's instruction will be returned . If we print what the value of the method's returned , it is nil puts shout(a) # nil