Skip to content

Instantly share code, notes, and snippets.

View mjseaman's full-sized avatar

Mitch Seaman mjseaman

  • Grafana Labs
  • Stockholm, Sweden
View GitHub Profile
# Save this file to your computer so you can run it
# via the command line (Terminal) like so:
# $ ruby deaf_grandma.rb
#
# Your method should wait for user input, which corresponds
# to you saying something to your Grandma.
# You'll probably want to write other methods, but this
# encapsulates the core Grandma logic
def deaf_grandma
def pig_latin_word(input)
index = input.split(//).index { |letter| letter[/[aeiouAEIOU]/] != nil }
(input + (input.slice!(0..(index-1))) + "ay").downcase
end
def pig_latin_phrase(input)
input.split(" ").map {|current_word| pig_latin_word(current_word)}.join(" ").capitalize
end
class MotorVehicle
def initialize(args)
@color = args[:color]
@wheels = args[:wheels]
end
def drive
@status = :driving
end
@mjseaman
mjseaman / index.html
Last active December 19, 2015 19:58 — forked from dbc-challenges/index.html
DBC Phase 2 Practice Assessment Part 3
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="http://cdn.jsdelivr.net/normalize/2.1.0/normalize.css">
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lato:100,900">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.0.2/css/font-awesome.min.css">
</head>
/* Here is your chance to take over Socrates!
Spend 10 minutes on each of the following hacks to the socrates website.
Enter them in the console to make sure it works and then save
your results here.
Choose a new pair for each. Add your names to the section you complete.
*/
/* Here is your chance to take over Socrates!
Spend 10 minutes on each of the following hacks to the socrates website.
Enter them in the console to make sure it works and then save
your results here.
Choose a new pair for each. Add your names to the section you complete.
*/
@mjseaman
mjseaman / app.html
Last active December 20, 2015 03:38
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
<script src="application.js"></script>
<link href="application.css" type="text/css" rel="stylesheet"></link>
</head>
@mjseaman
mjseaman / views.md
Last active December 20, 2015 15:08

Views in Rails work similarly to views in Sinatra, although Rails is more opinionated about where your views live in your application directory structure. The main difference is that Rails uses render to render views and partials, abstracting away the particular "format" of the view, e.g., ERB or something else.

In Sinatra we'd write something like

get '/users/:id' do
  @user = User.find(params[:id])

  erb :show_users
end
class Account
class InvalidAccountNumberError < StandardError; end
class NegativeDepositError < StandardError; end
class OverdraftError < StandardError; end
attr_reader :transactions
def initialize(acct_number, starting_balance = 0)
validate_number(acct_number)

#OOJS: Grocery List

That's all.