Skip to content

Instantly share code, notes, and snippets.

@remlapmot
remlapmot / update-r-packages-macos
Last active June 17, 2025 12:58
Update brew packages and R package for x86_64 and aarch64 and Stata on macOS
#!/usr/bin/env zsh
# Update Homebrew packages
brew upgrade --greedy
brew cleanup
# uv python install --reinstall 3.13
uv tool upgrade --all
mas upgrade
@remlapmot
remlapmot / install-gmp-from-source-macos.R
Last active August 12, 2022 08:45
Install gmp R package from source on macOS
# Install gmp from source
#
# * brew install gmp # gets latest gmp
# * obtain gmp from here https://mac.r-project.org/libs/ and follow instructions at bottom of page
# For some reason using Sys.setenv() didn't work so copy files from /opt/homebrew/Cellar/gmp/6.2.1_1/ subdirectories
# (include, lib, share) to /usr/local subdirectories
# Sys.setenv(C_INCLUDE_PATH="/opt/homebrew/Cellar/gmp/6.2.1_1/include:/opt/homebrew/Cellar/gmp/6.2.1_1/lib")
install.packages("gmp", type = "source")
@remlapmot
remlapmot / install-cairo-from-source-macos.R
Last active March 18, 2022 17:38
Install Cairo package from source on macOS
# install Cairo from source
# see https://www.mail-archive.com/[email protected]/msg06281.html
Sys.setenv(C_INCLUDE_PATH="/opt/X11/include")
install.packages("Cairo", type = "source")
@remlapmot
remlapmot / stop
Created March 18, 2022 11:53
Stop an RStudio Server session
#!/usr/bin/bash
sudo rstudio-server stop
@remlapmot
remlapmot / start
Created March 18, 2022 11:53
Launch an RStudio Server session, then go to in browser localhost:8787
#!/usr/bin/bash
sudo rstudio-server start
@remlapmot
remlapmot / rserver.conf
Created March 17, 2022 10:24
RStudio server configuration file to prevent sign out after 1 or 2hrs inactivity, location on Ubuntu /etc/rstudio
# Server Configuration File
auth-timeout-minutes=0
auth-stay-signed-in-days=100
@remlapmot
remlapmot / force-discard-changes.sh
Last active February 27, 2022 18:19
Use if discard changes in GitHub Desktop fails
git rm --cached -r .
git reset --hard
@remlapmot
remlapmot / update_r_win.ps1
Last active December 15, 2022 20:21
Update R on Windows - launch Powershell terminal as Administrator and assuming R.exe is on the PATH
R.exe -e "update.packages(ask = FALSE, repos = 'https://cran.rstudio.com')"
@remlapmot
remlapmot / tinytex-pkgs.R
Last active March 3, 2022 09:16
Install useful CTAN packages to install in TinyTeX
update.packages(ask = FALSE)
if (!requireNamespace('markdown', quietly = TRUE)) install.packages('markdown')
# if (!requireNamespace('pdftools')) install.packages('pdftools')
if (!requireNamespace('magick', quietly = TRUE)) install.packages('magick')
if (!requireNamespace('kable', quietly = TRUE)) install.packages('kable')
if (!requireNamespace('tinytex', quietly = TRUE)) install.packages('tinytex')
@remlapmot
remlapmot / r-packages
Created February 10, 2022 17:30
System dependencies and R packages for installing on a fresh Ubuntu installation
#!/usr/bin/env bash
sudo apt-get update -y && sudo apt-get --with-new-pkgs upgrade -y
sudo apt-get install -y \
build-essential \
libcurl4-openssl-dev \
libssl-dev \
libfreetype6-dev \
libmagick++-dev \