Skip to content

Instantly share code, notes, and snippets.

View simonw's full-sized avatar

Simon Willison simonw

View GitHub Profile
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[338],{578:(e,t,r)=>{e.exports=r.p+"7cf7ced34f0a1ece31b4.wasm"},338:(e,t,r)=>{var n;r.r(t),r.d(t,{default:()=>a});const a=(n="file:///private/tmp/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/emscripten-module.browser.mjs",function(e={}){var t,a,o=e;function i(e){e={log:e||function(){}};for(const t of i.za)t(e);return o.quickJSEmscriptenExtensions=e}o.ready=new Promise(((e,r)=>{t=e,a=r})),i.za=[],o.quickjsEmscriptenInit=i,i.za.push((e=>{e.getWasmMemory=function(){return Q}}));var _,u=Object.assign({},o),l="./this.program",s="object"==typeof window,f="function"==typeof importScripts,S="";(s||f)&&(f?S=self.location.href:"undefined"!=typeof document&&document.currentScript&&(S=document.currentScript.src),n&&(S=n),S=0!==S.indexOf("blob:")?S.substr(0,S.replace(/[?#].*/,"").lastIndexOf("/")+1):"",f&&(_=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}));var c,T=o.print||con
@simonw
simonw / METADATA
Last active February 28, 2024 00:36
Flattened directory of the files from the whl for https://pypi.org/project/testcontainers-postgres
Metadata-Version: 2.1
Name: testcontainers-postgres
Version: 0.0.1rc1
Summary: PostgreSQL component of testcontainers-python.
Home-page: https://github.com/testcontainers/testcontainers-python
Requires-Python: >=3.7
Description-Content-Type: text/x-rst
Requires-Dist: testcontainers-core
Requires-Dist: sqlalchemy
Requires-Dist: psycopg2-binary
import sqlite3
# Connect to the test.db database
conn = sqlite3.connect(":memory:")
cursor = conn.cursor()
# Create the news table
cursor.execute(
"""
CREATE TABLE IF NOT EXISTS news (

I made this Toga app as a Bash one-liner:

python -c '
import toga
import urllib.request
import json

def fetch_json(url):
    with urllib.request.urlopen(url) as response:
 if response.getcode() == 200:
This file has been truncated, but you can view the full file.
BEGIN TRANSACTION;
CREATE TABLE [ios] (
[ios] TEXT,
[path] TEXT,
[parent] TEXT,
[filename] TEXT,
[languages] TEXT
);
INSERT INTO "ios" VALUES('iOS1','/Applications/Calculator.app/Calculator','/Applications/Calculator.app','Calculator','["Objective-C"]');
.grow-wrap {
/* easy way to plop the elements on top of each other and have them both sized based on the tallest one's height */
display: grid;
}
.grow-wrap::after {
/* Note the weird space! Needed to preventy jumpy behavior */
content: attr(data-replicated-value) " ";
/* This is how textarea text behaves */
white-space: pre-wrap;
@simonw
simonw / datasette_table_in_flet.py
Created September 18, 2023 15:35
Showing data from Datasette in Flet
# pip install flet httpx
import flet as ft
import httpx
def main(page: ft.Page):
rows = httpx.get("https://simon.datasette.cloud/data/hacker_news_posts.json?_sort_desc=dt").json()["rows"]
first_row = rows[0]
page.scroll = ft.ScrollMode.ALWAYS
page.add(
@simonw
simonw / README.md
Created September 10, 2023 17:15
SQLite micro-benchmark with Python threading

I got GPT-4 Code Interpreter to write most of this for me, transcript here

I had to modify it a tiny bit to get it to run, the parameters for the queries were missing.

Results on my M2 MacBook Pro:

---------------
Mode | Scenario | Update QPS | Select QPS
---------------
@simonw
simonw / review-changes.sh
Created August 23, 2023 01:47
Script for reviewing every change to every file in a current Git repo and rejecting or keeping it
#!/bin/bash
# Get the list of changed files
files=$(git diff --name-only)
# Loop through each changed file
for file in $files; do
# Show the diff of the file
git diff $file

2023-08-22T20:18:12 conversation: 01h8fec5xgr78z9pyfmdgnwy33

Model: mlc-chat-Llama-2-13b-chat-hf-q4f16_1

Prompt:

Five cute names for a pet weasel

Response: