Skip to content

Instantly share code, notes, and snippets.

View bgrins's full-sized avatar

Brian Grinstead bgrins

View GitHub Profile

Create the project

If you don't already have one npm create vite@latest, and cd into the directory. Then:

git init
git add .
git commit -m "first-commit"
git branch -M main
@bgrins
bgrins / open-url.md
Last active January 20, 2023 20:19
Open URL in current iOS simulator

First open a simulator:

open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app

Then open a given URL in mobile Safari:

/Applications/Xcode.app/Contents/Developer/usr/bin/simctl openurl `/Applications/Xcode.app/Contents/Developer/usr/bin/simctl list | grep Booted | perl -ne'/\(([A-Z,0-9,-]+)\)/ && print "$1"'` "http://localhost:3000"
# Automatically restart datasette when a db file changes
sh -c '$PWD/scripts/restart-datasette.sh &' && fswatch -o fixtures.db | xargs -n1 -I{} sh -c '$PWD/scripts/restart-datasette.sh &'
deno eval 'let nanoid=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce(((t,e)=>t+=(e&=63)<36?e.toString(36):e<62?(e-26).toString(36).toUpperCase():e>62?"-":"_"),"");console.log(nanoid())'
import { parse } from "https://deno.land/std/flags/mod.ts";
import { DB } from "https://deno.land/x/sqlite/mod.ts";
import { faker } from "https://esm.sh/@faker-js/faker@7.4.0?dts";
// deno run --allow-read --allow-write fake-db.js --seed=1 --locale=fr --file=fake-data.db
const args = parse(Deno.args, {
default: {
seed: null,
locale: "en",
file: "fake-data.db",

For some reason just using datasette when in the venv described at https://docs.datasette.io/en/0.62/contributing.html didn't work, so use this instead

./venv/bin/datasette --reload -p 8002 fixtures.db

Full command to build the codemirror bundle and re-run:

node_modules/.bin/rollup datasette/static/cm-editor-6.0.1.js -f iife -n cm -o datasette/static/cm-editor-6.0.1.bundle.js -p @rollup/plugin-node-resolve -p @rollup/plugin-terser &amp;&amp; ./venv/bin/datasette --reload -p 8002 fixtures.db
@bgrins
bgrins / make-html.js
Last active November 18, 2022 05:43
deno run -A make-html.jsx
/** @jsxImportSource https://esm.sh/preact */
import { readCSVObjects } from "https://deno.land/x/csv/mod.ts";
import { render } from "npm:preact-render-to-string";
import { existsSync } from "https://deno.land/std/fs/mod.ts";
const URL =
"https://github.com/simonw/fara-history/raw/master/FARA_All_RegistrantDocs.csv";
const FILENAME = "FARA_All_RegistrantDocs.csv";
if (!existsSync(FILENAME)) {
package main
import (
"context"
"fmt"
"log"
"os"
"github.com/cloudflare/cloudflare-go"
"github.com/joho/godotenv"
CREATE TABLE IF NOT EXISTS
`httparchive-sandbox.crux.country_summary_082022` AS (
SELECT
DISTINCT origin,
country_code
FROM
`chrome-ux-report.materialized.country_summary`
WHERE
yyyymm = 202208
AND rank = 1000