Skip to content

Instantly share code, notes, and snippets.

@JohannesNE
JohannesNE / sin_tangents.jl
Created December 2, 2021 20:37
Draw a lot of tangets to a sine function
using Plots, Colors
f = sin
f´ = cos
p = plot(xlim = [-2pi, 7pi],
ylim = [-6,6],
lw= 0,
axis = nothing, border = :none)
library(rethinking)
library(cmdstanr)
library(microbenchmark)
X <- data.frame(x = rnorm(100, 9, 2))
fit_mean <- function(cmdstan) {
ulam(
alist(
x ~ normal( mu , Sigma ),
@JohannesNE
JohannesNE / qgam-example.R
Created January 15, 2021 11:48
qgam example
library(mgcv)
library(qgam)
library(tidyverse)
sim_dat <- tibble(time = 1:3000,
fast_c = (time %% 200)/200,
slow_c = (time %% 1150)/1150,
y_true = cos(pi*time/3000) +
5 * sin(2*pi*fast_c) +
2 * sin(2*pi*slow_c) +
@JohannesNE
JohannesNE / SV_sim.txt
Last active November 9, 2020 15:21
simulation of SV for R class
"thermal_dilution","pulse_contour"
73.6317625920867,75.342554906171
68.3712285703488,74.082500899531
67.0337117990298,66.8924393201056
64.2693831313004,65.6735967597446
64.620159610125,65.8322281532869
69.9639802510737,69.331835531702
71.5659969030918,70.3730251974306
62.3863314333201,64.7182056319291
66.8118186534452,71.9397699945955
@JohannesNE
JohannesNE / test-VSCaptureDrgVent.R
Created February 21, 2020 11:58
For testing/visualising VSCaptureDrgVent realtime waveforms
library(tidyverse)
library(ggplot2)
# Path to folder with CSVs
path <- '~/path/to/folder'
pressure <- read_csv(paste0(path, 'Airway_pressureDrgWaveExport.csv'),
col_names = c('time', 'unix_ms', 'pressure', 'insp'),
col_types = list(col_datetime(format = '%m/%d/%Y %H:%M:%S'),
col_double(),
@JohannesNE
JohannesNE / pin-bigquery-project.md
Last active June 12, 2021 15:46
How to pin a bigquery dataset shared with you in the new UI
@JohannesNE
JohannesNE / importphotos
Last active April 5, 2023 21:43
Python command line script to import photos from SD card to folder with today's date.
#!/usr/bin/env python3
'''
Import photos from SD card into folder with todays date + nickname
Use: importphotos (--jpg|--raw|--both) <nickname of folder (optional)>
Add script to path
'''
import os
import sys

Keybase proof

I hereby claim:

  • I am johannesne on github.
  • I am enevoldsen (https://keybase.io/enevoldsen) on keybase.
  • I have a public key ASCrocouH9zpmhNNmE6MTUQLnKZU4zJmcFpB-8bxaP9Jogo

To claim this, I am signing this object:

@JohannesNE
JohannesNE / gen_Citations.R
Last active April 5, 2023 21:40
Generate bibliography for R packages
#Generate .bib for base R + loaded R packages.
pat <- "package:(.*)"
packages <- sub(pat, "\\1", grep(pat, search(), value = TRUE))
cite_packages <- c("base", packages[-(which(packages == "stats"):length(packages))]) #Adds base R citation and removes base packages
capture.output(
for (i in cite_packages) print(citation(i), style = "Bibtex"),
file = "R_cite.bib")