Skip to content

Instantly share code, notes, and snippets.

View mbacou's full-sized avatar

Mel B. mbacou

View GitHub Profile

Using Google's generative APIs: lessons learned

Basics

  • The API key wasn't in the shell environment. It lives in ~/.Renviron, so the scripts fall back to reading GOOGLE_API_KEY from there.
  • Find model IDs by listing them, not by guessing marketing names: GET https://generativelanguage.googleapis.com/v1beta/models?pageSize=200 (the displayName field maps the two). The ones used:
@hadley
hadley / shiny-oauth.r
Last active November 3, 2026 22:07
Sketch of shiny + oauth
library(shiny)
library(httr)
# OAuth setup --------------------------------------------------------
# Most OAuth applications require that you redirect to a fixed and known
# set of URLs. Many only allow you to redirect to a single URL: if this
# is the case for, you'll need to create an app for testing with a localhost
# url, and an app for your deployed app.
@calligross
calligross / app.R
Last active August 23, 2023 17:22
Shiny Cookie Based Authentication Example, please visit https://calligross.de/post/using-cookie-based-authentication-with-shiny/ for more information.
library(shiny)
library(shinyjs)
if (!dir.exists('www/')) {
dir.create('www')
}
download.file(
url = 'https://cdn.jsdelivr.net/npm/js-cookie@2/src/js.cookie.min.js',
destfile = 'www/js.cookie.js'
@hadley
hadley / gist:837414
Created February 21, 2011 17:50
which-encoding.r
all <- iconvlist()
names(all) <- all
tries <- llply(all[330:350], function(cur) iconv(song$artist, cur, "UTF-8"))
vapply(tries, function(x) sum(is.na(x)), integer(1))