Skip to content

Instantly share code, notes, and snippets.

View nelsonauner's full-sized avatar
🔬

Nelson Auner nelsonauner

🔬
View GitHub Profile
@nelsonauner
nelsonauner / data_viz_overview.markdown
Created July 24, 2018 18:06
Overview of Data Visualization Solutions - 2018 H2
Name Author Cost Language Details
Quicksight Amazon Cheap SQL Difficult to use
RShiny R Studio Free R / SQL Requires some R knowledge
Looker Looker $$ SQL All dashboards version controlled in git
Superset Airbnb/Open Source Free SQL
@nelsonauner
nelsonauner / set_up_dual_monitor_linux.sh
Last active April 26, 2018 15:33
set_up_dual_monitor_linux.sh
# [vertical screen DP-2] - [horizontal screen DP-3]
xrandr --auto --output DP-2 --left-of DP-3
xrandr --output DP-2 --rotate left
sudo apt-get update
sudo apt-get -y install nginx
sudo sh -c 'echo "deb http://cran.rstudio.com/bin/linux/ubuntu trusty/" >> /etc/apt/sources.list'
gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9
gpg -a --export E084DAB9 | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install r-base
sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
sudo /sbin/mkswap /var/swap.1
sudo /sbin/swapon /var/swap.1
@nelsonauner
nelsonauner / copied_to_gmail.html
Created January 21, 2016 23:18
Showing how gmail inlines CSS
<!-- open example.html in chrome, select all, copy, paste into email. Send email to self, view email code: -->
<div dir=3D"ltr"><div id=3D"header" style=3D"color:rgb(51,51,51);font-famil=
y:&#39;Helvetica Neue&#39;,Helvetica,Arial,sans-serif;font-size:14px;line-h=
eight:20px"><h1 class=3D"" style=3D"margin:20px 0px 10px;font-size:36px;fon=
t-family:inherit;font-weight:500;line-height:1.1;color:inherit">Report for =
email</h1></div><p style=3D"margin:0px 0px 10px;color:rgb(51,51,51);font-fa=
mily:&#39;Helvetica Neue&#39;,Helvetica,Arial,sans-serif;font-size:14px;lin=
e-height:20px"><em>A more complicated markdown file</em></p><pre class=3D""=
@nelsonauner
nelsonauner / loadjQuery.js
Created October 14, 2015 19:27
load jquery inside any window
//adapted from http://stackoverflow.com/questions/5256583/run-my-own-script-inside-chromes-debugger-console
s = document.createElement('script');
s.src = 'https://code.jquery.com/jquery-2.1.4.min.js';
document.body.appendChild(s)
@nelsonauner
nelsonauner / rmNA.R
Last active September 9, 2015 05:19
Remove NAs only from certain columns with regex
#joinedData is dataframe
# has names(joinedData) > c("BLAH","BLEH","BLUCH","2015-05","2015-06",...)
# want to replce NAs with 0s for date columns
r <- "\\d{4}.\\d{2}"
x <- joinedData[grep(r,names(joinedData))]
x[is.na(x)] <- 0
@nelsonauner
nelsonauner / ShowTable.R
Last active August 29, 2015 14:26
Transition probabilies: generating and displaying
#############################################
# Actual solution ##################
#############################################
library(dplyr)
combined <- left_join(users,usersday2,by="id")
table(combined$finst.x,combined$finst.y)[c("check","save","both"),c("check","save","both", "none")]
# check save both none
# check 415 43 215 37
@nelsonauner
nelsonauner / setupShiny.sh
Created June 26, 2015 21:33
set up shiny server from dean attali's blog
sudo apt-get update
sudo apt-get install nginx -y
sudo service nginx start
sudo sh -c 'echo "deb http://cran.rstudio.com/bin/linux/ubuntu trusty/" >> /etc/apt/sources.list'
gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9
gpg -a --export E084DAB9 | sudo apt-key add -
sudo apt-get update
sudo apt-get install r-base -y
sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
@nelsonauner
nelsonauner / .ls.objects
Created April 9, 2015 15:28
Dirks' memory management function
#from http://stackoverflow.com/questions/1358003/tricks-to-manage-the-available-memory-in-an-r-session
# improved list of objects
.ls.objects <- function (pos = 1, pattern, order.by,
decreasing=FALSE, head=FALSE, n=5) {
napply <- function(names, fn) sapply(names, function(x)
fn(get(x, pos = pos)))
names <- ls(pos = pos, pattern = pattern)
obj.class <- napply(names, function(x) as.character(class(x))[1])
obj.mode <- napply(names, mode)
@nelsonauner
nelsonauner / gist:0e5d623f6f6edabc0bb2
Created January 24, 2015 15:42
mosquitos and beer simulation
# Simulatation inference for the results of "Alcohol ingestion stimulates mosquito attraction" by O Shirai (2002)
# study url: http://www.ncbi.nlm.nih.gov/pubmed/12083361
# this gist based off (excellent) presentation by John Rauser at the Strata + Hadoop 2014 conference
# watch the presentation at https://www.youtube.com/watch?v=5Dnw46eC-0o
library(magrittr) # Ceci n'est pas un pipe
data = "27 21 20 22 21 15 26 12 27 21 31 16 24 19 19 15 23 24 24 19 28 23 19 13 24 22 29 20 20 24 17 18 31 20 20 22 25 28 21 27 21 18 20"
numbers <-