Skip to content

Instantly share code, notes, and snippets.

template <class Fun>
class ScopeGuard {
Fun f_;
bool active_;
public:
ScopeGuard(Fun f)
: f_(std::move(f))
, active_(true) {
}
~ScopeGuard() { if (active_) f_(); }
@krlmlr
krlmlr / deps.R
Created January 19, 2016 14:44
Module dependency graph for an R package
devtools::load_all()
envir <- as.environment("package:darn")
deps <- mvbutils::foodweb(where = envir, plotting = FALSE)
funmat <- deps$funmat
funs <- mget(colnames(funmat), envir, mode = "function")
fun_files <-
lapply(funs, attr, "srcref") %>%
@krlmlr
krlmlr / gist:92007a8a8677fc56c87f
Created March 2, 2016 11:36
Offline GitHub issues, milestones, and labels, with wget
wget -np -k -e robots=off -r -l 1 https://github.com/krlmlr/tibble/milestones/ https://github.com/krlmlr/tibble/issues/ https://github.com/krlmlr/tibble/labels/
@krlmlr
krlmlr / rowwise.Rmd
Last active August 4, 2016 18:50 — forked from wch/rowwise.Rmd
---
title: "Applying a function over rows of a data frame"
author: "Winston Chang"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
```
@krlmlr
krlmlr / test-revdep.R
Last active August 24, 2016 15:11
Draft for testing revdep checks: https://github.com/hadley/devtools/issues/1302
#library(devtools)
devtools::load_all()
#' # Testing revdep_check()
#'
#' Functions:
create_deps_tested <- function() {
deps <- list(
testee = character(),
@krlmlr
krlmlr / huntr.R
Created December 23, 2016 14:50
Detect and manually fix missing join-by columns for dplyr
withCallingHandlers(
remake::make(remake::list_targets()),
message = function(e) {
if (grepl("Joining, ", e$message)) {
by_clause <- gsub("Joining(.*)\n", "\\1", e$message)
clipr::write_clip(by_clause)
srcref <- testthat:::find_first_srcref(sys.calls()[-1:-15])
srcfile <- attr(srcref, "srcfile")$filename
rstudioapi::navigateToFile(srcfile, srcref[1], srcref[2])
stop("Insert by clause: ", by_clause)
@krlmlr
krlmlr / sqlite3-unsigned-64.patch
Created January 8, 2017 12:56
SQLITE_UINT64_TYPE
diff --git a/src/sqlite3/sqlite3.h b/src/sqlite3/sqlite3.h
index 37d1024..0f55423 100644
--- a/src/sqlite3/sqlite3.h
+++ b/src/sqlite3/sqlite3.h
@@ -248,8 +248,11 @@ typedef struct sqlite3 sqlite3;
** between 0 and +18446744073709551615 inclusive.
*/
#ifdef SQLITE_INT64_TYPE
+ #ifndef SQLITE_UINT64_TYPE
+ #define SQLITE_UINT64_TYPE unsigned SQLITE_INT64_TYPE
> devtools::install_github("tidyverse/dplyr")
Downloading GitHub repo tidyverse/dplyr@master
from URL https://api.github.com/repos/tidyverse/dplyr/zipball/master
Installing dplyr
Downloading GitHub repo hadley/rlang@ac7498c9
from URL https://api.github.com/repos/hadley/rlang/zipball/ac7498c9
Installing rlang
"C:/PROGRA~1/R/R-33~1.3/bin/x64/R" --no-site-file --no-environ --no-save
--no-restore --quiet CMD \
INSTALL \
@krlmlr
krlmlr / olson-abbrev.txt
Created October 25, 2017 12:14
Abbreviations for Olson names from Ubuntu system
Africa/Abidjan
Africa/Accra
Afr/Addis_Abab
Africa/Algiers
Africa/Asmara
Africa/Asmera
Africa/Bamako
Africa/Bangui
Africa/Banjul
Africa/Bissau
@krlmlr
krlmlr / Rprofile-entrace
Last active January 7, 2021 01:59
Pretty stack traces in R
# Add this to your .Rprofile
options(
error = quote(rlang::entrace()),
rlang__backtrace_on_error = "collapse" # or "branch" or "full"
)