Skip to content

Instantly share code, notes, and snippets.

Reid Williams ReidWilliams

Block or report user

Report or block ReidWilliams

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ReidWilliams
ReidWilliams / regexp-point.txt
Created Feb 21, 2019
Regexp replace POINT(lat, long)
View regexp-point.txt
POINT \((-?\d+.\d+) (-?\d+.\d+)\)
$1,$2
@ReidWilliams
ReidWilliams / git.md
Last active Dec 12, 2018
Git cheatsheet
View git.md

git checkout --track -b <local branch> origin/<tracked branch>

@ReidWilliams
ReidWilliams / container.js
Last active Nov 21, 2018
React Container Pattern Template
View container.js
import React from 'react'
const createContainer = (ComposedComponent) => {
class Container extends React.Component {
render() {
const componentProps = {
...this.props
}
return (
@ReidWilliams
ReidWilliams / component.story.js
Created Nov 20, 2018
Storybook story template
View component.story.js
// 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'
@ReidWilliams
ReidWilliams / component.js
Last active Nov 21, 2018
React + styled-components template
View component.js
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 {
View rsync-cheatsheet.md

rsync -avh source/ destination

-a, archive (recursive and preserve everything about the file)
-v, verbose
-h, human readable sizes

Also useful:
-n, dry run
-z, compress
--delete, delete files that don't exist on the source side

View gist:20cfdeb1dd4d90201b24d40a3e5a181d
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.
@ReidWilliams
ReidWilliams / pandas.txt
Last active Feb 22, 2018
Pandas cheatsheet
View pandas.txt
# 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'))
@ReidWilliams
ReidWilliams / freeze-install.txt
Created Jan 30, 2018
Python: freeze and install packages
View freeze-install.txt
$ pip freeze > requirements.txt
$ pip install -r requirements.txt
@ReidWilliams
ReidWilliams / anaconda.txt
Created Dec 15, 2017
Anaconda cheatsheet
View anaconda.txt
# create environment with jupyter
conda create -n ENVNAME python=3 jupyter
You can’t perform that action at this time.