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
// Uses underscore.js to wrap a function and upon calling | |
// prints the function source and the argument. | |
// Useful for debugging chains of promises. | |
// USAGE | |
// var myfunction = function(argument) {...}; | |
// myfunction = inspect(myfunction); // myfunction is now instrumented | |
var _ = require('underscore'); | |
var util = require('util'); | |
var inspect = function(fnToInspect) { |
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
kill -9 $(ps -ef | grep '[n]ode --debug-brk=5858' | awk '{print $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
while true; do rsync -e "ssh -i /PATH/TO/PRIVATE/KEY.pem" -azvh --delete ./LOCAL-REPO/ ec2-user@IP:/REMOTE/PATH; sleep 2; done |
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
# Easy way to remotely access a Jupyter notebook, by forwarding a port | |
# Forward local port 8888 to the remote's localhost port 8888 | |
ssh -L 8888:localhost:8888 user@10.2.2.99 |
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
# create environment with jupyter | |
conda create -n ENVNAME python=3 jupyter |
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
$ pip freeze > requirements.txt | |
$ pip install -r requirements.txt |
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
# rename a dataframe column | |
dataframe = dataframe.rename(index=str, columns={'old_col_name': 'new_col_name'}) | |
# get all possible values for a string / categorical column | |
dataframe[column].value_counts(dropna=False) | |
# group data and count number of rows in a group | |
grouped = dataframe.groupby(color) | |
nreds = len(grouped.get_group('red')) |
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 estimate(self, X): | |
""" Use saved model to predict/estimate retention probability. | |
Arguments: | |
X (dict): dictionary of features, values. | |
Automatically uses model trained on same set of features as | |
X argument. | |
Returns: | |
List of one element, retention probability. |
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
// Dependencies | |
import React from 'react' | |
import { storiesOf } from '@storybook/react' | |
import centered from '@storybook/addon-centered' | |
import { action } from '@storybook/addon-actions' | |
// Local Dependencies | |
import { ComponentDecorator } from 'stories/decorators' | |
import MyComponent from './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
import React from 'react' | |
import PropTypes from 'prop-types' | |
import styled from 'styled-components' | |
// locals | |
// import { theme } from 'styles' | |
const Root = styled.div`` | |
class MyComponent extends React.Component { |
OlderNewer