Skip to content

Instantly share code, notes, and snippets.

@joewagner
joewagner / muller-kahan.js
Created October 10, 2022 15:05
Javascript Muller Kahan
// This is a test designed by muller and kahan that demonstrates how
// the calculation of a known convergence returns incorrectly because
// of the mathematics of floating point numbers
const max = 21
let u = 2.0;
let v = -4.0;
let w;
for (let i = 3; i < max; i++) {
w = 111.0 - 1130.0/v + 3000.0/(v*u);
@joewagner
joewagner / plog alias
Created November 2, 2022 01:06
Create a git alias that pretty logs
alias.plog log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=iso --branches
@joewagner
joewagner / policy-upgrades-testing.sh
Created February 28, 2023 23:10
List of commands to manually setup, deploy, upgrade a tableland registry. This enables testing the affects of existing policy contracts.
# you will want to run the hardhat node in a separate terminal
# putting this here as a reminder
cd evm-tableland
npx hardhat node
# Add the following to the `networks` prop in hardhat.config.ts
# "local-tableland": {
# url: "http://127.0.0.1:8545",
# accounts: [
# "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",
@joewagner
joewagner / bulk-insert.mjs
Created March 2, 2023 01:10
An example of helpers for Tableland bulk inserts that will need to be split into multiple transactions.
// Dependencies: @tableland/sdk, @tableland/local
// Run `npx local-tableland` and then run this script in another window
import { Database, helpers } from "@tableland/sdk";
import { Wallet, getDefaultProvider, utils } from "ethers";
// NOTE: using 34000 here to give a 1000 byte padding for the `insert into table values` and
// in case the sql parser increases the size, which is unlikely but possible.
// If you wanted to limit for gas you'd have to kinda guess a value here.
const BYTES_LIMIT = 34000