Skip to content

Instantly share code, notes, and snippets.

@ReidWilliams
ReidWilliams / sign.html
Last active February 7, 2022 17:01
Skeleton for signing a message with Metamask
<html>
<body>
<script type="module">
// Use a simple local http server like 'python3 -m http.server'
// Needs to liston on port 8000
// Janky, but I use a local copy of the Ethers libray to avoid CORS headaches
// https://cdn.ethers.io/lib/ethers-5.2.esm.min.js
// Ethers docs:
// https://docs.ethers.io/v5/getting-started/
@ReidWilliams
ReidWilliams / regexp-point.txt
Created February 21, 2019 19:57
Regexp replace POINT(lat, long)
POINT \((-?\d+.\d+) (-?\d+.\d+)\)
$1,$2
@ReidWilliams
ReidWilliams / git.md
Last active December 12, 2018 17:51
Git cheatsheet

git checkout --track -b origin/

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

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

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 February 22, 2018 14:47
Pandas cheatsheet
# 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 January 30, 2018 21:39
Python: freeze and install packages
$ pip freeze > requirements.txt
$ pip install -r requirements.txt