git config --global alias.unstage 'reset HEAD --'
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
# set -g mouse-resize-pane on | |
# Use Alt-arrow keys without prefix key to switch panes | |
bind -n M-Left select-pane -L | |
bind -n M-Right select-pane -R | |
bind -n M-Up select-pane -U | |
bind -n M-Down select-pane -D | |
# Shift arrow to switch windows | |
bind -n S-Left previous-window |
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
# install.packages(c("tidyverse", | |
# "devtools", | |
# "testthat", | |
# "usethis", | |
# "reprex", | |
# "covr", | |
# "lintr", | |
# "styler", | |
# "fs", | |
# "lookup", |
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
# adapted from: https://stackoverflow.com/a/41935867/171659 | |
# choose the image according to the language chosen in .travis.yml | |
mkdir -p "$PWD":/home/docker | |
docker run -ti --rm -v "$PWD":/home/docker -w /home/docker -u docker r-base /bin/bash | |
# now that you are in the docker image, switch to the travis user | |
sudo - travis | |
apt-get install ruby |
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
-- Adapted from http://www.craigkerstiens.com/2015/12/29/my-postgres-top-10-for-2016/ | |
\set QUIET 1 | |
\pset null '¤' | |
-- Customize prompts | |
\set PROMPT1 '%[%033[1;34m%][%M %n@%/] # %[%033[0m%]%' | |
\set PROMPT2 '... # ' | |
-- Show how long each query takes to execute | |
\timing |
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
# dplyr style | |
polygons %>% | |
mutate(value = raster::extract.sfg(geometry, r, mean)) %>% | |
plot() | |
# sp style | |
value = raster::extract(polygons, r, mean, df = TRUE) | |
# multiple values | |
md <- function(x) data.frame(m = mean(x), d = sd(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
#' Multivariate mutate | |
#' Mutate multiple columns | |
#' | |
#' @param .df A tbl | |
#' @param ... Name-value pairs of expressions that return one or more columns with 1 or nrow(.df) observations | |
#' @param .dots A list of formulas used to work around non-standard evaluation. | |
#' @export | |
#' @aliases mutatem_ | |
#' @examples | |
#' df <- tibble(x=1:5, y=5:1) |
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
first_day_in_month = function(x) { | |
day(x) = 1 | |
hour(x) = 0 | |
minute(x) = 0 | |
second(x) = 0 | |
return(x) | |
} | |
first_day_in_year = function(x) { | |
month(x) = 1 |
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
#' Pack multiple files in a zip | |
#' | |
#' @export | |
#' @param fz Complete zip filename and path | |
#' @param fs Named List. Names are files names and content to be passed to FUN | |
#' @param FUN Function for writing to disc (defautl write.csv). Has to accept content as | |
#' first argument and file name as second. Other arguments are passed using ... | |
#' @param temp.dir Temporary directory to write files and zip. Is appened to file names | |
#' if not NULL. | |
#' @param flags A character string of flags to be passed to the command. Defaults is \code{-r9Xj} |
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
DROP SCHEMA test CASCADE; | |
CREATE SCHEMA test; | |
CREATE TABLE test.measure AS | |
SELECT | |
r as rowy, c as colx, b as band, | |
round(random() * 100)::float as v | |
FROM | |
generate_series(1, 6) as r | |
CROSS JOIN LATERAL |
NewerOlder