Skip to content

Instantly share code, notes, and snippets.

@minams
minams / rails http status codes
Created April 9, 2019 17:11 — forked from mlanett/rails http status codes
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
phone_numbers = [
"(206) 555-1234",
"425-555-9999",
"406.555.1818",
"+1 206 555 8888",
"4255558872",
]
pattern = /^.*(\d{3}).*(\d{3}).*(\d{4})$/
@minams
minams / fancy-baby-dragon.rb
Created February 27, 2019 00:17
fancy dragon exercise
class BabyDragon
def initialize(name, color)
@name = name
@hungriness_level = 10
@is_asleep = false
@thirst_level = 10
@color = color
end
@minams
minams / data-transformation-part2.rb
Created February 15, 2019 12:42
Data Transformation Part 2
# Part 2
# 1
# You are given an array of String objects, stored in a variable called my_strings.
# You want to use this array to create a new array of Integer objects,
# which represents the length of each string. We want to store the resulting
# array in a variable called string_lengths.
# def animal_types(my_strings)
# string_lengths = my_strings.map { |animal_index|
@minams
minams / random_menu.rb
Created February 15, 2019 12:10
Random Menu
# create three arrays with 10 items each:
# first one is adjective
# second one is cooking style
# third one is foods
# program should randomize food items on its own line
# each food item is numbered 1. 2. ...
# creating the 3 arrays
adjectives = %w(sticky smoky spicy creamy crunchy crispy cheesy glazed flaky buttery)
@minams
minams / data-transformation.rb
Created February 14, 2019 19:03
Data Transformation
# Part 1
# 1
# You are given an array of String objects, stored in a variable called my_strings.
# You want to use this array to create a new array of Integer objects,
# which represents the length of each string. We want to store the resulting
# array in a variable called string_lengths.
# def animal_types(my_strings)
# string_lengths = []
@minams
minams / loop_worksheet.rb
Created February 14, 2019 17:54
Loop Table Exercise
# [2,5,8,11,14].each do |x|
# puts 2 * x + 7
# end
# ["kittens", "meerkats", "red pandas"].each do |critter|
# affirmation = "I am as amazing as " + critter + "!"
# print critter
# puts affirmation
# end
@minams
minams / generator.rb
Created February 8, 2019 17:39
Portmanteau Generator Exercise
# establishing the run_generator method
# getting all of the input needed
# storing those pieces of input into variables
# being able to print out those variables
# iterating through individual characters in words to check which characters are vowels
# https://github.com/Ada-C11/portmanteau-generator
# wave 1:
def is_vowel?(vowel)
vowels = %w{a e i o u}