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
scottdomes@scottdomes-ThinkPad:~/WebDev/RubyTest$ pry | |
[1] pry(main)> def say_hi(name) | |
[1] pry(main)* | |
[1] pry(main)* "Hi, #{name}." | |
[1] pry(main)* end | |
=> nil | |
[2] pry(main)> say_hi("Scott") | |
=> "Hi, Scott." | |
[3] pry(main)> Time.now | |
=> 2016-03-01 11:00:06 -0800 |
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
# Find the maximum | |
def maximum(arr) | |
arr.inject { |x, max| x > max ? x : max } | |
end | |
# expect it to return 42 below | |
result = maximum([2, 42, 22, 02]) | |
puts "max of 2, 42, 22, 02 is: #{result}" | |
# expect it to return nil when empty array is passed in |
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 determine_free_bottles (investment) | |
process_purchase(investment) | |
begin | |
find_bottles(@caps, @empty_bottles) | |
end while @empty_bottles > 1 || @caps > 3 | |
print_result | |
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
var net = require('net'); | |
var server = net.createServer(function(socket) { | |
var date = printTime(); | |
socket.end(date); | |
}); | |
function zeroFill(i) { | |
return (i < 10 ? '0' : '') + 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
var color = require('colors'); | |
var fs = require('fs'); | |
var player1 = { | |
cash: 50, | |
wins: 0 | |
}; | |
var player2 = { | |
cash: 50, | |
wins: 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, { Component } from 'react' | |
import './App.css' | |
import ListItem from './ListItem' | |
function arrayGenerator(length) { | |
return Array.apply(null, { length: length }).map(Number.call, Number) | |
} | |
class App extends Component { | |
constructor(props) { |
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
componentDidUpdate() { | |
Perf.stop() | |
Perf.printInclusive() | |
Perf.printWasted() | |
} | |
resetMultiplier() { | |
Perf.start() | |
this.setState({ multiplier: 2 }) | |
} |
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, { Component } from 'react' | |
export default class ListItem extends Component { | |
shouldComponentUpdate(nextProps, nextState) { | |
return nextProps.text !== this.props.text | |
} | |
render() { | |
let { text } = this.props | |
return <li>{text}</li> |
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
componentWillMount() { | |
window.performance.mark('App') | |
} | |
componentDidMount() { | |
console.log(window.performance.now('App')) | |
} |
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, { Component } from 'react' | |
import { observer } from 'mobx-react' | |
import { string, object } from 'prop-types' | |
// Separate local imports from dependencies | |
import ExpandableForm from './ExpandableForm' | |
import './styles/ProfileContainer.css' | |
// Use decorators if needed | |
@observer | |
export default class ProfileContainer extends Component { |
OlderNewer