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
defmodule Countdown do | |
def from(number, phrase \\ 'Aww shucky ducky!') do | |
Stream.iterate(number, &(&1 - 1)) |> Enum.take(number + 1) |> Enum.map( | |
fn | |
0 -> say(phrase) | |
number -> | |
say(number) | |
sleep(1) | |
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
function getInput() { | |
prompt('Please guess a number between 1 and 100.'); | |
} | |
var name = prompt('Welcome! What\'s your name?'); | |
var secretNumber = (Math.floor(Math.random() * 100) + 1); | |
while(!name.length > 0) { | |
name = prompt("Enter something for a name :)") |
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 Mortgage | |
attr_reader :principal, :down_payment_percentage, :apr, :duration_in_years | |
def initialize(principal, down_payment_percentage, apr, years) | |
@principal = principal | |
@down_payment_percentage = down_payment_percentage | |
@apr = apr | |
@duration_in_years = years | |
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
class Whiteboard | |
attr_accessor :contents | |
def initialize(contents = []) | |
@contents = contents | |
end | |
def erase_whiteboard | |
@contents = [] |
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 Car | |
def initialize(color, owner, cylinders) | |
@color = color | |
@owner = owner | |
@cylinders = cylinders | |
end | |
def color | |
@color | |
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
class Television # A TV plays many channels and many shows of those channels. | |
def initialize(channels=[]) | |
@channels = channels | |
end | |
end | |
class Channels #A channel may have many shows and belong to many TVs. | |
def initialize(shows=[]) | |
@shows = shows | |
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
class Card | |
attr_reader :rank, :suit | |
def initialize(rank=nil, suit = nil) | |
if suit.nil? | |
@suit = ['♠', '♣', '♥', '♦'].sample | |
else | |
@suit = suit | |
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
SELECT title, rating FROM movies ORDER BY rating LIMIT 50; | |
SELECT title FROM movies | |
WHERE rating IS NULL | |
ORDER BY title; | |
SELECT title FROM movies | |
WHERE synopsis ILIKE '%thrilling%'; | |
SELECT movies.title, movies.year, movies.rating FROM movies |
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
body {font: 80% Verdana;} | |
.whole_page {background-color: #f6f6ef; | |
width: 85%; | |
margin: auto;} | |
header {background-color: #ff6600; | |
height: 1.80em; | |
position: relative;} |
NewerOlder