Skip to content

Instantly share code, notes, and snippets.

View trestletech's full-sized avatar

Jeff Allen trestletech

View GitHub Profile
FROM ubuntu:14.04
MAINTAINER Winston Chang "winston@rstudio.com"
# =====================================================================
# R
# =====================================================================
# Need this to add R repo
RUN apt-get update && apt-get install -y software-properties-common
# Suppose a function has an argument "x". If a "child function" has multiple
# argument beginning with "x" and I want to pass the param "x" to its parent,
# I get error: `argument n matches multiple formal arguments`
# The reason this happens is clear, but at 3am my brain is firing blanks
# trying to find a solution. Help!
library(magrittr)
foo <- function(x, ...) UseMethod("foo")
foo.parent <- function(x, n = 5, ...) n
@trestletech
trestletech / .gitignore
Last active December 11, 2015 02:29
Import My PivotalTracker Stories into Astrid
setup.sh
token
@trestletech
trestletech / Main.java
Last active December 17, 2015 00:09
Project to compute the minimum integer > 1 which is not representable by combining an integer using the (parenthesized) +, -, /, and * operations.
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
public class Main {
public static void main(String[] args){
try{
//Write out to file assuming IntelliJ project layout.
PrintStream out = new PrintStream(new FileOutputStream("src/timing.txt"));
@trestletech
trestletech / server.R
Created June 19, 2013 05:01
Bug in shiny's renderUI function?
require(shiny)
shinyServer(function(input, output) {
val <- reactive({
if(input$change>0) {
# Option 1
'abc'
# # Option 2
# isolate({
@trestletech
trestletech / download.R
Last active December 19, 2015 23:19
Download all 4 bioconductor Gists and put them in your current working directory.
getLocalGist <- function(gistID, dirName){
url <- paste0("https://gist.github.com/",gistID,"/download")
if (shiny:::download(url, paste0(dirName,".tar.gz"), mode = "wb", quiet = TRUE) != 0)
stop("Failed to download URL ", url)
gistName <- shiny:::untar2(paste0(dirName,".tar.gz"), list=TRUE)[1]
shiny:::untar2(paste0(dirName,".tar.gz"))
#file.rename seems to be pretty fragile, but this seems to be working...
dir.create(dirName)
library(shiny)
shinyServer(function(input, output) {
dataset = reactive({
infile = input$file1
if (is.null(infile))
@trestletech
trestletech / population.Rds
Last active December 28, 2015 09:28
Data preparation for global population dataset in R.
@trestletech
trestletech / server.R
Last active January 3, 2016 12:29
Example of using clickId to dynamically cluster points in 2D space.
library(shiny)
library(mclust)
shinyServer(function(input, output, session) {
# Create a spot where we can store additional
# reactive values for this session
val <- reactiveValues(x=NULL, y=NULL)
@trestletech
trestletech / global.R
Last active January 3, 2016 21:29
A Shiny example using a selectInput in a pageWithSidebar layout but relying on a dataset defined in global.R
# Define a dataset globally which will be available
# both to the UI and to the server.
# Rely on the 'WorldPhones' dataset in the datasets
# package (which generally comes preloaded).
library(datasets)
# Trim out the non-consecutive year from