Skip to content

Instantly share code, notes, and snippets.

@simonpcouch
simonpcouch / mcp_client_demo.R
Created May 20, 2025 14:44
A demo implementation of the MCP client protocol in R
# an example server: acquaint's MCP server for R sessions
r_process <- callr::r_bg(
function() acquaint::mcp_server(),
stdout = "|",
stdin = "|"
)
Sys.sleep(1)
log_cat_client <- function(x, append = TRUE) {
@jimbrig
jimbrig / .env.example
Created May 14, 2025 15:40
Yahoo Fantasy Sports API - Python Scripts
YAHOO_CLIENT_ID=""
YAHOO_CLIENT_SECRET=""
@HighLibrarian
HighLibrarian / MyPowerShellProfile.ps1
Last active May 20, 2025 09:51
DailyPowerShellProfile
<#
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@@@@@@@@@@@@@@@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@#-:**************=*@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-%+=%%%%%%%%%%%%%%-#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%##%%%%%%%%%%%%%%%%%%%%%%%:*%%=+%%%%%%%%%%%%%%.#@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%#@%%%%%%%%%%%%%%%%%%@%%*#@%%@+%%%%%%%%%%%%%%%+%@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
<#
.SYNOPSIS
Perform Git submodule update to any commit and/or branch.
.DESCRIPTION
This script performs Git submodules updates to any commit and/or branch.
It allows you to update a submodule to the latest commit, to a specific commit, or to the latest/specific commit of a specific branch.
It will automatically commit the changes to the parent repository, and optionally also push them to the remote repository.
.PARAMETER pathToLocalRepo
@simonpcouch
simonpcouch / CLAUDE.md
Created March 26, 2025 15:44
An example `CLAUDE.md` prompt for R package development

You are situated inside of an R package source directory. The subdirectory R/ contains source files. The subdirectory tests/testthat/ contains corresponding tests. e.g. R/task.R is tested primarily in tests/testthat/test-task.R.

Do not add new code comments, and only remove existing code comments if the comment isn't relevant anymore.

The package has not yet been published and does not have any users; remove functionality outright when it's no longer needed rather than beginning a deprecation process. No need to worry about breaking changes.

When testing code that raises a message, warning, or error, use expect_snapshot() (possibly with error = TRUE) instead of expect_message() or otherwise.

When you're running package tests, use devtools::load_all(); testthat::test_file("tests/testthat/path-to-file.R"). If you encounter namespacing issues, don't delete tests that otherwise should work, and instead ask me what to do.

@smach
smach / app_ollama.R
Last active March 21, 2025 16:25
Sample R Shiny app to run local models with an Ollama server. Coded mostly by various LLMs including Posit's Shiny Assistant
# This is a sample R Shiny app chatbot that runs local models with an Ollama server.
# You also need Ollama installed and a ollama server running, plus at least one local model pulled.
# I hard-coded a few local models,
# If you use this, you'll want to hard code yours (including descriptions, or take those out)
# Coded with lots of LLM help + Posit's Shiny Assistant.
library(shiny)
library(shinychat)
library(bslib)
@smach
smach / favicon_app.R
Last active March 12, 2025 13:46
R Shiny app to turn JPGs and PNGs into .ico favicon files. Written mostly by GPT o3-mini-high with help from Claude and Shiny Assistant (and me)
options(shiny.maxRequestSize = 5 * 1024^2) # Limit uploads to 5 MB
library(shiny)
library(magick)
library(base64enc)
library(bslib)
# Helper function to sanitize file names
safeFileName <- function(filename) {
gsub("[^a-zA-Z0-9_.-]", "_", filename)
@dylanpieper
dylanpieper / roxynorm-prefix.md
Last active March 2, 2025 19:15
Pal prompt for roxygen normalization

Roxygen Normalization

You are a terse assistant designed to help R users write roxygen documentation according to CRAN and tidy style with a consistent format. Respond with only the needed R code, no backticks or newlines around the response. Intersperse newlines within function calls as needed, per tidy style.

As example, given the input:

#' app
#'
#' this makes an app
@SMSAgentSoftware
SMSAgentSoftware / Invoke-AIChat.ps1
Last active June 2, 2025 20:23
PowerShell script to chat interactively with various AI models using their REST APIs. Requires API keys stored in an Azure KeyVault.
function Invoke-AIChat {
<#
.SYNOPSIS
Invokes an AI chat model to generate responses based on user prompts.
.DESCRIPTION
This function provides a unified interface to interact with various AI language model providers including:
- Azure OpenAI Services
- OpenAI API
- Anthropic Claude
@disler
disler / README.md
Last active August 18, 2025 09:58
Use Meta Prompting to rapidly generate results in the GenAI Age

Meta Prompting

In the Generative AI Age your ability to generate prompts is your ability to generate results.

Guide

Claude 3.5 Sonnet and o1 series models are recommended for meta prompting.

Replace {{user-input}} with your own input to generate prompts.

Use mp_*.txt as example user-inputs to see how to generate high quality prompts.