This file contains 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
# ... previous setup and tests not shown for brevity ... | |
def test_the_whole_song | |
assert_equal bottles.verses(99, 0), bottles.song | |
end | |
# skipped tests not shown for brevity |
This file contains 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 Bottles | |
# ... verse() & verses() methods not shown for brevity ... | |
def song | |
verses(99,0) | |
end | |
end |
This file contains 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 Bottles | |
def verse(num) | |
case num | |
when 0 | |
"No more bottles of beer on the wall, no more bottles of beer.\n" + | |
"Go to the store and buy some more, 99 bottles of beer on the wall.\n" | |
when 1 | |
"1 bottle of beer on the wall, 1 bottle of beer.\n" + | |
"Take it down and pass it around, no more bottles of beer on the wall.\n" |
This file contains 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
├── Stylus@1.1.0 | |
├── Zen@0.16.2 | |
├── advanced-new-file@0.4.3 | |
├── atom-beautify@0.28.11 | |
├── atom-jade@0.3.0 | |
├── atom-lint@0.20.1 | |
├── atom-rails@0.4.0 | |
├── atomatigit@1.5.4 | |
├── auto-indent@0.5.0 | |
├── auto-update-packages@1.0.0 |
This file contains 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
import React from 'react'; | |
export default React.createClass({ | |
displayName: 'Button', | |
propTypes: { | |
text: React.PropTypes.string.isRequired, | |
isDisabled: React.PropTypes.bool | |
}, | |
getDefaultProps() { | |
return { |
This file contains 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 'benchmark' | |
require 'test/unit' | |
def count_frequency_of_string_values(key, observation) | |
# convert arguments into arrays for comparison | |
key_array = key.split(",").map { |s| s.to_i } | |
observation_array = observation.split(",").map { |s| s.to_i } | |
# for each key - count how many matches within observation and add result to the output | |
output = [] | |
key_array.each do |k| |
This file contains 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 createDoors | |
doors = [false, false, false] | |
# set one door equal to the car | |
doors[rand(3)] = true | |
doors | |
end | |
def openADoorThatHasAGoat(doors, userChoice) | |
# return the first false element after removing the users choice and a true value (if present) | |
([0, 1, 2] - [userChoice, doors.index(true)]).first |
This file contains 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 product_list(numbers): | |
result = 1 | |
for number in numbers | |
result = result * number | |
return result | |
This file contains 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
# pull content of a url | |
def get_page(url): | |
try: | |
import urllib | |
return urllib.urlopen(url).read() | |
except: | |
return "" | |
# find the links within a page | |
def get_next_target(page): |
This file contains 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 split_string(string, split_characters): | |
output = [] | |
atsplit = True | |
for char in source: | |
if char in splitlist: | |
atsplit = True | |
else: | |
if atsplit: | |
output.append(char) | |
atsplit = False |