This file contains 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 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 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 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 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
smode <- function(x) { | |
which(tabulate(x)==max(tabulate(x))) | |
} |
This file contains 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 <hisself@adambradley.net> | |
* |
This file contains 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
$outp = array_map('serialize', $outp); | |
$outp = array_unique($outp); | |
$outp = array_map('unserialize', $outp); |
This file contains 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: Ugly code; first project with paper.js. | |
var lblHeight = 0; | |
var marX = 30; | |
var marY = 10; | |
var marDesc = 3; | |
var labels = []; | |
var dataurl = '/data/states.json'; | |
//var dataurl = 'data/mtcars.json'; |
This file contains 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
USER_TOKEN = 'pinboard:ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890' | |
import re | |
import requests | |
import sys | |
import time | |
links = requests.get('https://api.pinboard.in/v1/posts/all?auth_token='+USER_TOKEN+'&format=json')#&count=100') | |
if links.status_code != 200: |
This file contains 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 | |
/** | |
* Functions for treating (blacklight-based) Josiah as an API. | |
*/ | |
namespace ocra\josiah; | |
/** | |
* Find a field (and optionally subfield) in the JSONified MaRCXML record. | |
* |