Skip to content

Instantly share code, notes, and snippets.

Avatar

Patrick Schratz pat-s

View GitHub Profile
View install-cluto.R
# because base::file.rename() is a pain across OS
requireNamespace("fs", quietly = TRUE)
# download cluto zip file
temp = tempfile()
download.file("http://glaros.dtc.umn.edu/gkhome/fetch/sw/cluto/cluto-2.1.2a.zip", temp, quiet = TRUE)
unzip(temp, files = c("cluto-2.1.2/Linux-x86_64/vcluster", "cluto-2.1.2/MSWIN-x86_64/vcluster.exe"))
unlink(temp)
View git-startup-rstudio
if (requireNamespace(c("callr", "git2r", "gert", "cli"), quietly = TRUE)) {
has_git = git2r::in_repository()
if (has_git && Sys.getenv("RSTUDIO") == 1) {
cli::cli_text("Running
{.code gert::git_pull(verbose = FALSE, prune = TRUE, rebase = TRUE)}
in the background.")
callr::r_bg(function() {
gert::git_pull(verbose = FALSE, prune = TRUE, rebase = TRUE)
},
stdout = out <- tempfile(), stderr = err <- tempfile())$wait()
View git-pull-rstudio
if (requireNamespace(c("callr", "git2r"), quietly = TRUE)) {
has_git = git2r::in_repository()
if (has_git) {
message("Running `git2r::pull()` in the background.")
callr::r_bg(function() {git2r::pull()})$wait()$get_result()
}
}
View gist:529d386d2e1e9e6ae068db73431f8866
Jun 12 01:03:00 charge2 kernel: [762622.063494] testing the buffer
Jun 12 01:03:00 charge2 kernel: [762622.063505] testing the buffer
Jun 12 01:03:00 charge2 kernel: [762622.063592] testing the buffer
Jun 12 01:03:00 charge2 kernel: [762622.063604] testing the buffer
Jun 12 01:03:01 charge2 CRON[58247]: (ursmaendli) CMD (/home/ursmaendli/charge2/run.sh >> /home/ursmaendli/run-sh.log 2>&1)
Jun 12 01:03:01 charge2 CRON[58248]: (ursmaendli) CMD (/home/ursmaendli/charge2/run-static.sh >> /home/ursmaendli/run-static-sh.log 2>&1)
Jun 12 01:03:02 charge2 containerd[80521]: time="2020-06-12T01:03:02.341916576Z" level=info msg="shim containerd-shim started" address=/containerd-shim/355a87ba8742cd32cd0d779d231a254f64410b04ae06fd07a1616efb84c2781f.sock debug=false pid=58266
Jun 12 01:03:02 charge2 containerd[80521]: time="2020-06-12T01:03:02.397109845Z" level=info msg="shim containerd-shim started" address=/containerd-shim/ef6ccfec1e235dab150e0ec0e1409e821985432e28a324418737a76f1c85f8a3.sock debug=false pid=58300
Jun 12
View RStudio_usethis_selection_browse.R
browse_news <- function(package = NULL) {
# check for pkgdown url
field_url <- desc::desc_get_urls(file = system.file("DESCRIPTION", package = package))[1]
# check if a news site exists for the given url
has_pkgdown <- httr::status_code(httr::GET(paste0(field_url, "/news"))) == 200
if (has_pkgdown) {
view_url((paste0(field_url, "/news")))
return(invisible())
}
View gist:938d5642573107654e09c9884dd3bc28
fs::dir_create("inst/paramtest", recurse = TRUE)
writeLines('on:
push:
pull_request:
# for now, CRON jobs only run on the default branch of the repo (i.e. usually on master)
schedule:
# * is a special character in YAML so you have to quote this string
- cron: "0 4 * * *"
name: Parameter Check
@pat-s
pat-s / example.R
Created Mar 17, 2020
init_mlr3learner_drat_deploy
View example.R
init_mlr3learner_drat_deploy("mlr3learners.mboost") # replace this with the actual learner name
@pat-s
pat-s / install-r-macOS.sh
Created Dec 14, 2019
Install R official on macOS
View install-r-macOS.sh
#! /bin/bash
R_VERSION=$1
wget https://mac.r-project.org/el-capitan/R-${R_VERSION}-branch/R-${R_VERSION}-branch-el-capitan-sa-x86_64.tar.gz
sudo tar fvxz R*.tar.gz -C /
rm R*.tar.gz
View gist:66b0e96d89a4ae3750d04e0e7fcc5651
/* -------------------------------------------------------
*
* !! This file was generated by xaringanthemer !!
*
* Changes made to this file directly will be overwritten
* if you used xaringanthemer in your xaringan slides Rmd
*
* Issues or likes?
* - https://github.com/gadenbuie/xaringanthemer
* - https://www.garrickadenbuie.com
@pat-s
pat-s / addins.json
Last active Mar 2, 2020
Apply RStudio Desktop Settings
View addins.json
{
"styler::style_active_file": "Ctrl+Y",
"addmins::insert_dashes": "Ctrl+8",
"xaringan::inf_mr": "Ctrl+M",
"drake::rs_addin_loadd": "Ctrl+K",
"browse::browse": "Ctrl+B"
}