This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
songs <- read.table('http://data.adamtbradley.com/RadioParadisePlays.txt', | |
sep='-', skip=1, quote='', strip.white=T, | |
allowEscapes=T, col.names=c('time', 'artist', 'track')) | |
songs$artist <- sub('–', '-', songs$artist) | |
songs$track <- sub('–', '-', songs$track) | |
summ <- table(paste(songs$artist, songs$track, sep=": ")) | |
summ.artists = table(songs$artist) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
library(ggplot2) | |
#This is at http://raw.github.com/hadley/data-baby-names/master/baby-names.csv | |
names <- read.csv('~/R/baby-names.csv') | |
# Define server logic required to plot various variables against mpg | |
shinyServer(function(input, output) { | |
# Return the formula text for printing as a caption | |
output$caption <- reactiveText(function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(reshape) | |
library(ggplot2) | |
library(ReadImages) | |
ccodes <- read.csv('http://sandbox.adamtbradley.com/colors/') | |
#From http://is-r.tumblr.com/post/36586614678 | |
#Read an image from the web and shape it into a data.frame. | |
#codeColors() uses this--I don't call it directly. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#options('gh_token') should be a GitHub API token with the 'gist' scope. | |
#(See http://developer.github.com/v3/gists/) | |
library(httr) | |
library(rjson) | |
gistify <- function(filename, desc=F, public=F) { | |
data <- list(public = public) | |
if ( desc != F ) data$description = desc | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@GrabConfig(systemClassLoader=true) | |
@Grab(group='com.jcraft', module='jsch', version='0.1.48') | |
import com.jcraft.jsch.*; | |
@Grab(group='org.apache.ant', module='ant-jsch', version='1.8.4') | |
import org.apache.tools.ant.taskdefs.optional.ssh.Scp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#in .Rprofile: | |
tumblr.user <- "[email protected]" | |
tumblr.pass <- "tumblrPassword" | |
library(markdown) | |
library(httr) | |
options(rstudio.markdownToHTML = | |
function(i,o) { | |
markdownToHTML(i,o,fragment.only=TRUE) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(markdown) | |
options(rstudio.markdownToHTML = | |
function(i,o) { | |
markdownToHTML(i,o,fragment.only=TRUE) | |
} | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import groovy.xml.MarkupBuilder | |
//Read a tab-delimited file. | |
def tdl = new TLD('comiclist.txt', false, 'Box No.') | |
/* | |
//Turn it into a simple xml format, one 'comic' per spreadsheet row. | |
def wrt = new StringWriter() | |
def xml = new MarkupBuilder(wrt) | |
xml.comics { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Return the actual location of a web page given a shortened url. | |
// Based in part on this Stack Overflow answer: | |
// http://stackoverflow.com/questions/1519392/how-to-prevent-apache-http-client-from-following-a-redirect | |
import groovyx.net.http.HTTPBuilder | |
import org.apache.http.impl.client.AbstractHttpClient | |
import org.apache.http.params.BasicHttpParams | |
import static groovyx.net.http.Method.HEAD |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Similar to XSLT's copy-of element. Useful if e.g. you have node containing XHTML | |
that you want to return as-is. | |
*/ | |
Node.metaClass.asString = { | |
def text = [] | |
delegate.children().each { child -> |