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
@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
#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
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
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
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
#Warning: Messy code. | |
#(It's been repurposed a few times.) | |
library(plyr) | |
library(ggplot2) | |
plotData <- function(date) { | |
und <- c(unemp[unemp$Date==date, -1]) | |
und <- und[order(names(und))] | |
und <- t(as.data.frame(und)) | |
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
<?php | |
$defaults=array('a'=>1, 'b'=>2, 'c'=>3); | |
$input=array('a'=> 'boo', 'c'=>4, 'd'=>5, 'e'=>6); | |
$output = array_intersect_key($input+$defaults, $defaults); | |
//Might want to provide a warning if $unused isn't empty. | |
$unused = array_diff_key($input, $defaults); |
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
#States is a data.frame with at least the following columns: | |
# $color: Any string identifiable as a color by CSS (It's included in a `style` attribute. | |
# $letter: The letter corresponding to this state in the Stately font. | |
# | |
# states$id and states$class will be used as the `id` and `class` | |
# attributes of the list elements for the states. All other columns | |
# will be inserted as data-<column-name> attributes (in case you want | |
# to use them with JavaScript). | |
statelify <- function(states) { |
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
define('TEMPLATE_DIR', 'path/to/my/templates'); | |
/** | |
* Processes a PHP template. | |
* | |
* Looks in OCRA_TEMPLATE_DIR for {$template}.tpl, and includes it, | |
* probably generating an HTML page. | |
* | |
* @author Adam Bradley <[email protected]> | |
* |