Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Solving Cyber Risk

Nelson Auner nelsonauner

🎯
Solving Cyber Risk
View GitHub Profile
@nelsonauner
nelsonauner / data_viz_overview.markdown
Created Jul 24, 2018
Overview of Data Visualization Solutions - 2018 H2
View data_viz_overview.markdown
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 Apr 26, 2018
set_up_dual_monitor_linux.sh
View 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
View install_shiny.sh
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 Jan 21, 2016
Showing how gmail inlines CSS
View copied_to_gmail.html
<!-- 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 Oct 14, 2015
load jquery inside any window
View loadjQuery.js
//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 Sep 9, 2015
Remove NAs only from certain columns with regex
View rmNA.R
#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 Aug 29, 2015
Transition probabilies: generating and displaying
View ShowTable.R
#############################################
# 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 Jun 26, 2015
set up shiny server from dean attali's blog
View setupShiny.sh
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 Apr 9, 2015
Dirks' memory management function
View .ls.objects
#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 Jan 24, 2015
mosquitos and beer simulation
View gist:0e5d623f6f6edabc0bb2
# 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 <-
You can’t perform that action at this time.