Skip to content

Instantly share code, notes, and snippets.

View homerhanumat's full-sized avatar

Homer White homerhanumat

  • Georgetown College
  • Kentucky, USA
View GitHub Profile
@homerhanumat
homerhanumat / custom.js
Created July 3, 2020 14:27
Solution to Sample JavaScript in the Browser Assignment: Random Content. Note: no css supplied in this gist.
/********************************************************************
*
* Script to insert random Youtube embed into index.html
*
*******************************************************************/
// The array of objects, one object for each artist.
const artists = [
{
@homerhanumat
homerhanumat / sse.R
Created April 12, 2018 18:52
ggplot illustration for k. kendall
library(tidyverse)
xVals <- function(n, center, width) {
seq(from = center - width, to = center + width, length.out = n)
}
width <- 0.3
survey <- tigerstats::m111survey
gms <-
survey %>%
group_by(seat) %>%
@homerhanumat
homerhanumat / suggestion.R
Created March 8, 2018 18:31
Suggestion for Celeste
## Experiment with the constants below (e.g., the 5, 25, 8, etc.) so see if you can get the effect you want.
## Note that wrapping the loop in turtle_do makes it run a good bit faster
## Also think about what you can do to keep the turtle tracing over itself when it repeats 50 drips
library(TurtleGraphics)
turtle_drip_pollack<-function(n=50){
turtle_init(75,75, mode = "clip")
repeat {
for( i in 1:n){
turtle_do({
@homerhanumat
homerhanumat / .block
Last active March 3, 2018 18:06
R^2 Illustration
license: MIT
height: 1000
@homerhanumat
homerhanumat / runge_kutta_system.R
Created February 27, 2018 18:18
Runge-Kutta for a system of DEs
initz <- c(5,10,0,10)
mySystem <- list(
dz1 = function(t,zs) zs[2],
dz2 = function(t,zs) zs[1]^2+zs[3]+2*zs[4]+2*t,
dz3 = function(t,zs) zs[4],
dz4 = function(t,zs) zs[1]+zs[2]+3*zs[3]^2+5*t
)
rungeKutta <- function(t0,z0,t1,steps,fns) {
h <- (t1-t0)/steps
@homerhanumat
homerhanumat / .block
Last active February 26, 2018 11:39
Regression to the Mean
license: MIT
height: 1000
border: no
@homerhanumat
homerhanumat / runge_kutta.R
Created February 6, 2018 21:27
Runge-Kutta in R
# x is xo, y is y0, x1 is x-value for which you want y, n is number of steps,
# f is the function f in the DE dy/dx = f(f,)
rungeKutta <- function(x, y, x1, n, f) {
h <- (x1 - x) / n
X <- numeric(n + 1)
Y <- numeric(n + 1)
X[1] <- x
Y[1] <- y
for ( i in 1:n ) {
xhalf <- x + 0.5 * h
@homerhanumat
homerhanumat / app.R
Last active February 1, 2021 03:08
Shiny dashboard with yellow sidebar
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(),
tags$head(tags$style(HTML("
.skin-blue .main-sidebar {
background-color: yellow;
@homerhanumat
homerhanumat / server.R
Last active January 3, 2016 20:02
Shiny app illustrating a slider that appears to wait for the user to enter a number in a numericInput field
function(input,output) {
output$sliderout <- renderText({
if (exists_as_numeric(input$numinput)) {
isolate(input$sliderinput)
}
})
output$numout <- renderText({
input$numinput
})
}