Skip to content

Instantly share code, notes, and snippets.

@jimbrig
jimbrig / bsTheme.R
Created August 27, 2024 15:19 — forked from jtrive84/bsTheme.R
Function to change shiny bootstrap theme
sfThemeSelector = function() {
# --------------------------------------------------------------------------
# Allow dynamic update of bootstrap theme.
# --------------------------------------------------------------------------
div(
div(
selectInput(
"shinytheme-selector", "Select theme:",
c("default", shinythemes:::allThemes()),
@jimbrig
jimbrig / index.md
Created August 26, 2024 15:15 — forked from jcheng5/index.md
Resources for "Shiny × AI" by Joe Cheng, at posit::conf(2024)
@jimbrig
jimbrig / llm_factory.py
Created August 17, 2024 18:34 — forked from daveebbelaar/llm_factory.py
LLM Factory with Instructor
from typing import Any, Dict, List, Type
import instructor
from anthropic import Anthropic
from config.settings import get_settings
from openai import OpenAI
from pydantic import BaseModel, Field
class LLMFactory:
@jimbrig
jimbrig / chrome_flags.updated.js
Created August 15, 2024 19:59 — forked from kkeybbs/chrome_flags.updated.js
Backup chrome flags to json and restore the backup on another machine.
// 2022-04-03, tested with Chrome 99.0.4844.84 on MacBook Pro m1
/*
Open chrome://flags/
F12 open developer console, swtich to tab "Console"
Paste below codes
- input backup() to download flags backup file
- input restore() to select one backup to restore
*/
function saveFile(filename, data) {
@jimbrig
jimbrig / UsefulAttributes.md
Created August 7, 2024 01:03 — forked from StartAutomating/UsefulAttributes.md
Potentially Useful Attributes in PowerShell

PowerShell, as a language, is very self-discoverable.

When you Get-Command, you get a rich object about a command.

This can have a lot of metadata.

You can and should also use inline help (like this script does).

Sometimes, I want more metadata than the command or parameter can actually provide.

@jimbrig
jimbrig / pluck_recursive.R
Created June 28, 2024 22:43 — forked from wch/pluck_recursive.R
From a tree, recursively pluck all elements with a particular name
# @drob's version from https://twitter.com/drob/status/1501747414780239879
pluck_recursive <- function(lst, name) {
if (is.list(lst)) {
if (!is.null(lst[[name]])) {
return(lst[[name]])
}
return(unname(unlist(purrr::map(lst, pluck_recursive, name))))
}
}
@jimbrig
jimbrig / gist:0f5a53b44ae75193eefdcc14df04b3f6
Created June 27, 2024 17:00 — forked from pitch-gist/gist:2999707
HTML: Simple Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
@jimbrig
jimbrig / README.md
Created June 21, 2024 22:36 — forked from jcheng5/README.md
Accepting POST requests from Shiny

Accepting POST requests from Shiny

(This post was motivated by a talk by @jnolis at CascadiaRConf 2021)

Recent versions of Shiny have an undocumented feature for handling POST requests that are not associated with any specific Shiny session. (Note that this functionality is missing our normal level of polish; it's a fairly low-level hook that I needed to make some things possible, but doesn't make anything easy.)

In a nutshell, it works by replacing your traditional ui object with a function(req), and then marking that function with an attribute indicating that it knows how to handle both GET and POST:

library(shiny)
/* --------------------------------
Typography
-------------------------------- */
:root {
--font-primary: sans-serif;
--font-secondary: serif;
@jimbrig
jimbrig / signatureTemplate.tex
Created May 29, 2024 17:45 — forked from tudorcoman/signatureTemplate.tex
LaTex signature template (useful for contracts between companies)
\documentclass[a4paper,twoside,11pt]{article}
\usepackage{delarray}
\usepackage{fancyhdr}
\usepackage[cp1250]{inputenc}
\usepackage[T1]{fontenc}
\pagestyle{fancyplain} \fancyfoot[LE,RO]{\thepage} \cfoot{}
\renewcommand{\headrulewidth}{0pt}
\headheight=14pt