Skip to content

Instantly share code, notes, and snippets.

@hafen
hafen / server.R
Last active December 10, 2015 04:48
Shiny dynamic number of UI elements example
library(shiny)
MAX <- 200
shinyServer(function(input, output) {
# input$nInputs will be changed infrequently
# but input$dummy will be changed frequently
nInputs <- reactive(function() {
# it would be nice to be able add some code here
@hafen
hafen / test1
Created July 2, 2014 14:44
test
test
@hafen
hafen / doubles.csv
Last active August 29, 2015 14:14
doubles
x y
53.8815367264149 411.436319810874
-219.24469668437 243.552532150571
-216.749025691947 228.528592776184
-244.301233448298 253.585129540112
-246.821861150645 276.145995311617
-196.708787622789 318.722142442355
186.676190233249 248.568830845342
26.3043722601395 411.436319810874
-186.676190233249 180.911190240751
<head>
<script src="http://cdn.pydata.org/bokeh/release/bokeh-0.8.1.min.js"></script>
<link href="http://cdn.pydata.org/bokeh/release/bokeh-0.8.1.min.css" rel="stylesheet">
</head>
<div id=08fd29cc51d3761133a159ca4f697be5 class="plotdiv"></div>
<script type="text/javascript">
Bokeh.$(function() {
var modelid = "a57e43d6b7e067caeaa2a9159e4e5d59";
@hafen
hafen / gist:bcb77bbd6c6d23447a05
Created March 31, 2015 08:11
datadr quick start with RHIPE backend
library(Rhipe)
rhinit()
rhoptions(zips = "/ln/share/RhipeLib.tar.gz")
rhoptions(runner = "sh ./RhipeLib/library/Rhipe/bin/RhipeMapReduce.sh")
rhoptions(file.types.remove.regex = "(/_meta|/_rh_meta|/_outputs|/_SUCCESS|/_LOG|/_log|rhipe_debug|rhipe_merged_index_db)")
hdfs.setwd("/ln/rhafen")
library(datadr)
housing <- drRead.csv(hdfsConn("/tmp/housing/", type = "text"),
@hafen
hafen / code.R
Last active August 29, 2015 14:26
A quick datadr / trelliscope demo
## installation
##---------------------------------------------------------
install.packages("devtools") # if not installed
devtools::install_github("tesseradata/datadr")
devtools::install_github("tesseradata/trelliscope")
devtools::install_github("hafen/housingData")
devtools::install_github("bokeh/rbokeh")
## quick trelliscope example
@hafen
hafen / choropleth.csv
Created September 22, 2015 04:04
choropleth data
We can't make this file beautiful and searchable because it's too large.
"long","lat","group","color"
-86.496774,32.344437,"0.1","#7F7FFF"
-86.717897,32.402814,"0.1","#7F7FFF"
-86.814912,32.340803,"0.1","#7F7FFF"
-86.890581,32.502974,"0.1","#7F7FFF"
-86.917595,32.664169,"0.1","#7F7FFF"
-86.71339,32.661732,"0.1","#7F7FFF"
-86.714219,32.705694,"0.1","#7F7FFF"
-86.413116,32.707386,"0.1","#7F7FFF"
-86.411172,32.409937,"0.1","#7F7FFF"
@hafen
hafen / README.md
Last active September 30, 2015 20:41
Basketball Overlay

Created by Ryan Hafen

library(rbokeh)
url <- 'https://raw.githubusercontent.com/weinfz/nba_shot_value_charts/master/court.png'
# image is 1155 wide x 993 high
aspect <- 993 / 1155
@hafen
hafen / README.md
Created September 30, 2015 20:37
Basketball Overlay

Created by Ryan Hafen

library(rbokeh)
url <- 'https://raw.githubusercontent.com/weinfz/nba_shot_value_charts/master/court.png'
p <- figure(width = 600, height = 600 * aspect, padding_factor = 0, 
  xlab = NULL, ylab = NULL) %>%
 ly_image_url(x = -300, y = -20, url = url, w = 600, h = 440, anchor = 'bottom_left') %&gt;%
@hafen
hafen / README.md
Created September 30, 2015 20:38
Basketball Overlay

Created by Ryan Hafen

library(rbokeh)
url <- 'https://raw.githubusercontent.com/weinfz/nba_shot_value_charts/master/court.png'
p <- figure(width = 600, height = 600 * aspect, padding_factor = 0, 
  xlab = NULL, ylab = NULL) %>%
 ly_image_url(x = -300, y = -20, url = url, w = 600, h = 440, anchor = 'bottom_left') %&gt;%