Skip to content

Instantly share code, notes, and snippets.

@briandconnelly
briandconnelly / README.md
Last active November 13, 2021 23:56
Send a push notification with a message and a ggplot2 object

Send a push notification with a message and a ggplot2 object

ggpushover() allows you to send a push notification to your device that contains a message and a ggplot2 object as an image.

Prerequisites

You will need to have the pushoverr and ggplot2 packages installed. To do this, run:

install.packages(c("pushoverr", "ggplot2"))
@briandconnelly
briandconnelly / telegraf-speedtest.conf
Last active November 7, 2019 01:00
Periodic Speedtest with Telegraf
# Run a speedtest every 60 minutes using Speedtest CLI - https://www.speedtest.net/apps/cli
# WARNING! You may want to change the interval if your ISP enforces data usage limits.
[[inputs.exec]]
interval = "60m"
timeout = "1m"
commands = ["/speedtest -f json"]
name_override = "speedtest"
data_format = "json"
@briandconnelly
briandconnelly / kable_jira.R
Created May 2, 2018 23:21
Format an R dataframe for pasting into a Jira ticket
kable_jira <- function(x, ...) {
# Ideal solution would be to use knitr:::kable_mark, but...
res <- knitr::kable(x = x, format = "markdown", ...)
res[[1]] <- stringr::str_replace_all(
string = res[[1]],
pattern = "\\|",
replacement = "\\|\\|"
)
# Remove the second line
@briandconnelly
briandconnelly / airflow
Last active March 21, 2018 19:20 — forked from theotheo/airflow
Basic Bash completion for Airflow
_airflow()
{
local cur prev opts base
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
# echo $prev

Keybase proof

I hereby claim:

  • I am briandconnelly on github.
  • I am briandconnelly (https://keybase.io/briandconnelly) on keybase.
  • I have a public key ASD3Tx_Myw9ishMbW2Ujks39hyf3ln8mbpGdOWb_04KDiwo

To claim this, I am signing this object:

@briandconnelly
briandconnelly / nse_sample.R
Last active March 31, 2016 00:48
Problems with NSE and lazyeval
get_column_ <- function(.data, colname) {
lazyeval::lazy_eval(colname, .data)
}
get_column <- function(.data, col) {
# Adding .data as the env argument to lazy() is also not working
get_column_(.data=.data, colname=lazyeval::lazy(col))
}
mydata <- data.frame(time = c(1,2,3), value = rnorm(3))
@briandconnelly
briandconnelly / PETrawdata.csv
Last active March 28, 2016 20:28
Analyzing growth curves
We can't make this file beautiful and searchable because it's too large.
Time,Temperature,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,B1,B2,B3,B4,B5,B6,B7,B8,B9,B10,B11,B12,C1,C2,C3,C4,C5,C6,C7,C8,C9,C10,C11,C12,D1,D2,D3,D4,D5,D6,D7,D8,D9,D10,D11,D12,E1,E2,E3,E4,E5,E6,E7,E8,E9,E10,E11,E12,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,G1,G2,G3,G4,G5,G6,G7,G8,G9,G10,G11,G12,H1,H2,H3,H4,H5,H6,H7,H8,H9,H10,H11,H12
0,35.5,0.0754,0.0751,0.0744,0.0724,0.0703,0.0724,0.0633,0.0726,0.0679,0.0708,0.0713,0.0677,0.0679,0.0993,0.098,0.0878,0.0845,0.0861,0.0741,0.0845,0.0788,0.081,0.0849,0.0734,0.0621,0.0856,0.0893,0.0899,0.0869,0.0891,0.0728,0.0935,0.0809,0.0857,0.0896,0.0836,0.0697,0.0869,0.0898,0.0939,0.0892,0.0898,0.0877,0.0943,0.1091,0.091,0.0917,0.0681,0.0635,0.0849,0.0871,0.0896,0.0864,0.0872,0.0769,0.0894,0.0879,0.0939,0.0964,0.0809,0.0658,0.0838,0.0857,0.0862,0.0845,0.0891,0.0824,0.0878,0.0932,0.0879,0.0905,0.0644,0.062,0.0851,0.0854,0.0843,0.0846,0.0854,0.073,0.0859,0.0817,0.085,0.0858,0.0669,0.068,0.0699,0.0701,0.0728,0.0698,0.0726,0.0593,0.0725,0.0683,0.0703,0.0718,0.0663
90,37.5,0.0739,0.071,0.
@briandconnelly
briandconnelly / graph_properties.R
Last active October 2, 2015 18:09
Exploring Graph Structure with igraph
# You'll need igraph. If you don't have it, run install.packages("igraph")
library(igraph)
# First load the function moore_lattice_2d()
bulky <- moore_lattice_2d(rows=100, columns=100)
slender <- moore_lattice_2d(rows=4, columns=2500)
# Other generators: sample_k_regular, make_ring, sample_smallworld, etc...
@briandconnelly
briandconnelly / what_varies.r
Last active August 29, 2015 14:16
Get the names of columns that have >1 unique values in an R data frame
what_varies <- function(d)
{
varies <- function(x) nrow(unique(d[x])) > 1
return(names(d)[unlist(lapply(seq_len(ncol(d)), varies))])
}
@briandconnelly
briandconnelly / setup_rstudio.sh
Last active April 13, 2021 21:46
Setup RStudio Server on a Google Compute Engine Instance (Debian)
#!/bin/bash
# Install RStudio Server on a Google Compute Engine instance running Debian
# Wheezy
CRAN_MIRROR='cran.rstudio.com'
pushd /tmp
# Install up-to-date version of R ---------------------------------------------