Skip to content

Instantly share code, notes, and snippets.

View matt297's full-sized avatar

Matt Hennessy matt297

View GitHub Profile
@matt297
matt297 / ruby_examples.rb
Last active November 14, 2021 04:29 — forked from MaggieMoss/ruby-examples.rb
Lighthouse Labs - Intro to Web Dev - W2D2
# STRINGS
# # we can use double quotes
puts "This is a string."
# # or we can use single quotes
puts 'This is a string with single quotes.'
# # adding two strings together
puts 'Hello, ' + "Maggie."
#INTEGER
#we can add them
@matt297
matt297 / fizzbuzz.rb
Last active November 2, 2016 23:32 — forked from sarahca/fizzbuzz.rb
Lighthouse Labs - Intro to Web Dev - W2D2
# Our program should
# - make a list of numbers from 1 to 100 (inclusive)
# - for each number:
# print "Fizz" if divisible by 3
# print "Buzz" if divisible by 5
# print "FizzBuzz" if divisible by 3 AND 5
# otherwise, print the number
# uncomment the block of code you want to run to test each version
@matt297
matt297 / fizzbuzz_class_solution.rb
Last active November 8, 2016 01:00
Lighthouse Labs - Intro to Web Dev - W2D2 - Oct 2016 Cohort
def number_label(number)
if number % 5 == 0 && number % 3 == 0
"#{number} FIZZBUZZ"
elsif number % 5 == 0
"#{number} BUZZ"
elsif number % 3 == 0
"#{number} FIZZ"
@matt297
matt297 / yellowpager.rb
Last active November 8, 2016 01:12
Lighthouse Labs - Intro to Web Dev - W3D1
# Courtesy of https://ide.c9.io/brendandeere/yellowpager
# Write a method called "yellowpager" that accepts a 10-character string of
# letters and outputs a corresponding phone number string. If the input letter
# string isn't 10 characters, you should return false. Not valid.
# 2 -> A B C
# 3 -> D E F
# 4 -> G H I
# 5 -> J K L
@matt297
matt297 / yellowpage_class_solution.rb
Created November 8, 2016 02:08
Lighthouse Labs - Intro to Web Dev - W3D1 - Oct 2016 Cohort
def map_letters_to_numbers(user_input)
user_output = ""
user_input.upcase!
if user_input.length == 10
user_input.each_char do |letter|
case letter
when("A".."C") then user_output += "2"
when("D".."F") then user_output += "3"
@matt297
matt297 / song_class_example.rb
Created November 15, 2016 00:27
Lighthouse Labs - Intro to Web Dev - W4D1 - Oct 2016 Cohort
class Song
def initialize(title)
@title = title
end
def play
puts "Now playing #{@title}"
end
@matt297
matt297 / calculator_challenge.md
Last active November 15, 2016 01:20
Calculator Challenge

Calculator Challenge

You have been tasked with creating a program that runs in the command line (bash). The program should ask for 2 numbers, a mathematical operator, and then execute the operation on the two numbers.

How It Works

  • Can be run using bash (i.e. ruby yourfile.rb)
  • Asks the user to input a number (i.e. 10)
  • Asks the user to input another number (i.e. 5)
  • Asks the user to input a mathematical operator (i.e. +)
  • Outputs the the result of the computation (i.e. 15.0)
@matt297
matt297 / sinatra_form_example.md
Last active June 7, 2017 23:10
Lighthouse Labs - Intro to Web Dev - W4D1 - Oct 2016 Cohort

app/models/user.erb

class User < ActiveRecord::Base

  # All of the fields listed here are required
  validates_presence_of :email, :avatar_url, :username, :password

  # All of these fields must be unique (i.e. can't register the same email twice)
  validates_uniqueness_of :email, :username
  
@matt297
matt297 / heroku_deployment.md
Last active November 25, 2020 23:56
Lighthouse Labs - Intro to Web Dev - W6D2 - Deploying Finstagram to Heroku

Deploying Finstagram to Heroku

These instructions will help you deploy your Finstagram app to Heroku (a web hosting service), so that the entire internet will be able to see and interact with your application! Before we get to deployment though, we need to make sure a couple of our files are setup properly.

Pre-Deployment: Edit Your Gemfile

Ensure your Gemfile file contains the following code (should match exactly).

source "https://rubygems.org"

gem 'rake'
gem 'activesupport'
@matt297
matt297 / web_dev_cheatsheet.md
Last active May 1, 2023 05:48
Lighthouse Labs - Intro to Web Dev - Cheat Sheet