Skip to content

Instantly share code, notes, and snippets.

View cbare's full-sized avatar
👹
¯\_(ツ)_/¯

Christopher Bare cbare

👹
¯\_(ツ)_/¯
View GitHub Profile
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'
@cbare
cbare / Dockerfile
Created October 9, 2016 20:39
Dockerfile for Octave on Ubuntu 16.04
FROM ubuntu:16.04
RUN apt-get update && apt-get install -y less && apt-get install -y octave
VOLUME ["/source"]
WORKDIR /source
CMD octave
@cbare
cbare / download_pilot_images.py
Created June 28, 2016 20:01
Download pilot images for the DM Challenge from an S3 bucket
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
@cbare
cbare / sample_from_density.R
Created June 8, 2016 21:47
Sample from an estimated probability density in 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)
}
@cbare
cbare / Directionality_of_mPower_features.Rmd
Created June 8, 2016 00:05
Assess the 4 selected features for the mPower dashboard, committing some fun R data geekery in the process
---
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)
@cbare
cbare / spam_synapse.py
Created June 3, 2016 21:49
An example of accessing Synapse from AWS Lambda
"""
=======================================================
How to access Synapse from Amazon Lambda with Python
=======================================================
Here we show an example of adding a row to a Synapse table
through an AWS Lambda script.
Caveat: Any operation that requires chunked file upload
fails on AWS Lambda. The execution environment for
@cbare
cbare / combine_features.py
Created February 15, 2016 17:43
Take individual feature .csv files from mhealthx and output a combined feature table
"""
Combine feature extraction output .csv files
"""
import csv
import os
dir = "/home/ubuntu/mhealthx_output/feature_tables/voice_openSMILE-2.2rc1_gemaps"
data=[]
for filename in os.listdir(dir):
print filename
@cbare
cbare / messages.py
Created January 26, 2016 00:42
A new version of message templates for challenge scoring which create HTML formatted message bodies.
## Messages for challenge scoring script.
import string
import sys
import warnings
## Module level state. You'll need to set a synapse object at least
## before using this module.
syn = None
############################################################
##
## Create EC2 Machines
##
## Start up EC2 instances for each member of a Synapse
## team, emailing them the details of their assigned
## machine.
##
## chris.bare@sagebase.org, November 2015
##
import json
import pandas as pd
import matplotlib.pyplot as plt
import synapseclient
from collections import OrderedDict
syn = synapseclient.Synapse()
syn.login()