Skip to content

Instantly share code, notes, and snippets.

View mattocci27's full-sized avatar

Masatoshi Katabuchi mattocci27

View GitHub Profile
@eveyp
eveyp / renv_and_singularity.md
Last active September 5, 2022 05:53
renv and Singularity Containers

Using renv in Singularity Containers

The Problem

My HPC runs CentOS while the container is running Ubuntu Focal. This means that when packages link a system dependency, that system dependency might be in different places. So, I can't use the same built binaries for some packages because they'll break when a system dependency they need isn't where it is expected (this happens when a package is built in one OS but loaded in the other).

The Solution

To fix this I need to keep the CentOS and Ubuntu libraries separate from each other. This is simple enough when not using renv, but I'm looking for reproducibility, so I need an renv compatible way to keep the libraries separate.

To do this I define an Renviron.site file that will be used by the container that sets an environmental variables for a prefix for the renvcache and the project library. Then I bind mount the Renviron.site file in the container and renv picks up the environmental variable and keeps things separate.

@takenoco82
takenoco82 / using-docker-registry.md
Last active August 13, 2023 05:42
Docker Registry の使い方

Docker Registry の使い方

これは何?

  • Docker Registry の導入方法と設定のサンプル

Docker Registry を起動する

# 削除するためには REGISTRY_STORAGE_DELETE_ENABLED=true が必要
$ docker run -d -p 5000:5000 --name registry -e REGISTRY_STORAGE_DELETE_ENABLED=true registry:2
library(tidyverse)
library(broom)
library(lme4)

set.seed(1234)

# Make fake data
# 2x2x2 factorial design
df <- tibble(id = 1:1000, 
@udkyo
udkyo / Dockerfile
Last active September 6, 2025 05:56
Basic container for X11 forwarding goodness
FROM ubuntu
RUN apt update \
&& apt install -y firefox \
openssh-server \
xauth \
&& mkdir /var/run/sshd \
&& mkdir /root/.ssh \
&& chmod 700 /root/.ssh \
&& ssh-keygen -A \
&& sed -i "s/^.*PasswordAuthentication.*$/PasswordAuthentication no/" /etc/ssh/sshd_config \
@genkuroki
genkuroki / OLS and MLE examples.ipynb
Last active October 8, 2018 15:55
Julia/Baseball/OLS and MLE examples.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rmoff
rmoff / 00.README.md
Last active December 1, 2021 23:45
RMarkdown - repeating child block with changing variable value

When you use knit_expand it appears that the inclusion of the Rmd is done on the first pass, and then the complete document evaluated. This means that a Rmd block referenced in loop with knit_expand will only evaluate changing variables at their last value.

This can be worked around by passing the literal value of the variable at the time of the knit_expand with {{var}} syntax.

This is documented in the knitr_expand docs, but less clear (to an R noob like me) for embedded documents rather than strings.

@primaryobjects
primaryobjects / saveChart.R
Last active October 9, 2021 02:21
Add text outside the chart area of a ggplot2 graph in R and save the resulting chart to a png file.
require(ggplot2)
require(gridExtra)
saveChart <- function(chart, fileName) {
# Draw attribution.
chart <- chart + geom_text(aes(label = 'sentimentview.com', x = 2.5, y = 0), hjust = -2, vjust = 6, color="#a0a0a0", size=3.5)
# Disable clip-area.
gt <- ggplot_gtable(ggplot_build(chart))
gt$layout$clip[gt$layout$name == "panel"] <- "off"
data {
int<lower=1> N; // Number of samples
int<lower=1> M; // Number of dimensions
int<lower=1> K; // Number of mixtures. Set to 1,000 at the moment.
vector[M] y[N]; // Vector containing the NxM dimensional data
vector<lower=0>[K] alpha; // Parameter for Dirichlet prior. Set to 1.0/K in list of length K.
}
parameters {
simplex[K] theta; // Mixing proportions
@benmarwick
benmarwick / captions_and_crossrefs.rmd
Last active March 24, 2023 17:53
Auto-numbering and cross-referencing of figures and tables in rmarkdown
---
title: "Auto-numbering and cross-referencing of figures and tables in rmarkdown"
output: html_document
---
NOTE: I recommend using the bookdown package and `output: html_document2` to make captions and cross-references more easily than the method described below.
TODO: check this out: https://github.com/adletaw/captioner
Here's how to use:
@burke
burke / remotepaste.md
Last active August 17, 2025 02:36
This sets up keybindings in tmux that allow you to copy/paste to/from your OS X clipboard from tmux running inside an SSH connection to a remote host. Partially borrowed from http://seancoates.com/blogs/remote-pbcopy

Local (OS X) Side

~/Library/LaunchAgents/pbcopy.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
     <key>Label</key>
     <string>localhost.pbcopy</string>