https://speakerdeck.com/jcheng5/shiny-x-ai
- Video input and audio spinner controls: {shinymedia}, for R and Python
- Video assistant example app
- R version: source
| #Requires -Modules @{ ModuleName = 'PwshSpectreConsole'; RequiredVersion = '2.1.1' } | |
| Set-SpectreColors -AccentColor DeepPink1 | |
| # Build root layout scaffolding for: | |
| # .--------------------------------. | |
| # | Title | <- Update-TitleComponent will render the title | |
| # |--------------------------------| | |
| # | | <- Update-MessageListComponent will display the list of messages here | |
| # | | |
| <# | |
| .SYNOPSIS | |
| PUT SHORT SCRIPT DESCRIPTION HERE AND ADD ANY ADDITIONAL KEYWORD SECTIONS AS NEEDED (.PARAMETER, .EXAMPLE, ETC.). | |
| #> | |
| [CmdletBinding()] | |
| param ( | |
| # PUT PARAMETER DEFINITIONS HERE AND DELETE THIS COMMENT. | |
| ) | |
| process { |
| function Invoke-ScriptBlockWithRetries { | |
| [CmdletBinding(DefaultParameterSetName = 'RetryNonTerminatingErrors')] | |
| param ( | |
| [Parameter(Mandatory = $true, HelpMessage = "The script block to execute.")] | |
| [ValidateNotNull()] | |
| [scriptblock] $ScriptBlock, | |
| [Parameter(Mandatory = $false, HelpMessage = "The maximum number of times to attempt the script block when it returns an error.")] | |
| [ValidateRange(1, [int]::MaxValue)] | |
| [int] $MaxNumberOfAttempts = 5, |
| .PHONY: buildsite check clean coverage docs getwd initialize install load render setwd start test usegit | |
| .DEFAULT_GOAL := help | |
| define BROWSER_PYSCRIPT | |
| import os, webbrowser, sys | |
| from urllib.request import pathname2url | |
| # The input is expected to be the full HTML filename | |
| filename = sys.argv[1] | |
| filepath = os.path.abspath(os.path.join("./vignettes/", filename)) |
| sfThemeSelector = function() { | |
| # -------------------------------------------------------------------------- | |
| # Allow dynamic update of bootstrap theme. | |
| # -------------------------------------------------------------------------- | |
| div( | |
| div( | |
| selectInput( | |
| "shinytheme-selector", "Select theme:", | |
| c("default", shinythemes:::allThemes()), |
https://speakerdeck.com/jcheng5/shiny-x-ai
| 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: |
| // 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) { |
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.
| # @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)))) | |
| } | |
| } |