Skip to content

Instantly share code, notes, and snippets.

@dewittpe
dewittpe / process.sh
Created January 19, 2022 00:15
Convert a large set of raw image files into a pdf for easy printing
#!/bin/bash
# requires imagemagick
#########################################################
# Unzip a large set of NEF, JEPG, and other image files #
# resize and convert to pdf for easy printing #
#########################################################
# unzip the compressed zip achieves
for i in *.zip;
@dewittpe
dewittpe / circles-and-polygons.R
Last active September 23, 2020 19:15
inscribed circles and regular polygons
# objective - plot circles and polygons such that
# 0. A circle
# 1. An equilateral triangle such that the edges are tangent to the circle
# 2. A circle such that the vertices of the triangle are on the circumference
# 3. A square with edges tangent to the circle drown in step 2.
# 4. A circle with the vertices of the square on the circumference
# 5. A regular pentagon....
#
# A vertex of the regular polygons will all be co-linear. That is, with the
# initial circle centered at the Cartesian point (0, 0), then on vertex for each
@dewittpe
dewittpe / padovan.R
Created September 30, 2019 16:57
Padovan Sequence and sierpinski trianagles
library(ggplot2)
library(magrittr)
library(parallel)
# Padovan Sequence
# 1, 1, 1, 2, 2, 3, 4, ...
padovan <- function(n) {
n <- floor(n)
if (n <= 3) stop("n needs to be an integer greater than 3")
@dewittpe
dewittpe / ssh-setup.sh
Created March 19, 2018 20:49
Script to quickly setup ssh keys on remote machines
#!/bin/bash
HOST=git.neptuneinc.org
REMOTEUSER=pdewitt
KEY=/home/$USER/.ssh/id_rsa.pub
ssh -l $REMOTEUSER $HOST mkdir -p .ssh
cat $KEY | ssh -l $REMOTEUSER $HOST 'cat >> .ssh/authorized_keys'
ssh -l $REMOTEUSER $HOST "chmod 700 .ssh; chmod 640 .ssh/authorized_keys"
@dewittpe
dewittpe / my_extractor.R
Last active October 27, 2017 17:20
Custom extractor function
# my_extractor.R
#
# Given an M dimensional array, extract the last index based on prescribed
# values of the first M-1 values.
#
# For example, for a 3D array with indices [x, y, z] write a function that will
# extract z as function of x and y.
set.seed(42)
@dewittpe
dewittpe / Data.csv
Created May 23, 2017 16:50
data-for-so44096820
date value
1995-01-01 100
1995-02-01 98.9
1995-03-01 97.8
1995-04-01 97.9
1995-05-01 98.2
1995-06-01 104.4
1995-07-01 101.1
1995-08-01 101.9
1995-09-01 103.3
@dewittpe
dewittpe / README.md
Last active April 14, 2017 03:08
icd_explorations

ICD Exploration

Exploring the ICD codes between the icd package and the pccc package.

In general there are R scripts which are used to produce .md files via knitr::spin()

@dewittpe
dewittpe / build-script.R
Last active November 28, 2021 15:47
Equation Numbering in Rmd
library(rmarkdown)
library(knitr)
render("eqn-numbering.Rmd")
@dewittpe
dewittpe / select_cols.R
Created September 13, 2015 03:48
Regular expressions for selecting columns to read into R via `readr::read_delim`
# Example using regular expressions and setting col_types for use with
# readr::read_delim
# function select_cols
# args:
# clnms a character vector of column names
# rexprs a character vector of regular expressions to search clnms for. These
# rexprs select the columns form the .csv
# types a character vector of "l", "i", "d", "c" for logical, integer,
# double, and character. see documentation for readr for more detail
@dewittpe
dewittpe / random-number-images.R
Created June 15, 2015 22:29
Random Number Generator Graphics
# ---------------------------------------------------------------------------- #
# file: random-number-images.R
# author: Peter DeWitt
#
# inspired by the work presented at http://boallen.com/random-numbers.html
# this file generates several images based on random number generators in R
# ---------------------------------------------------------------------------- #
# ---------------------------------------------------------------------------- #
# libraries
# ---------------------------------------------------------------------------- #