Skip to content

Instantly share code, notes, and snippets.

View gadenbuie's full-sized avatar

Garrick Aden-Buie gadenbuie

View GitHub Profile
@gadenbuie
gadenbuie / usf-beamer-template.tex
Last active December 22, 2015 16:29
A USF College of Engineering Beamer Theme + Template Slides + Conference Presentation Framework
% University of South Florida College of Engineering Beamer Template
% Garrick Aden-Buie
% Send comments/beers to: [email protected]
% Example presentation:
% http://garrickadenbuie.com/wp-content/uploads/2013/09/usf-beamer-example.pdf
% IMPORTANT:
% If you want to use the USF logo, make sure you
% download the USF College of Engineering logo from:
@gadenbuie
gadenbuie / server.R
Last active January 4, 2016 19:59
Simple Linear First-Order Difference Equations for Cobweb Model (Shiny App)
library(shiny)
# s(k) = s(0) + b*p(k-1)
# d(k) = d(0) - a*p(k)
# p(k) = -b/a*p(k-1) + (d0-s0)/a
cobweb = function(params){
# Create data frame of prices, and supply and demand stocks
s0 = params[1]
@gadenbuie
gadenbuie / md2beamer.sh
Created February 19, 2014 17:42
A simple USF color pandoc-beamer template
#!/bin/bash
# Requires: pandoc -- http://johnmacfarlane.net/pandoc/
# Usage: ./md2beamer.sh Content.md ==> Content.pdf (beamer presentation)
name=`echo $1 | cut -f1 -d'.'`
pandoc $1 -o $name.pdf -t beamer --template=usf_simple.beamer --latex-engine=xelatex --highlight-style=tango
@gadenbuie
gadenbuie / coffeeCream_functions.R
Last active August 29, 2015 13:57
Coffee and Cream Problem Simulation
# T.room # Temperature of the room
# T.coffee # Initial temperature of the coffee
# T.cream # Temperature of the cream
# k # Cooling rate constant
# T.d # Desired coffee temperature
temp <- function(T.init, T.room, k, x){
# Newton's cooling law temperature function
return(T.room + (T.init - T.room)*exp(-k*x))
}
@gadenbuie
gadenbuie / getCiteCounts.R
Last active November 1, 2015 05:24
Look up citation counts with rcrossref
getCiteCounts <- function(citekeys, bibtex){
## This function takes a list of citation keys, for ex. from lit review notes
## and a master bibtex file with citekeys and DOIs
## Returns a vector of number of times each article was cited from CrossRef
# Check for and load/install required packages
# --> stringr, rcrossref
if (!'stringr' %in% installed.packages()) install.packages('stringr')
require(stringr, quietly=TRUE)
@gadenbuie
gadenbuie / install-lnav.sh
Created November 13, 2015 16:56
Install lnav from GitHub source
#! /bin/bash
clone-lnav() {
echo "Downloading lnav..."
cd ~/Downloads
hash git &> /dev/null
if [ $? -eq 1 ]; then
sudo apt-get install git
fi
if [ $? -eq 0 ]; then
@gadenbuie
gadenbuie / server.R
Created September 1, 2016 15:17 — forked from daattali/server.R
Encrypt password with md5 for Shiny-app.
library(shiny)
library(datasets)
Logged = FALSE;
PASSWORD <- data.frame(Brukernavn = "withr", Passord = "25d55ad283aa400af464c76d713c07ad")
# Define server logic required to summarize and view the selected dataset
shinyServer(function(input, output) {
source("www/Login.R", local = TRUE)
observe({
@gadenbuie
gadenbuie / backstitch.R
Last active August 14, 2019 16:41
Convert Rmd document (knitr::knit) to an R script (knitr::spin) #RMarkdown #knitr #knit #spin
warning("You probably don't want to use this `backstitch()` function.",
"\n It's hacky and there's a much better option in knitr called `purl()`.",
"\n More info at: `?knitr::purl`")
#' Backstitch an Rmd file to an R script
#'
#' Takes an Rmd file -- that would be converted with knitr::knit() -- and
#' "backstitches" it into an R script suitable for knitr::purl(). The output
#' file is the just the backstitched R script when `output_type = 'script'`, or
#' just the code chunks when `output_type = 'code'` (note that all inline code
reprex::reprex({
library(purrr)
l1 <- list(a = list(a1 = 1:10))
l2 <- list(a = list(a2 = 10:20))
list_merge(l1, l2)
#' But both `l1` and `l2` are named... so arguments should be named?
list_merge(x = l1, y = l2)
#' Oh, l2 is implicitly unnamed because it's in dots
list_merge(l1, y = l2)
#' But what I *really* wanted was this
reprex::reprex({
library(purrr)
l1 <- list(a = list(a1 = 1:10))
l2 <- list(a = list(a2 = 10:20))
list_merge(l1, l2)
#' But both `l1` and `l2` are named... so arguments should be named?
list_merge(x = l1, y = l2)
#' Oh, l2 is implicitly unnamed because it's in dots
list_merge(l1, y = l2)
#' But what I *really* wanted was this