Skip to content

Instantly share code, notes, and snippets.

@remlapmot
remlapmot / update-r-packages-macos
Last active June 6, 2024 17:13
Update brew packages and R 4.2.# package for x86_64 and aarch64 and Stata on macOS
#!/usr/bin/env zsh
# Update Homebrew packages
brew upgrade
# Update packages on R Apple Silicon aarch64 arch
R -q -e 'options(repos = c(personal = "https://remlapmot.r-universe.dev/", universe = "https://mrcieu.r-universe.dev/", CRAN = "https://cran.rstudio.com/")); if (!is.null(old.packages())) update.packages(ask = FALSE, type = "source", Ncpus = 4); remotes::update_packages()'
# Update StataMP on 10th, 20th, 30th of each month
DD=$(date +%d)
@remlapmot
remlapmot / local.conf
Created April 12, 2020 09:05
Allow WSL to use fonts installed on Windows. File location: /etc/fonts
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<dir>/mnt/c/Windows/Fonts</dir>
</fontconfig>
@remlapmot
remlapmot / update-packages.R
Last active May 29, 2024 09:59
Solution to: Warning: package '#' in library '/usr/lib/R/library' will not be updated
# Solution to Linux warning message
# Warning: package '#' in library '/usr/lib/R/library' will not be updated
update.packages(oldPkgs = old.packages(), ask = FALSE)
@remlapmot
remlapmot / 4k-windows-resize-after-sleep-fix.reg
Last active May 6, 2024 17:22
Windows 10 registry entry setting which fixes PrimSurfSize.cx, PrimSurfSize.cy, and Stride values for a 4K monitor, so windows do not resize after sleep (an issue which seems to affect some Dell computers)
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\GraphicsDrivers\Configuration\NOEDID_8086_3E98_00000000_00020000_31063^9B5CF2A2AB5D52EABA55D3D249C48521]
"SetId"="NOEDID_8086_3E98_00000000_00020000_31063"
"Timestamp"=hex(b):7c,f5,a9,74,7f,f1,d5,01
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\GraphicsDrivers\Configuration\NOEDID_8086_3E98_00000000_00020000_31063^9B5CF2A2AB5D52EABA55D3D249C48521\00]
"PrimSurfSize.cx"=dword:00000f00
"PrimSurfSize.cy"=dword:00000870
"Stride"=dword:00003c00
@remlapmot
remlapmot / restart-gpgagent.sh
Created July 11, 2022 07:59
gpg-agent should restart when required after being killed as follows
#!/bin/bash
gpgconf --kill gpg-agent
@remlapmot
remlapmot / r-cmd-check-as-cran.R
Last active April 8, 2024 12:42
Run devtools::check() as CRAN
# Run check as CRAN (well sort of)
devtools::check(env_vars = c(NOT_CRAN = FALSE))
devtools::check(env_vars = c(NOT_CRAN = FALSE), cran = TRUE, force_suggests = TRUE, incoming = TRUE)
# Additionally not building/re-running the vignettes
devtools::check(
env_vars = c(NOT_CRAN = FALSE),
args = c(
'--no-manual',
# Amendment from https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Data-in-packages
# https://stat.ethz.ch/pipermail/r-devel/2022-July/081873.html
CheckLazyDataCompression <- function(pkg)
{
pkg_name <- sub("_.*", "", pkg)
lib <- tempfile(); dir.create(lib)
zs <- c("gzip", "bzip2", "xz")
res <- double(3); names(res) <- zs
for (z in zs) {
opts <- c(paste0("--data-compress=", z),
@remlapmot
remlapmot / settings.json
Last active April 3, 2024 11:05
Zed settings
// Zed settings
//
// For information on how to configure Zed, see the Zed
// documentation: https://zed.dev/docs/configuring-zed
//
// To see all of Zed's default settings without changing your
// custom settings, run the `open default settings` command
// from the command palette or from `Zed` application menu.
{
"theme": "Rosé Pine Moon",
@remlapmot
remlapmot / brew-install-temurin.sh
Created April 2, 2024 10:38
Installing Java on Apple Silicon macOS for rJava R package to work
brew install temurin
@remlapmot
remlapmot / default.Rmd
Last active February 7, 2024 11:51
Default R Markdown file to use in RStudio (from v1.3). File location: %appdata%\rstudio\templates ; on Mac/Linux: ~/.config/rstudio/templates
---
title: "Title"
author: "My Name"
date: "`r format(Sys.time(), '%d %B %Y')`"
output:
html_document:
toc: true
toc_float:
collapsed: false
smooth_scroll: false