Skip to content

Instantly share code, notes, and snippets.

View mhpob's full-sized avatar

Mike O'Brien mhpob

View GitHub Profile

These are instructions on how to set up SSH into a WSL system on a remote server. They loosely follow the instructions here https://superuser.com/questions/1622581/ssh-into-wsl-from-another-machine-on-the-network. Assume the Windows Host's name is my.windowshost and your user name is me (so [email protected]) and that your user name on the Windows host's WSL is wsl_me. It does not seem to matter what the WSL host name is: we'll be using localhost for the WSL as we're forwarding traffic through the Windows host (my.windowshost in our example).

  1. Set up OpenSSH on the Windows host (just Google how to do this)
@mhpob
mhpob / remote-wsl.md
Created August 30, 2024 00:18 — forked from mattbell87/remote-wsl.md
VSCode Remote: Connect to WSL2 from another machine

VSCode Remote: Connect to WSL2 from another machine

Do you want to do remote development on your WSL2 container in Visual Studio Code? Read this.

Proxy jump method

  1. On the host set up OpenSSH for Windows
  2. Run wsl --update to make sure you are running the latest WSL
  3. Open WSL and install another SSH server inside WSL with sudo apt-get install openssh-server
  4. Now run sudo systemctl enable --now ssh to automatically start ssh when WSL starts.
@mhpob
mhpob / caveplot.R
Last active March 17, 2022 20:35
"Cave plot" proof of concept
library(dplyr)
df_north <- tibble(
week = 1:53,
N = sample(0:15, 53, replace = T)
)
df_south <- tibble(
week = 1:53,
@mhpob
mhpob / mgcv_random_effects.R
Last active August 24, 2023 18:00
Random effects specifications
## This was originally used in review, where Year was nested within Blocks
library(mgcv)
# In the BodyWeight data, Rat is nested in Diet with no repeated Rats across Diets
# Analogous to Year nested in Blocks with no repeated Years across Blocks
data('BodyWeight')
# Dummy code levels of Diet as for YearBlock in manuscript
BodyWeight$Diet1 <- ifelse(BodyWeight$Diet == 1, 0, 1)
@mhpob
mhpob / reilly-field
Created April 19, 2021 14:05
Check JRA field conditions with Powershell
[xml]$Content = Invoke-WebRequest -Uri "https://water.weather.gov/ahps2/hydrograph_to_xml.php?gage=rmdv2&output=xml"
$smry = $content.site.forecast.datum.primary."#text" | measure -Minimum
if($smry.minimum -lt 5.5){
New-BurntToastNotification -Text "Get ready to go sampling!" ,
"Richmond-Westham is forecast to be <5.5 ft."
}
@mhpob
mhpob / loop_chunks.md
Last active April 19, 2021 14:05
Programmatically create RMarkdown chunks

The following was adapted from the blog post here.

The key is to use results = "asis". More information can be found here. Basically:

  • anything output with cat() will be evaluated as RMarkdown.
  • anything output with print() will be evaluated with R.
for(i in seq(min(station_key$year), max(station_key$year), 1)){
  
@mhpob
mhpob / mgcv_errs.md
Last active January 31, 2025 15:45
mgcv errors and description on how to fix

mgcv

gam

Error in gam.reparam(UrS, sp, grderiv) : NA/NaN/Inf in foreign function call (arg

You're likely trying to take the log of zero.

bam(~s(, bs = 'so'))

# Create track
set.seed(8675309)
turning_angles <- runif(100, 0, 2*pi)
runs <- runif(100, 0, 50)
fake_track <- data.frame(x = 0,
y = 0,
t = 1)
@mhpob
mhpob / prune-local
Last active April 19, 2021 14:06
Delete and prune local branches that no longer exist.
git branch -d branch-to-delete
git fetch -p