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 an R package hosted as a build artifact on gitlab | |
#' | |
#' Gitlab supports the storage of build artifacts which may be utilized as | |
#' distribution mechanism for code binaries. Applying this to scheme to R, a | |
#' build task may be defined (for example for each tagged commit), yielding a | |
#' .zip file of the tar.gz package produced by R CMD build. This function | |
#' fetches the most recent build artifact and installs it as a package. | |
#' | |
#' @param gitlab A string representing the base url of the gitlab host | |
#' @param name The name of the package repository |
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
export C_INCLUDE_PATH=$(/usr/local/clang-7/bin/llvm-config --includedir) | |
export CPLUS_INCLUDE_PATH=$(/usr/local/clang-7/bin/llvm-config --includedir) | |
export LIBRARY_PATH=$(/usr/local/clang-7/bin/llvm-config --libdir) | |
git clone --recursive https://github.com/dmlc/xgboost | |
cd xgboost | |
cp make/config.mk config.mk | |
vi config.mk | |
# make edits such that | |
# export CC = /usr/local/clang-7/bin/clang |
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
wget https://stat.ethz.ch/CRAN/src/base/R-3/R-3.5.1.tar.gz | |
tar -xvf R-3.5.1.tar.gz | |
cd R-3.5.1 | |
vi config.site | |
# edit such that | |
# CC=/usr/local/clang-7/bin/clang | |
# OBJC=$CC | |
# F77=/usr/local/gcc-8.2/bin/gfortran-8 | |
# LDFLAGS="-L/usr/local/clang-7/lib -L/usr/local/lib" |
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
rm_tbl_4 <- function(tbl, env) { | |
tbl = deparse(substitute(tbl)) | |
rm(list = tbl, pos = env) | |
} | |
fun_a <- function(dat_tbl) { | |
fun_b(dat_tbl) | |
} | |
fun_b <- function(data_table) { |
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
dt_sequential <- function(tbl, group_by, fun, use_cols) { | |
time_taken <- system.time({ | |
res <- tbl[, fun(.SD), by = group_by, .SDcols = use_cols] | |
}) | |
list(result = res, timings = time_taken) | |
} |
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
library(bigmemory) | |
add_col_var <- function(x) { | |
biganalytics::apply(x, 2L, function(y) { | |
col_var <- 0 | |
y_bar <- 0 | |
for (i in y) y_bar <- y_bar + i | |
y_bar <- y_bar / length(y) | |
for (i in y) col_var <- col_var + (i - y_bar) ^ 2 | |
y + (col_var / length(y)) |
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
# make sure a recent version of bison is available | |
brew install bison | |
wget https://www-eu.apache.org/dist/arrow/arrow-0.12.0/apache-arrow-0.12.0.tar.gz | |
tar -xvf apache-arrow-0.12.0.tar.gz | |
cd apache-arrow-0.12.0/cpp && mkdir release && cd release | |
# It is important to statically link to boost libraries | |
cmake .. -DARROW_PARQUET=ON -DCMAKE_BUILD_TYPE=Release -DARROW_BOOST_USE_SHARED:BOOL=Off \ | |
-DBISON_EXECUTABLE=/usr/local/opt/bison/bin/bison |
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
// compile: clang++ -Wall -std=c++14 -I /usr/local/include mp11-type-list-switch.cpp -o mp11-type-list-switch | |
#include <vector> | |
#include <iostream> | |
#include <boost/mp11/list.hpp> | |
#include <boost/mp11/algorithm.hpp> | |
namespace mp11 = boost::mp11; |
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
// compile: clang++ -Wall -std=c++11 functor-type-switch.cpp -o functor-type-switch | |
#include <vector> | |
#include <iostream> | |
#include <stdexcept> | |
template <template<typename> class Func, typename ...Ar> | |
auto dispatch_type(size_t type, Ar&&... rg) -> | |
decltype(Func<int>()(std::forward<Ar>(rg)...)) { | |
switch(type) { |
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
#include <stdexcept> | |
#include <tuple> | |
#include <iostream> | |
// terminating case to avoid if-constexpr | |
template <template<class> class F, typename R, typename... Ar> | |
R dispatch_impl(int, Ar&&... rgs) { | |
throw std::runtime_error("error"); | |
} |
OlderNewer