Skip to content

Instantly share code, notes, and snippets.

@remlapmot
remlapmot / TwoSampleMR-linux-debian-dependencies
Last active August 5, 2022 11:12
CRAN dependencies for TwoSampleMR R package to install the binary packages on Ubuntu instead of compiling from source
#!/bin/bash
sudo apt-get update -y &&
apt-get --with-new-pkgs upgrade -y &&
apt-get install -y gfortran \
libgmp-dev \
r-cran-ggplot2 \
r-cran-gridextra \
r-cran-cowplot \
r-cran-plyr \
r-cran-reshape2 \
@remlapmot
remlapmot / r-minor-version-update-packages.R
Created May 18, 2021 20:13
Install packages from previous minor version of R into new minor version of R
# Copy packages from previous minor version of R to new version of R library directory
# from https://community.rstudio.com/t/reinstalling-packages-on-new-version-of-r/7670/3
lib_loc <- "C:\\Users\\tom\\Documents\\R\\win-library\\4.0"
to_install <- unname(installed.packages(lib.loc = lib_loc)[, "Package"])
to_install
install.packages(pkgs = to_install)
@remlapmot
remlapmot / update
Last active December 15, 2022 20:20
Update packages on a Debian based Linux distro, e.g. Ubuntu, using apt
#!/bin/bash
# update Ubuntu packages as root
sudo apt-get update && sudo apt-get --with-new-pkgs upgrade -y
# Ensure /usr/lib/R/site-library is writeable
sudo chmod 777 -R /usr/lib/R/site-library
# Update R packages as root
sudo R -q -e "update.packages(ask = FALSE)"
@remlapmot
remlapmot / rstan-windows-config.R
Created April 1, 2021 09:55
rstan Windows configuration
dotR <- file.path(Sys.getenv("HOME"), ".R")
if (!file.exists(dotR)) dir.create(dotR)
M <- file.path(dotR, "Makevars.win")
if (!file.exists(M)) file.create(M)
cat("\n CXX14FLAGS += -mtune=native -O3 -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2",
file = M, sep = "\n", append = FALSE)
@remlapmot
remlapmot / rstan-linux-config.R
Last active April 1, 2021 09:54
rstan compiler on Ubuntu
# In Terminal install clang
# sudo apt-get install clang
dotR <- file.path(Sys.getenv("HOME"), ".R")
if (!file.exists(dotR)) dir.create(dotR)
M <- file.path(dotR, "Makevars")
if (!file.exists(M)) file.create(M)
cat("\nCXX14FLAGS=-O3 -march=native -mtune=native -fPIC",
"CXX14=clang++", # g++ # or clang++ but you may need a version postfix
file = M, sep = "\n", append = TRUE)
@remlapmot
remlapmot / install-rcurl-from-source.R
Last active March 26, 2021 21:51
Install RCurl from source on Windows 10 assuming Rtools40 installed
# In Rtools 4.0 run
# pacman -Syu
# pacman -S mingw-w64-{i686,x86_64}-curl
# pkg-config --libs libcurl
install.packages("RCurl")
@remlapmot
remlapmot / install-xml-from-source.R
Last active December 7, 2022 13:17
Install XML package from source on Windows 10 assuming Rtool40 installed
# In Rtools 4.0 run
# pacman -Syu
# pacman -S mingw-w64-{i686,x86_64}-libxml2
Sys.setenv(LOCAL_CPPFLAGS = "-I/mingw$(WIN)/include/libxml2")
Sys.setenv(LIB_XML = "$(MINGW_PREFIX)")
install.packages("XML")
@remlapmot
remlapmot / ntreset.ps1
Created February 9, 2021 08:37
Flush DNS and winsock reset - hopefully a fix for my network adaptor repeatedly disconnecting
ipconfig /flushdns
netsh winsock reset
@remlapmot
remlapmot / update-git-for-windows.ps1
Created January 14, 2021 15:17
Update git for Windows
git update-git-for-windows
@remlapmot
remlapmot / keybindings.json
Created December 24, 2020 19:05
Keyboard shortcuts for VS Code; %appdata%/code/user
// Place your key bindings in this file to override the defaultsauto[]
[
{
"key": "ctrl+enter",
"command": "workbench.action.terminal.runSelectedText"
}
]