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
example_tree = [ | |
{:node=>:at_rule, | |
:name=>"charset", | |
:prelude=>[{:node=>:whitespace, :pos=>8, :raw=>" "}, {:node=>:string, :pos=>9, :raw=>"\"UTF-8\"", :value=>"UTF-8"}], | |
:tokens=> | |
[{:node=>:at_keyword, :pos=>0, :raw=>"@charset", :value=>"charset"}, | |
{:node=>:whitespace, :pos=>8, :raw=>" "}, | |
{:node=>:string, :pos=>9, :raw=>"\"UTF-8\"", :value=>"UTF-8"}, | |
{:node=>:semicolon, :pos=>16, :raw=>";"}]}, | |
{:node=>:style_rule, |
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
{ | |
"name": "dst-react", | |
"devDependencies": { | |
"browserify": "~>6.3", | |
"browserify-incremental": "^1.4.0", | |
"jasmine-expect-jsx": "^1.1.2", | |
"jest-cli": "^0.5.4", | |
"react": "^0.13.0", | |
"react-tools": "^0.12.1", | |
"reactify": "^0.17.1" |
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
function nth(list, index) { | |
for (var node = list; node; node = node.rest) { | |
if (index == 0) { | |
return (node.value || undefined); | |
} else { | |
nth(node.rest, index--) | |
} | |
} | |
} |
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
var i = 0; | |
console.log(i++); | |
var i = 0; | |
console.log(i += 1); | |
var i = 0; | |
console.log(++i); |
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 Shelf # without the wrapper | |
... | |
def store(book) | |
# imagine complicated logic here... | |
intermediate_result = book.storage_requirements / self.capacity | |
# imagine more complicated logic... | |
end | |
end | |
class Shelf # with wrapper |
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 Book | |
.... | |
def initialize(title: 'Unknown', author: 'Unknown') # This is the Ruby >= 2.0 syntax. | |
@title = title | |
@author = author | |
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 Shelf | |
... | |
def store(book) | |
length = book.length | |
width = book.width | |
depth = book.depth | |
# logic to find the nearest spot that can accomodate the given dimensions | |
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 Book | |
.... | |
def initialize(args) | |
args = defaults.merge(args) # If you're using Ruby <2.0, this is the way to go. | |
@title = args[:title] | |
@author = args[:author] | |
end | |
def defaults | |
{title: "Unknown", author: "Unknown"} | |
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 Shelf | |
... | |
def store(@book) | |
# logic to find the correct location on itself for @book | |
end | |
end | |
class Book | |
attr_accessor :title, :author | |
def initialize(args) |
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 Book | |
attr_accessor :title, :author | |
def initialize(args) | |
args = defaults.merge(args) | |
@title = args[:title] | |
... | |
end | |
def store_book | |
# logic for storing the book at a location on the shelf |
NewerOlder