This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test/unit' | |
class ChangeMachine | |
# Returns an array indicating the quantity of | |
# each denomination required. | |
# [pennies, nickels, dimes, quarters] | |
def issue_coins(amount) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# s = "Can't believe Los Angeles won the Stanley Cup" | |
# | |
# a = ["downcase", "reverse", "upcase"] | |
# | |
# a.each do |m| | |
# puts s.send(m) | |
# end | |
class Team | |
def method_missing(m, *args) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script> | |
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/themes/redmond/jquery-ui.css" type="text/css" media="screen"> | |
<script> | |
$(function() { | |
$("#message").datepicker(); | |
$("a").on('click', function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
</head> | |
<body> | |
<script> | |
function sayWeather() { | |
alert('It is very nice outside, what are you doing coding in here?'); | |
var e = document.getElementById("jeff"); | |
// e.style.color = "red"; | |
e.style.display = "none"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Vending Project | |
# Task 1 - Write a vending machine script that will dispence cokes until inventory is 0. | |
# Task 2 - Try adding the ability to keep track of capacity per brand | |
class VendingMachine | |
def initialize(total_inventory) | |
@coke, @sprite, @root_beer = [total_inventory/3,total_inventory/3,total_inventory/3] | |
@money = 0 | |
@total_inventory = total_inventory * 50 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Try adding the ability to keep track of capacity per brand | |
# And push the buttons until the entire machine is empty | |
class VendingMachine | |
# attr_accessor :money | |
def initialize(number_of_cans) | |
@cans = [] | |
number_of_cans.times do | |
@cans << 'Coke' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Open up a Rails app that has at least one model | |
# Create a file named config/initializers/sample.rb | |
# Paste this code into it | |
# Open up your console | |
# Try to figure out how to call these methods | |
# Try to figure out how they work | |
class ActiveRecord::Base | |
def self.sample |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def something | |
puts "Hello" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def show | |
slug_id = CGI.escape(params[:id]) | |
@list = List.find_by_slug(slug_id) | |
@aha = Aha.new | |
@aha.list = @list | |
respond_to do |format| | |
format.html # show.html.erb | |
format.json { render json: @list } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
def method_missing(m, *args) | |
map_elements(m, args) || super | |
end | |
def map_elements(m, *args) | |
target_method = singular_of(m) | |
new_array = map do |element| | |
if element.respond_to?(target_method) |