Skip to content

Instantly share code, notes, and snippets.

@corynissen
corynissen / index.html
Last active August 29, 2015 14:23
Philly Energy Benchmarking
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<link rel='stylesheet' href='http://cdn.leafletjs.com/leaflet-0.5.1/leaflet.css'>
<script src='http://cdn.leafletjs.com/leaflet-0.5.1/leaflet.js' type='text/javascript'></script>
<script src='https://rawgithub.com/leaflet-extras/leaflet-providers/gh-pages/leaflet-providers.js' type='text/javascript'></script>
<script src='http://harrywood.co.uk/maps/examples/leaflet/leaflet-plugins/layer/vector/KML.js' type='text/javascript'></script>
@corynissen
corynissen / austin_energy.R
Last active August 29, 2015 14:23
Austin Energy Benchmarking
library("stringr")
library("rMaps") # devtools::install_github('ramnathv/rMaps')
# download data from Austin open data portal - powered by socrata
ed <- read.csv("http://data.austintexas.gov/api/views/rka3-mjzi/rows.csv",
stringsAsFactors=FALSE)
# get lat, lng, and address separated out from Address field
ed$latlng <- substring(ed$Address, regexpr("\\n\\(", ed$Address)+2, nchar(ed$Address))
ed$lat <- substring(ed$latlng, 1, regexpr(",", ed$latlng)-1)
@corynissen
corynissen / index.html
Created June 18, 2015 18:14
Austin Energy Benchmarking
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<link rel='stylesheet' href='http://cdn.leafletjs.com/leaflet-0.5.1/leaflet.css'>
<script src='http://cdn.leafletjs.com/leaflet-0.5.1/leaflet.js' type='text/javascript'></script>
<script src='https://rawgithub.com/leaflet-extras/leaflet-providers/gh-pages/leaflet-providers.js' type='text/javascript'></script>
<script src='http://harrywood.co.uk/maps/examples/leaflet/leaflet-plugins/layer/vector/KML.js' type='text/javascript'></script>
@corynissen
corynissen / server.R
Last active August 29, 2015 14:15
SO question 28423302
library(shiny)
library(ggvis)
Visitas_Por_Fuente <- structure(list(date = structure(1:31, .Label = c("2014-12-01",
"2014-12-02", "2014-12-03", "2014-12-04", "2014-12-05", "2014-12-06",
"2014-12-07", "2014-12-08", "2014-12-09", "2014-12-10", "2014-12-11",
"2014-12-12", "2014-12-13", "2014-12-14", "2014-12-15", "2014-12-16",
"2014-12-17", "2014-12-18", "2014-12-19", "2014-12-20", "2014-12-21",
@corynissen
corynissen / global.R
Last active August 29, 2015 14:15
SO question 28474903
df1_number <-sample(seq(1,20,0.01),20,replace = T)
df2_number <-sample(seq(1,20,0.01),20,replace = T)
df1_number2 <-sample(seq(1,5,0.01),20,replace = T)
df2_number2 <-sample(seq(1,5,0.01),20,replace = T)
df1 <- data.frame(name = rep(letters[1:4],each = 5), number = df1_number, number2 = df1_number2)
df2 <- data.frame(name = rep(letters[1:4],each = 5), number = df2_number, number2 = df2_number2)
axis_vars_y <- c("number" = "number", "number2" = "number2")
@corynissen
corynissen / server.R
Last active August 29, 2015 14:15
SO question 28475137
library(RODBC)
shinyServer(function(input,output){
output$txt1<-renderTable({
input$b1
if(input$b1==0 )return()
isolate({
con<-odbcConnect("sample",uid="amma",pwd="amma")
sqlTables(con)
# sqlQuery(con,"insertintosampvalues('",input$text1,"',",input$text2,")");
@corynissen
corynissen / index.html
Created December 1, 2014 20:30
Foodbornechi Map
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<link rel='stylesheet' href='http://cdn.leafletjs.com/leaflet-0.5.1/leaflet.css'>
<script src='http://cdn.leafletjs.com/leaflet-0.5.1/leaflet.js' type='text/javascript'></script>
<script src='https://rawgithub.com/leaflet-extras/leaflet-providers/gh-pages/leaflet-providers.js' type='text/javascript'></script>
<script src='http://harrywood.co.uk/maps/examples/leaflet/leaflet-plugins/layer/vector/KML.js' type='text/javascript'></script>
recId|searchText|country
0001|Invalidenstraße 116 10115 Berlin|DEU
0002|Am Kronberger Hang 8 65824 Schwalbach|DEU
0003|425 W Randolph St Chicago IL 60606|USA
0004|One Main Street Cambridge MA 02142|USA
0005|200 S Mathilda Ave Sunnyvale CA 94086|USA
@corynissen
corynissen / trendy_graph.R
Last active August 29, 2015 14:07
Attempt at making a dashboard-y graph in ggplot2
# trying to create a graph as seen here: https://twitter.com/Cnnct2me/status/522429612089819136
df <- data.frame(time=1:100, why=runif(100, 72, 83))
ggplot(df) +
geom_ribbon(aes(x=time, ymin=72, ymax=why), color="white", fill="white") +
coord_cartesian(ylim=c(70, 85)) +
theme(panel.background = element_rect(fill = '#3FE874'),
plot.background = element_blank(),
panel.grid.major = element_blank(),
@corynissen
corynissen / server.R
Last active August 29, 2015 14:06
save reactiveValues
library(shiny)
library(RCurl)
shinyServer(function(input, output, session){
urls <- reactiveValues()
if(file.exists("data.Rdata")){
load("data.Rdata")
urls$url <- df$url
urls$isbn <- df$isbn