Instantly share code, notes, and snippets.

View speakers.py
"""
Reformat the output of Amazon Transcribe
usage: python3 speakers.py asrOutput.json
"""
import json
import sys
# read in the JSON output of Amazon Transcribe
with open(sys.argv[1]) as f:
View external-review-counts.R
library('RPostgreSQL')
library('dplyr')
library('lubridate')
library('tidyr')
# Get external reviews with UTC timestamps from the DB
# \copy (select distinct o.observation_id, o.collection_date, o.vendor_id, v.name, reviewed_at_utc, reviewed_by from ops.review r join analysis.observation o on r.observation_id=o.observation_id join analysis.vendor v on o.vendor_id=v.vendor_id where reviewed_at_utc >= '2017-05-01' order by reviewed_at_utc) TO '/Users/cbare/Desktop/external-reviews.tsv' WITH NULL AS '';
# df <- read.table('/Users/cbare/Desktop/external-reviews.tsv', stringsAsFactors=F)
# get data via a query
View type_check_me.py
"""
This is a bit of Python code with type annotations.
To type check this code with [mypy](http://mypy-lang.org/) like this:
mypy mypy/type_check_me.py
"""
from typing import List, TypeVar, Optional, Sequence
def gcd(a: int, b: int) -> int:
View external-review-counts-by-state.R
# compile stats on external clinical reviews
library('RPostgreSQL')
library('dplyr')
library('lubridate')
library('tidyr')
# Get external reviews with UTC timestamps from the DB
# \copy (select distinct o.observation_id, o.collection_date, o.vendor_id, v.name, reviewed_at_utc, reviewed_by from ops.review r join analysis.observation o on r.observation_id=o.observation_id join analysis.vendor v on o.vendor_id=v.vendor_id where reviewed_at_utc >= '2017-05-01' order by reviewed_at_utc) TO '/Users/cbare/Desktop/external-reviews.tsv' WITH NULL AS '';
# get a table of addresses from user-management
View .gitconfig
[alias]
gr = log --graph --full-history --all --color \n --pretty=tformat:\"%x1b[31m%h%x09%x1b[32m%d%x1b[0m%x20%s%x20%x1b[33m(%an)%x1b[0m\"
plog = log --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit -n 20
ls = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate
ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
cdiff = diff --cached
branches = branch --list -vva --color
remotes = remote --verbose
[color]
ui = auto
View .bashrc
PATH=/Users/CBare/bin:$PATH
export CLICOLOR=1
export LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx
alias ls='ls -alph'
alias path='echo -e ${PATH//:/\\n}'
alias libpath='echo -e ${LD_LIBRARY_PATH//:/\\n}'
alias du='du -kh'
alias df='df -kh'
View Dockerfile
FROM ubuntu:16.04
RUN apt-get update && apt-get install -y less && apt-get install -y octave
VOLUME ["/source"]
WORKDIR /source
CMD octave
View download_pilot_images.py
import os
from boto.s3.connection import S3Connection
from boto.s3.connection import OrdinaryCallingFormat
## retrieve AWS credentials from environment variables
aws_key = os.getenv('AWS_KEY_ID')
aws_secret = os.getenv('AWS_SECRET_KEY')
## Ordinary calling format necessary because of dots in
## bucket name. See: https://github.com/boto/boto/issues/2836
View sample_from_density.R
## Sample from an estimated probability density
sample.density <- function(dd, size, jitter=FALSE) {
x <- sample(dd$x, size=size, prob=dd$y, replace=TRUE)
if (dd$n < 2) jitter=FALSE
if (jitter) {
w <- mean(dd$x[2:length(dd$x)] - dd$x[1:(length(dd$x)-1)]) / 2.0
x <- x + runif(size,-w,w)
}
return(x)
}
View Directionality_of_mPower_features.Rmd
---
title: "Directionality of mPower features"
author: "J. Christopher Bare"
date: "June 6, 2016"
---
```{r imports, echo=FALSE, message=FALSE, warning=FALSE}
library(synapseClient)
library(ggplot2)
library(scales)