Skip to content

Instantly share code, notes, and snippets.

View vcabansag's full-sized avatar

Vincent Cabansag vcabansag

View GitHub Profile
@vcabansag
vcabansag / gist:7308a3d79ca57ede4e73
Created May 6, 2014 16:19
Adding HTTP Authentication to a Middleman app using Heroku environment variables
require "rubygems"
require "rack"
require "middleman/rack"
require "rack/contrib/try_static"
protected_middleman = Rack::Auth::Basic.new(Middleman.server) do |username, password|
[username, password] == [ENV['HTTP_USERNAME'], ENV['HTTP_PASSWORD']]
# Enable proper HEAD responses
use Rack::Head
# Exploring methods
def introduce(first_name, last_name)
puts "Hello! My name is #{first_name} #{last_name}."
end
# Ruby creates local variables called first_name and last_name and
# assigns the inputs (or arguments) into them
# Accessing hashes and arrays
# Create a set of hashes like below:
student1 = { "first" => "Neal", "last" => "Sales-Griffin", "hometown" => "Chicago" }
student2 = { "first" => "Mike", "last" => "McGee", "hometown" => "Freeport" }
student3 = { "first" => "Jeff", "last" => "Cohen", "hometown" => "Skokie" }
student4 = { "first" => "Raghu", "last" => "Betina", "hometown" => "Goshen" }
student5 = { "first" => "Vince", "last" => "Cabansag", "hometown" => "Sturgis" }