Skip to content

Instantly share code, notes, and snippets.

View jalapic's full-sized avatar

James Curley jalapic

View GitHub Profile
@abresler
abresler / gist:6911f5eb5d3834fc6d55
Last active August 29, 2015 14:15
gotham_cookies_graphviz
library(rvest)
library(htmltools)
library(pipeR)
library("DiagrammeR")
html('
<ul class="ze_imagelist" style="width:925px;height:400px;" id="slideshowpj_widget_54da647bbdf7e"><li class="ze_thumb ze_type_image ze_item_number_1"><a class="ze_box" rel="prettyPhoto[pj_widget_54da647bbdf7e]" href="http://ec12.cdn.cincopa.com/SaltedCaramel2.jpg?o=1&amp;res=76&amp;cdn=ec&amp;p=y&amp;pid=231720&amp;ph3=b2d1timslim1sat2p2lxtiganpc1chim&amp;d=AMWAjFwULOAANQJsAMnyJRB&amp;as=mp3" title="Salted Caramel - Our Signature Cookie<br />Our Signature Cookie! Caramel-infused dough loaded with Chocolate Chips and drizzled with Salted Caramel Sauce" style="width:190px;height:190px;"> <div class="ze_overlay"></div> <div id="pj_widget_54da647bbdf7e_0_thumbsplash" class="ze_item" style="width:190px;height:190px;"> <img class="ze_postar" style="height:190px;" src="http://ec12.cdn.cincopa.com/SaltedCaramel2.jpg?o=1&amp;res=76&amp;cdn=ec&amp;p=y&amp;pid=231720&amp;ph3=b2d1timslim1sat2p2lxtiganpc1chim&amp;d=AMWAjFwULOAANQJsAMnyJRB" t
@timelyportfolio
timelyportfolio / Readme.md
Last active August 29, 2015 14:28 — forked from jalapic/gana.csv
Heatmap of touches (in rbokeh)

@jalapic did these really nice set of touch heatmap charts. On Twitter, there was a discussion how to do this interactively with d3.js or some other JavaScript. I definitely have some ideas how to accomplish this, but for now let's see how we can kind of do it in rbokeh. There is just a small issue with palette selection in Bokeh that does not let us allow a no color that prevents us from getting really close.

## https://gist.github.com/jalapic/3616c0197ece24060e99
library(rbokeh)
library(dplyr)

gana <- read.csv("https://gist.githubusercontent.com/jalapic/3616c0197ece24060e99/raw/2bc2361c5fceb9be80dece9b7ffa14d129a3edfb/gana.csv")

figure() %>%
@rich-iannone
rich-iannone / diagrammer-fixed-nodes-visnetwork.R
Last active October 2, 2015 03:34
Fixed nodes (with specified positions) in DiagrammeR
# Installation
#install.packages("devtools")
devtools::install_github("rich-iannone/DiagrammeR")
library(DiagrammeR)
# Create and render an empty graph
empty_graph <- create_graph()
render_graph(empty_graph, output = "visNetwork")
library(SmarterPoland)
library(riverplot)
library(RColorBrewer)
library(graphics)
library(reshape2)
library(plyr)
library(stringr)
library(countrycode)
# DOWNLOAD THE DATA
We can make this file beautiful and searchable if this error is corrected: It looks like row 5 should actually have 34 columns, instead of 5. in line 4.
name.table,id.season,is.offense,name.player,team,id.player,jersey,id.position,id.team,slug.team,city.team,gp,possesions,pct.play_type,pts,fga,fgm,ppp,ppp.worse,ppp.better,possesions.per_game,pts.per_game,fga.per_game,fgm.per_game,fg.miss.per_game,rank,pct.fg,pct.efg,pct.ft_achieved,pct.to,pct.shooting_foul,pct.and_1,pct.scored,stem.table
Post-Up,2015-16,TRUE,Paul Millsap,Atlanta Hawks,200794,4,F,1610612737,ATL,Atlanta,4,13,19.69700050354,20,8,7,1.53846001625061,25,0,3.25,5,2,1.75,0.25,1,87.5,87.5,30.7692307692308,15.3846153846154,30.7692307692308,7.69230769230769,76.9230769230769,Postup
Post-Up,2015-16,TRUE,Al Horford,Atlanta Hawks,201143,15,F-C,1610612737,ATL,Atlanta,4,11,15.0684995651245,12,8,6,1.09090995788574,17,7,2.75,3,2,1.5,0.5,2,75,75,0,27.2727272727273,0,0,54.5454545454545,Postup
Post-Up,2015-16,FALSE,Kent Bazemore,Atlanta Hawks,203145,24,G,1610612737,ATL,Atlanta,4,11,22.917,7,7,1,0.636,5,4,2.75,1.75,1.75,0.25,1.5,6,14.286,14.286,27.273,9.091,27.273,0,36.364,Postup
Post-Up,2015-16,FALSE,Al Horford,A
@abresler
abresler / get_nba_days_scores.r
Last active December 18, 2015 15:11
Gets game scores and more for any valid NBA date
packages <- #need all of these installed including some from github
c('dplyr',
'magrittr',
'jsonlite',
'tidyr',
'stringr',
'lubridate')
options(warn = -1)
lapply(packages, library, character.only = T)
@nowherenearithaca
nowherenearithaca / README.md
Last active April 11, 2016 04:22
Making a Heat Map Legend with D3 - a Simple Example

This is an example of creating what could be a legend for a heat map, demonstrating the simple use of a data-driven linear gradient with D3.

library(ggplot2) # devtools::install_github("hadley/ggplot2") or subtitles won't work
library(tidyr)
library(dplyr)
library(readr)
library(scales)
URL <- "https://static01.nyt.com/newsgraphics/2016/04/21/undervote/ad8bd3e44231c1091e75621b9f27fe31d116999f/data.tsv"
fil <- "nytimes_vote.tsv"
if (!file.exists(fil)) download.file(URL, fil)
# devtools::install_github('jalapic/engsoccerdata')
library(engsoccerdata)
library(dplyr)
library(plotly)
library(htmlwidgets)
england$Date <- as.Date(england$Date, format = "%Y-%m-%d")
#Get Data into Format Needed
df<-rbind(
from __future__ import print_function
import copy
class permutor:
def __init__(self, infile='curley_seq.txt', max_entries=-1):
self.indata = self.read_infile(infile)
if max_entries>0:
self.indata = self.indata[0:max_entries]