Learning to create a reusable chart function for a scatter plot, following Mike Bostock's "Towards Reusable Charts." Also includes a random data generator.
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
tifs_to_project = FileList["*.tif"].exclude(/epsg3857/).ext(".epsg3857.tif") | |
desc "Reproject all geotiffs into EPSG:3857" | |
multitask :default => tifs_to_project | |
rule( /\.epsg3857\.tif$/ => [ | |
proc {|task_name| task_name.sub(/\.epsg3857\.tif$/, '.tif') } | |
]) do |t| | |
system "gdalwarp -t_srs EPSG:3857 -s_srs EPSG:4326 #{t.source} #{t.name}" | |
end |
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
desc "Download the WPA Slave Narratives using wget" | |
task :wget_wpa do | |
system %{wget --wait 1 --limit-rate=200k -A .jpg,.png,.gif,.txt,.tif,.pdf --no-parent --background --mirror http://memory.loc.gov/mss/mesn/} | |
end | |
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
tifs_to_project = FileList["*.tif"].exclude(/epsg3857/).ext(".epsg3857.tif") | |
desc "Reproject all geotiffs into EPSG:3857" | |
multitask :default => tifs_to_project | |
rule( /\.epsg3857\.tif$/ => [ | |
proc {|task_name| task_name.sub(/\.epsg3857\.tif$/, '.tif') } | |
]) do |t| | |
system "gdalwarp -t_srs EPSG:3857 -s_srs EPSG:4326 #{t.source} #{t.name}" | |
end |
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
# Convert text files in cp1252 with dos line endings to files in UTF-8 with | |
# Unix line endings | |
for file (*.txt) {iconv -f cp1252 -t utf-8 $file -o $file} | |
dos2unix *.txt |
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
" Convert pandoc buffer to HTML and copy to system clipboard | |
autocmd FileType pandoc nnoremap <buffer> <C-S-x> :write \| let @+ = system("pandoc -t html " . shellescape(expand("%:p")))<CR> |
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(dplyr) | |
library(reshape2) | |
library(stringr) | |
library(ggplot2) | |
library(RColorBrewer) | |
# options(stringsAsFactors = FALSE) | |
options("scipen"=100, "digits"=4) | |
salaries <- read.csv("faculty-salaries-2013-14.csv") |
A quicksort algorithm to demonstrate recursion. Adapted from Norman Matloff, The Art of R Programming (San Francisco: No Starch Press, 2011), 176.
An example of using a matrix to find which cities are closest to one
another. The file distances-from-google.r
downloads some sample data
from Google's Distance Matrix API and converts it from a JSON object to
an R matrix. The file distance-matrix.r
creates a function to find the
closest city in each row of a distance matrix.
Results:
- New York is closest to Philadelphia
- Los Angeles is closest to Houston
An attribution function for R. Borrowed from Kieran Healy's code.