Skip to content

Instantly share code, notes, and snippets.

View lmullen's full-sized avatar

Lincoln Mullen lmullen

View GitHub Profile
@lmullen
lmullen / Rakefile
Last active August 29, 2015 13:57
Convert geotiffs and rsync them to the server
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
@lmullen
lmullen / Rakefile
Last active August 29, 2015 13:57
Download the WPA Slave Narratives from the Library of Congress
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
@lmullen
lmullen / Rakefile
Last active August 29, 2015 13:57
Reproject geotiffs and upload them to a server
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
@lmullen
lmullen / convert-file-encoding-line-breaks.zsh
Created March 12, 2014 20:46
Convert text files in cp1252 with dos line endings to files in UTF-8 with Unix line endings
# 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
@lmullen
lmullen / pandoc-copy.vim
Created March 13, 2014 17:41
Convert pandoc buffer to HTML and copy to system clipboard
" 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>
@lmullen
lmullen / README.md
Last active August 29, 2015 13:57
Reusable Scatter Plot Function

Learning to create a reusable chart function for a scatter plot, following Mike Bostock's "Towards Reusable Charts." Also includes a random data generator.

@lmullen
lmullen / analysis.r
Last active December 7, 2018 14:41
Charting Faculty Salaries
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")
@lmullen
lmullen / README.md
Last active August 29, 2015 13:57
Quicksort algorithm in R to demonstrate recursion
@lmullen
lmullen / README.md
Last active August 25, 2019 14:22
Distance matrix in R

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
@lmullen
lmullen / README.md
Created March 26, 2014 00:01
Attribution function for R