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
# optimization parameters | |
DBI::dbExecute(con, "PRAGMA journal_mode = wal;") | |
DBI::dbExecute(con, "PRAGMA synchronous = normal;") | |
DBI::dbExecute(con, "PRAGMA cache_size = -128000;") | |
DBI::dbExecute(con, "PRAGMA page_size = 4096;") | |
DBI::dbExecute(con, "PRAGMA locking_mode = EXCLUSIVE;") | |
DBI::dbExecute(con, "PRAGMA temp_store = MEMORY;") |
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
# duckdb import tsv snippet | |
duckdb_fp | |
tsv_fp | |
con <- DBI::dbConnect(duckdb::duckdb(), duckdb_fp) | |
# config duckdb | |
DBI::dbExecute(con, "SET memory_limit='20GB';") | |
DBI::dbExecute(con, "SET threads TO 20;") |
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
fp <- "proposal.tex" | |
lines <- readLines(fp) | |
for (i in 1:length(lines)) { | |
lines[i] = paste0("\"", gsub("\\", "\\\\", lines[i], fixed = TRUE), "\",") | |
} | |
writeLines(lines) |
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
# thanks to https://social.technet.microsoft.com/Forums/en-US/b4335755-68a4-4acc-8d70-54414b40c987/microsoft-r-open-line-breaks-during-package-compilation?forum=ropen | |
/opt/microsoft/ropen/4.0.2/lib64/R/bin/R --vanilla | |
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 fresh_connect to force not using old connection (so that ip address could refresh per 10secs) | |
# depends on how you set up the refresh ip for Tor service | |
h <- curl::new_handle(proxy = "socks5://localhost:9050", maxage_conn = 10) # , fresh_connect = 1) | |
curl::handle_setheaders(h, "Cache-Control" = "no-cache", "User-Agent" = Randomuseragent::random_useragent()) | |
req <- curl::curl_fetch_memory("https://icanhazip.com/", handle = h) | |
rawToChar(req$content) |
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
// test the partial derivative in one go | |
#include "adcpp.h" | |
#include <iostream> | |
using namespace adcpp; | |
static bwd::Double mysq(const bwd::Double &x, const bwd::Double &y) { | |
return bwd::pow(x, 2) + bwd::pow(y, 3); | |
} |
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
// write the sinkhorn algorithm and compare with the POT result | |
#include "Eigen/Eigen" | |
// #include "unsupported/Eigen/MatrixFunctions" | |
#include <iostream> | |
void sinkhorn(Eigen::VectorXd a, Eigen::VectorXd b, Eigen::MatrixXd M, | |
const double reg, const int numItermax = 1000, | |
const double stopThr = 1e-9) { | |
// only compute 1d to 1d case |