Skip to content

Instantly share code, notes, and snippets.

View nwstephens's full-sized avatar

Nathan Stephens nwstephens

View GitHub Profile
docker pull rapidsai/staging:docker-raft-ann-bench-589-23.10a-cuda11.8-py3.9-amd64
export DATA_FOLDER=/home/rapids/benchmarks
docker run --gpus all --rm -it \
-v $DATA_FOLDER \
rapidsai/staging:docker-raft-ann-bench-589-23.10a-cuda11.8-py3.9-amd64 \
"--dataset sift-128-euclidean" \
"--normalize" \
"--algorithms raft_cagra" \
@nwstephens
nwstephens / self_described_digits.R
Last active March 28, 2023 23:27
Integers that describe their own digits
# Integers that describe their own digits
# Nathan Stephens
# 3/28/2023
###################
# Background
###################
# We seek numbers whose digits describe how many digits are in that same number
# For example, consider 42,101,000, which has 8 digits.
# We index those digits 0-7, and consider how many of each index are in the number.
@nwstephens
nwstephens / palendromic2.R
Created January 19, 2023 23:36
This code can calculate extremely large iterations (easily up to 100,000), because it separates digits into elements in a vector.
# Palendromic numbers
x<-196
i<-0
# Add elements together
g<-function(v){
v<-c(v%/%10,0)+c(0,v%%10)
if(v[1]==0) v[-1] else v
}
# Palindromic Numbers
# Nathan Stephens
# 1/18/2023
library(magrittr)
library(ggplot2)
# Reverse digits of an integer
f<-function(x){ x %>%
as.character %>%
@nwstephens
nwstephens / war.R
Created July 30, 2022 22:22
Simulate the card game "War" with R
g <- function(){
deck = rep(1:13, each=4)
deal <- sample(length(deck))
p1 <- deck[deal[1:26]]
p2 <- deck[deal[27:52]]
hands <- 1
wins <- matrix(NA, 0, 4)
while(length(p1) > 0 & length(p2) > 0){
hands <- hands + 1
wins <- rbind(wins, c(p1[1], p2[1], length(p1), length(p2)))
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nwstephens
nwstephens / perf_analyzer_issue.sh
Last active April 15, 2022 18:35
This script is adapted from https://github.com/nwstephens/triton-xgboost. It demonstrates an error when using the perf_analyzer between two containers in a docker network. The workaround is to use `--network host` instead of `--network=tritonnet`. For more information on the implications using the host network, see: https://docs.docker.com/netwo…
# Create docker network
sudo docker network create tritonnet
# Create shared volume for model_repository
sudo docker volume create volume1
# Pull and run Triton container
sudo docker pull nvcr.io/nvidia/tritonserver:22.03-py3
sudo docker run --gpus=all -d -p 8000:8000 -p 8001:8001 -p 8002:8002 --network=tritonnet \
-v /var/lib/docker/volumes/volume1/_data/model_repository:/models \
@nwstephens
nwstephens / rstudio-user-report.sh
Last active July 23, 2021 13:49
This script will output the AWS account ID, AWS region, and other user metrics for single node installations of RStudio Workbench running in AWS.
#!/bin/bash
METADATA=$(curl --silent http://169.254.169.254/latest/dynamic/instance-identity/document)
REGION=$(echo "$METADATA" | grep 'region' | cut -d : -f2 | awk -F\" '{print $2}')
ACCOUNTID=$(echo "$METADATA" | grep 'accountId' | cut -d : -f2 | awk -F\" '{print $2}')
METRICS=$(sqlite3 /var/lib/rstudio-server/rstudio.sqlite <<EOF
select \
total(CASE WHEN locked=0 and last_sign_in >= datetime('now', '-1 days') then 1 else 0 end) as DAU0,
total(CASE WHEN locked=0 and last_sign_in >= datetime('now', '-7 days') then 1 else 0 end) as WAU0,
@nwstephens
nwstephens / gist:813e3020d455667056e6638ebe8d5185
Last active April 3, 2021 05:58
Configure a Shiny app to read encrypted passwords in build and run environments
#
# This is a Shiny web application. You can run the application by clicking
# the 'Run App' button above.
#
# Find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com/
#
# Set the keyring backend to file and initialize the system keyring:
@nwstephens
nwstephens / gist:255be56b99f1700acfd7a7f8b69da103
Last active April 3, 2021 05:57
Storing secrets with R. Using the keyring package you can stole encrypted secrets on disk or store them as environment variables in memory.
library(keyring)
options("keyring_backend" = "file") # set this in .Rprofile for convenience
### Store secrets encrypted at rest
keyring_create("kr")
key_set("foobar", keyring = "kr")
key_get("foobar", keyring = "kr")
### Store multiple secrets