Skip to content

Instantly share code, notes, and snippets.

View michael-reeves's full-sized avatar
💭
Livin the dream

Michael Reeves michael-reeves

💭
Livin the dream
View GitHub Profile
  1. Living and Working Abroad
  • Working Remote Around the World
  1. You're Going Where?
  2. Patagonia?
  3. That Patagonia
  4. Argentina and South America
  • A world away
  • Make amazing friends
  • Learn new things every day
  • AMAZING food/wine
@michael-reeves
michael-reeves / gist:1094befb6fe9e17ee7c2
Last active August 29, 2015 14:24
Playing with HTTP Request and Response via JoshCheek

Playing with HTTP Request and Response

The internet is just "client sends an HTTP request to the server, which sends back an HTTP response" where client is usually web browser. Sending an HTTP request is like writing to a file that goes across the internet, and reading from a file that came from the internet. So to understand the web, the most important thing is to understand HTTP requests. Then, you can go to Sinatra, and it will be "this is how Sinatra does that underlying thing you already know".

To see the request, go to the terminal and type nc -l 3000 (the number is called a port, it's like an index in an array, you put a program there, then when a web request comes in, it checks the port, finds the program, and hands it the incoming request). The specific number isn't important, as long as its big enough to get past the claimed ones. Now that you have that running, set it on one side of your screen, and set your browser on the other side. Then type `http:/

require 'prime'
class Prime
def self.fib(n)
if n == 0
return 0
end
(2..n).reduce([0,1]) do |total, n|
total << total[-1] + total[-2]
end
puts "Top Level"
puts "self is #{self}"
class C
puts "Class definition block:"
puts "self is #{self}"
def self.x
puts "Class method C.x:"
puts "self is #{self}"