Skip to content

Instantly share code, notes, and snippets.

@colearendt
colearendt / netshoot.yaml
Created April 4, 2022 20:22
Easy yaml resources to deploy to Kubernetes
# beware... these sleep intervals can be horrible to tearing down the pods
apiVersion: v1
kind: ReplicationController
metadata:
name: netshoot
spec:
replicas: 1
selector:
name: netshoot
template:
@colearendt
colearendt / README.md
Last active July 29, 2021 09:14
Generate a user-generation script

Generate User Creation

Sometimes it is nice to have a simple way to "reproduce users" on a system

i.e. my server is connected to LDAP and has users / groups defined. I want to be able to create the same UIDs/GIDs without joining to the LDAP server.

This script is designed to help.

  • Run it on the server where users are defined.
  • It loops through users, code-generating a shell script that can "recreate" those users with proper UID/GID
@colearendt
colearendt / script.R
Created January 14, 2021 01:35
Build Connect Programmatically
library(connectapi)
# TODO: use a real password. This user will _actually_ get created on your instance
# you can delete the user afterwards using the Connect usermanager CLI if you want
client <- connectapi:::create_first_admin("http://localhost:55011", "admin", "admin0", "admin@example.com", provider = "password")
# a directory with a manifest.json
bnd <- bundle_dir("./tests/testthat/examples/static")
content1 <- client %>%
@colearendt
colearendt / email-20191209.Rmd
Created December 9, 2019 23:02
blastula/gt reprex 20191209
---
output: blastula::blastula_email
---
```{r email_setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
report_url <- Sys.getenv("RSC_REPORT_URL")
```
## Test Email
@colearendt
colearendt / lazy-explore.R
Created March 18, 2019 02:20
Exploring dbplyr
# create database connection
con <- dbConnect(...)
# define tbl object
mytbl <- tbl(con, "table")
# dbplyr:::tbl_sql
# -> op_base_remote
# --> get list of var names (by doing a quick query)
# --> op_base
@colearendt
colearendt / config.yml
Created February 4, 2019 02:31
Example functions and configuration files for using the config package to simplify connecting to a database
default:
gis:
drv: !expr RPostgres::Postgres()
db: mydatabase
port: 5432
host: somehost.dev.example.com
prod:
gis:
drv: !expr RPostgres::Postgres()
db: proddb
@colearendt
colearendt / exploration.md
Last active December 5, 2018 03:53
async processes to speed up database logging

Is async in R always the right answer?

I have a database logging operation that takes about 1/3s - 1/2s. I do lots of these logging operations. I do enough of them that I am worried it could be a bottleneck in whether my app has a snappy feel to it.

bench::mark(log_event(con, schema=schema, prefix = prefix, event = "benchmark", session = "session"))
# # A tibble: 1 x 14
#   expression   min  mean median   max `itr/sec` mem_alloc  n_gc n_itr total_time result memory time 
#   <chr>      <bch> <bch> <bch:> <bch>     <dbl> <bch:byt> <dbl> <int>   <bch:tm> <list> <list> <lis>
# 1 "log_even… 376ms 379ms 379ms 382ms 2.64 44.5KB 0 2 758ms 
@colearendt
colearendt / keybase.md
Created July 11, 2018 17:46
Prove my identity on keybase

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@colearendt
colearendt / airplane-report.Rmd
Last active March 28, 2018 20:11
RMarkdown Examples
---
title: "airplanes"
params:
carrier: AA
output:
html_document:
df_print: paged
---
```{r setup, include=FALSE}