Skip to content

Instantly share code, notes, and snippets.

View LukasWallrich's full-sized avatar

Lukas Wallrich LukasWallrich

View GitHub Profile
@LukasWallrich
LukasWallrich / osf_preprint_counts_by_server.json
Created February 23, 2026 09:37
OSF preprint counts per server 2025-08-25 to 2026-02-23
{
"start_date": "2025-08-25",
"end_date": "2026-02-23",
"servers": {
"psyarxiv": {
"name": "PsyArXiv",
"total": 6923,
"withdrawn": 16,
"active": 6907
},
@LukasWallrich
LukasWallrich / osf_preprint_counts_by_server.json
Created February 23, 2026 09:25
OSF preprint counts per server 2025-08-25 to 2026-02-23
{
"start_date": "2025-08-25",
"end_date": "2026-02-23",
"servers": {
"psyarxiv": {
"name": "PsyArXiv",
"count": 6923
},
"socarxiv": {
"name": "SocArXiv",
@LukasWallrich
LukasWallrich / osf_preprint_count.json
Created February 23, 2026 09:02
OSF preprint count 2025-08-25 to 2026-02-23
{
"start_date": "2025-08-25",
"end_date": "2026-02-23",
"total_preprints": 11577,
"query_url": "https://api.osf.io/v2/preprints/?filter%5Bdate_published%5D%5Bgte%5D=2025-08-25&filter%5Bdate_published%5D%5Blte%5D=2026-02-23&filter%5Bis_published%5D=true&page%5Bsize%5D=1"
}
@LukasWallrich
LukasWallrich / bibtex-to-apa.js
Created January 21, 2026 13:00
Bibtex to APA references
const { Cite } = require('@citation-js/core');
require('@citation-js/plugin-bibtex');
require('@citation-js/plugin-csl');
const fs = require('fs');
const DEFAULT_INPUT = 'https://docs.google.com/document/d/1-KKsOYZWJ3LdgdO2b2uJsOG2AmUDaQBNqWVVTY2W4W8/edit?tab=t.0';
const DEFAULT_OUTPUT = 'apa_lookup.json';
async function fetchBibtex(input) {
if (!input.startsWith('http')) {
@LukasWallrich
LukasWallrich / gist:2dbe7931dba1260b74512330c300d0e1
Created November 10, 2025 23:36
Effect size calculation for Dijkstra et al
``` r
# Study parameters
n1 <- 150 # Popular fiction
n2 <- 150 # Literary fiction
# Means and 95% CIs
m1 <- 27.233
ci1_lower <- 26.581
ci1_upper <- 27.885
@LukasWallrich
LukasWallrich / gist:01eae59cb003c143d1014f7a9a26e882
Created November 10, 2025 22:40
ML loss framing effect size calculation
``` r
# ============================================
# ORIGINAL STUDY (Tversky & Kahneman, 1981)
# ============================================
# Create contingency table
original <- matrix(c(
109, 43, # Gain frame: 72% chose A, 28% chose B
34, 121 # Loss frame: 22% chose C, 78% chose D
), nrow = 2, byrow = TRUE)
@LukasWallrich
LukasWallrich / crossref_by_dois.R
Created August 1, 2025 15:32
Get metadata for many crossref DOIs in one R call
library(httr)
library(jsonlite)
library(dplyr)
library(purrr)
library(stringr)
`%||%` <- function(a, b) if (!is.null(a)) a else b
extract_date <- function(x) {
if (is.null(x)) return(NA_character_)
@LukasWallrich
LukasWallrich / manual_dedup.R
Created April 5, 2024 11:51
A Shiny interface to deal with ASySD's manual dedup step
# Derived from revtools code, copyright Martin J Westgate
# Adapted by Lukas Wallrich, still unter GPL-3 licence
library(magrittr)
manual_dedup <- function(
df, cols = names(df), suffixes = c("1", "2"), id = "id"
){
input_data <- list(
@LukasWallrich
LukasWallrich / Gmodel.py
Last active February 14, 2023 17:09
Gmodel.py
# Model proposed by Grim et al
# with different perspectives added - i.e. shortcuts
# Used this to avoid duplicating files
import httpimport
url = "https://gist.githubusercontent.com/LukasWallrich/05f445821fbae694b37a205dc08b2b4f/raw/"
with httpimport.remote_repo(url):
from HPmodel import HPProblem, PSAgent
@LukasWallrich
LukasWallrich / my_data_color.R
Last active November 3, 2022 12:02
gt data_color extension to target column
my_data_color <- function (data, SOURCE_columns, TARGET_columns, colors, alpha = NULL, apply_to = c("fill",
"text"), autocolor_text = TRUE)
{
stop_if_not_gt(data = data)
apply_to <- match.arg(apply_to)
colors <- rlang::enquo(colors)
data_tbl <- dt_data_get(data = data)
colors <- rlang::eval_tidy(colors, data_tbl)
resolved_source_columns <- resolve_cols_c(expr = {
{