Skip to content

Instantly share code, notes, and snippets.

import { ethers } from "ethers"
import { update } from "./store"
const provider = new ethers.providers.Web3Provider(window.ethereum)
provider.on("network", (oldNetwork, newNetwork) => update(state => ({
...state,
chainId: ( newNetwork ?? oldNetwork ).chainId
})))
@jm42
jm42 / 3box-key.txt
Created May 27, 2021 18:40
3Box Profile Verification
did:3:bafyreieq4lcvrv5buxh3v3izjfb7xdjeqmc4gq7usqhjwna5fmvnbwnrr4
@jm42
jm42 / constants.js
Created April 10, 2021 21:29
Generate RSA key per canvas
module.exports = Object.freeze({
/** RSA bits for key pair generation */
KEY_BITS: 512,
})
@jm42
jm42 / cw-dashboard-alarm.yml
Created April 5, 2021 17:05
Example resource to create a CloudWatch Dashboard for an Alarm in CloudFormation
CloudWatchDashboard:
Type: AWS::CloudWatch::Dashboard
Properties:
DashboardName: !Sub ${AWS::StackName}
DashboardBody: !Sub
- |
{
"periodOverride": "inherit",
"widgets": [
@jm42
jm42 / migrate.js
Created March 4, 2021 03:13
Migration (node, pg, ioredis)
const fs = require('fs')
const path = require('path')
/** Creates the initial "migrations" table. Even if this is run
* every migration is not that much weight. */
async function initSchema(pool, table) {
await pool.query(`CREATE TABLE IF NOT EXISTS ${pool.escapeIdentifier(table)} (version SMALLINT PRIMARY KEY)`)
}
async function getVersions(pool, table) {
@jm42
jm42 / i3-config
Last active February 10, 2021 21:10
# i3 config file (v4)
#
# Please see https://i3wm.org/docs/userguide.html for a complete reference!
set $mod Mod4
# Autostart
exec --no-startup-id nitrogen --restore &
exec --no-startup-id picom -CGb
@jm42
jm42 / draw-compass.html
Created October 30, 2020 18:15
Draw an SVG compass
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Compass</title>
</head>
<body>
<svg id="compass" width="220" height="220" viewBox="0 0 220 220" xmlns="http://www.w3.org/2000/svg">
@jm42
jm42 / display.js
Created July 9, 2020 18:05
canvas-library
class Sprite {
constructor(rect) {
this._visible = true
this.dirty = 1
this.rect = rect
}
get visible() {
return this._visible
}
@jm42
jm42 / countries-csv2json.py
Created April 8, 2020 20:40
Countries Bounds
import csv
import json
data = {}
with open('countries.csv', 'r') as fr:
reader = csv.reader(fr, dialect='excel-tab')
for row in reader:
@jm42
jm42 / boot_config.txt
Created June 23, 2019 19:38
RPi LCD rotate upside-down
lcd_rotate=2