Skip to content

Instantly share code, notes, and snippets.

View simonw's full-sized avatar

Simon Willison simonw

View GitHub Profile
@harperreed
harperreed / prompt.txt
Created March 10, 2024 15:58
security robot prompt
You are a security robot. Your job is to observe and report any activity. Specifically, notice the people and what they are doing.
Context:
This is the front of an office space
People enter and exit from the office via the red door
There is aa couch and some chairs that people may be sitting on. There is also a snack area, and an area with equipment. right of the image.
Return JSON.
{
@sakopov
sakopov / OIDC_for_Github.md
Last active January 5, 2024 22:46
OIDC for Github and AWS

Some rough cloudformation to add OIDC support for Github in AWS.

  1. Create new identity provider for Github. (1b511abead59c6ce207077c0bf0e0043b1382612 is the known thumbprint for Github).

Note, you can discover current thumbprint using openssl.

 $ openssl s_client -servername token.actions.githubusercontent.com -showcerts -connect token.actions.githubusercontent.com:443 <    /dev/null 2>/dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sed "0,/-END CERTIFICATE-/d" > certificate.crt
 $ openssl x509 -in certificate.crt -fingerprint -noout | cut -f2 -d'=' | tr -d ':' | tr '[:upper:]' '[:lower:]'
 1b511abead59c6ce207077c0bf0e0043b1382612
@rsbohn
rsbohn / digger.py
Last active September 14, 2023 21:25
"get embeddings from an LLM database"
# LICENSE https://www.apache.org/licenses/LICENSE-2.0.txt
# Copyright (C) Randall Bohn 2023
# requires: llm>=0.9, sqlite_utils, numpy, umap-learn==0.5.3
from typing import Dict
import llm
import numpy as np
from sqlite_utils import Database
from umap import UMAP
@samuelcolvin
samuelcolvin / aicli.py
Last active March 2, 2024 16:04
OpenAI powered AI CLI in just a few lines of code - moved to https://github.com/samuelcolvin/aicli
#!/usr/bin/env python3
import os
from datetime import datetime, timezone
from pathlib import Path
from prompt_toolkit import PromptSession
from prompt_toolkit.history import FileHistory
import openai
from rich.console import Console
from rich.markdown import Markdown
@CharlesNepote
CharlesNepote / csv2datasette
Last active March 17, 2024 17:02
csv2datasette
#!/usr/bin/env bash
# sudo ln -s "$(pwd)/csv2datasette" /usr/bin/csv2datasette
# csv2datasette is meant to explore CSV data. It is not meant to create a sustainable DB.
# csv2datasette is a bash script which open CSV files directly in Datasette. It offers
# a number of options for reading and exploring CSV files, such as --stats, inspired by WTFCsv.
#
# `--stats` option includes, for each column: the column name, the number of unique values,
# the number of filled rows, the number of missing values, the mininmum value, the maximum value,
# the average, the sum, the shortest string, the longest string, the number of numeric values,
@adactio
adactio / previewImageUploads.js
Created May 12, 2022 13:33
Show inline previews of images that are going to be uploaded.
// Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
// http://creativecommons.org/publicdomain/zero/1.0/
(function (win,doc) {
'use strict';
if (!win.FileReader || !win.addEventListener || !doc.querySelectorAll) {
// doesn't cut the mustard.
return;
}
doc.querySelectorAll('input[type="file"][accept="image/*"]').forEach( function (fileInput) {
@palewire
palewire / README.md
Last active May 24, 2023 18:09
How to deploy a Prefect agent to Google Kubernetes Engine

How to deploy a Prefect agent to Google Kubernetes Engine

This post contains code and commands you can use to deploy Prefect agents to Google Cloud’s Google Kubernetes Engine. The agents stand ready to execute workflows triggered by Prefect projects. One agent can run tasks from multiple projects.

The example here demonstrates how to create a single agent with minimal customization. It is configured with a Dockerfile, which installs necessary dependencies, and a k8s.cfg file, which connects the system to a Prefect account.

Agents are deployed via the gcloud command-line utility and its kubectl extension. Proper permissions within a project on Google Cloud are required.

Getting started

@kristoferjoseph
kristoferjoseph / single-file-web-component.html
Last active November 22, 2023 01:17
Single file Web Component
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Single File Web Component</title>
</head>
<body>
<template id=single-file>
<style>
h1 {
@tombulled
tombulled / app.py
Created November 15, 2020 20:37
Stream a file, in this case an mp4 video, supporting range-requests using starlette
from starlette.applications import Starlette
from starlette.responses import StreamingResponse
from starlette.requests import Request
from starlette.routing import Route
from pathlib import Path
from typing import IO, Generator
"""
Stream a file, in this case an mp4 video, supporting range-requests using starlette
@psychemedia
psychemedia / sqlite_utils_magic.ipynb
Last active October 22, 2020 06:36
Proof of concept sqlite_utils magic
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.