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 { Switch, Route } from 'react-router' | |
import { replace } from 'react-router-redux' | |
@connect(null, { replace }) | |
class PrivateRoute extends React.Component { | |
componentWillMount() { | |
this.props.replace('/foo') | |
} | |
render() { |
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 assert from 'assert' | |
const sortByAge = (source) => source.sort((itemA, itemB) => itemA.age - itemB.age) | |
const ob = (age) => ({ name: ''+age, age }) | |
assert.deepEqual( | |
sortByAge([ ob(1), ob(6), ob(2), ob(5), ob(3), ob(4) ]), | |
[ ob(1), ob(2), ob(3), ob(4), ob(5), ob(6) ] | |
) |
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
const flatten = (source) => { | |
const length = source.length | |
let i = 0 | |
let flattened = [] | |
for (; i < length; i++) { | |
// recursive call could reach stack limit | |
flattened = flattened.concat( | |
!Array.isArray(source[i]) ? source[i] : flatten(source[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
#!/usr/bin/python | |
import pandas as pd | |
import statsmodels.api as sm | |
import math | |
import matplotlib.pyplot as plt | |
import numpy as np | |
loansData = pd.read_csv('loansData_clean.csv') | |
loansData['IR_TF'] = loansData['Interest.Rate'] < 12 |
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 pandas as pd | |
import matplotlib.pyplot as plt | |
loansData = pd.read_csv( | |
'https://spark-public.s3.amazonaws.com/dataanalysis/loansData.csv' | |
) | |
loansData['Interest.Rate'] = loansData['Interest.Rate'].map( | |
lambda x: float(x.rstrip('%')) | |
) | |
loansData['Loan.Length'] = loansData['Loan.Length'].map( |
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
from scipy import stats | |
# import matplotlib.pyplot as plt | |
import pandas as pd | |
import collections | |
loansData = pd.read_csv( | |
'https://spark-public.s3.amazonaws.com/dataanalysis/loansData.csv' | |
) | |
loansData.dropna(inplace=True) | |
freq = collections.Counter(loansData['Open.CREDIT.Lines']) |
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
#!/usr/bin/python | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
import scipy.stats as stats | |
# read the data | |
loansData = pd.read_csv( | |
'https://spark-public.s3.amazonaws.com/dataanalysis/loansData.csv' | |
) |
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
propTypes: { | |
onClickItem: React.PropTypes.func.isRequired, | |
inputs: React.PropTypes.arrayOf( | |
React.PropTypes.shape({ | |
text: React.PropTypes.node | |
}) | |
) | |
}, | |
getDefaultProps(){ |
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
let ClickableList = React.createClass({ | |
render(){ | |
let { inputs, onClickItem } = this.props; | |
return ( | |
<ul> | |
{inputs.map((input,i)=> | |
<li key={i} onClick={onClickItem.bind(null, input)}> | |
{input} | |
</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
let MyForm = React.createClass({ | |
render(){ | |
return ( | |
<form onSubmit={this.handleSubmit}> | |
<input type="text" ref='my-input' /> | |
</form> | |
) | |
}, | |
handleSubmit(event){ | |
event.preventDefault() |
NewerOlder