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
#!/usr/local/bin/Rscript | |
library(potools) | |
suppressPackageStartupMessages(library(data.table)) | |
script_wd = setwd("~/github/r-svn") | |
GIT_COMMIT = if (interactive()) readline('git commit: ') else commandArgs(TRUE) | |
setwd('src/library') | |
get_po_messages <- potools:::get_po_messages |
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(data.table) | |
# Export the table on page 2 to .csv: | |
# https://docs.google.com/document/d/1XbfOf3CLVb2UFyUZGJoVLkBUDZ6Hs3APCDW8UzuOvZk | |
DT=fread('~/Desktop/r-translations.csv') | |
DT[ , { | |
par(cex = 2) | |
y = `# Messages` | |
xx = barplot(y, names.arg = `R Version`, space=0, col='#2268bc', yaxt='n', main='Translatable messages by R version', las=2L) | |
text(xx[1L], y[1L]/2, srt=90, prettyNum(y[1L], big.mark = ','), col='white') | |
text(xx[.N], y[.N]/2, srt=90, prettyNum(y[.N], big.mark = ','), col='white') |
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
#!/usr/local/bin/Rscript | |
library(data.table) | |
imports_dt <- tools::dependsOnPkgs( | |
"data.table", "Imports", | |
recursive = TRUE, | |
installed = available.packages() | |
) | |
tar_dir <- "/media/michael/69913553-793b-4435-ac82-0e7df8e34b9f/cran-mirror/src/contrib" |
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(sp) | |
library(rgdal) | |
# better to download & read the files programmatically, but something | |
# funky is happening on that route, not bothering to debug too deeply. | |
# for reproducibility: | |
# (1) Click Download at the URL | |
# (2) Unzip the file; it contains two more zip directories, one KML and one SHP | |
# (3) Unzip the .shp zip to ~/Downloads/mrt |
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(data.table) | |
library(sp) | |
library(rgdal) | |
library(rgeos) | |
# Via CA GIS Data site | |
ca = readOGR("~/Downloads/CA_Counties", "CA_Counties_TIGER2016") | |
travel_zone = gBuffer( | |
ca[ca$NAME == "Santa Clara", ], |
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(data.table) | |
DT = fread("~/Downloads/spotifyclass.csv") | |
# add new columns. they're great predictors! | |
DT[ , paste0("V", 1:nrow(DT)) := replicate(.N, rnorm(.N), simplify = FALSE)] | |
summary(lm(DT$target ~ ., data = DT[ , .SD, .SDcols = patterns("^V")]))$r.squared |
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
# caveat -- doesn't have 100% overlap w the dictionary | |
CENTER=u | |
LETTERS=${CENTER}cfinot | |
grep $CENTER /usr/share/dict/words | grep -E "^[$LETTERS]{4,}$" |
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
#/bin/sh | |
# built on ImageMagick tools via convert; constituent SO answers: | |
# https://askubuntu.com/a/101527/362864 | |
# https://askubuntu.com/a/1052902/362864 | |
# https://stackoverflow.com/a/20075227/3576984 | |
# https://unix.stackexchange.com/a/24019/112834 | |
# INPUT: foo.gif | |
# step 0: isolate foo to its own folder | |
TMPDIR=/tmp/__flop_mirror__ |
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
test_xml = ' | |
<div> | |
<div> | |
<div> | |
<div> | |
<p>1</p> | |
<p>2</p> | |
<p>3</p> | |
</div> | |
</div> |
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
# NB: not fully reproducible since I've had to censor some stuff / obscure credentialling | |
library(data.table) | |
mtcars = cbind(car = rownames(mtcars), mtcars) | |
mtcars = lapply(mtcars, function(x) if (is.character(x)) sQuote(x, "'") else x) | |
colnames = toString(names(mtcars)) | |
mtcars$sep = ', ' | |
# \n\t are bells&whistles to make cat(query) look nicer | |
mtcars$collapse = '),\n\t(' | |
query = sprintf("select * from (values\n\t(%s)\n)\nt(%s)", do.call(paste, mtcars), colnames) | |
presto_rest_endpoint = file.path('/path/to/rest', 'statement') |