Skip to content

Instantly share code, notes, and snippets.

View numtel's full-sized avatar
🦓
Natural Ungulates Make Teeming Elephants Laugh

Ben Green numtel

🦓
Natural Ungulates Make Teeming Elephants Laugh
View GitHub Profile
@numtel
numtel / index.js
Created December 22, 2023 08:30
Shamir's secret sharing using node.js
const crypto = require('crypto');
// All by chatgpt4 except this shim line below
global.window = {};
const secrets = require('secrets.js');
// Function to generate RSA key pair
function generateKeyPair() {
return crypto.generateKeyPairSync('rsa', {
modulusLength: 2048,
publicKeyEncoding: { type: 'spki', format: 'pem' },
@numtel
numtel / ooooh.md
Created October 21, 2023 20:36
writer's cohort bullet draft #1

We're all unsatisfied with government, with capitalism, with how much struggling there is in the world. Even if you're doing well personally, the guilt of inequality is inescapable.

Our collective decision-making ability in the US has been entrusted to a very small group of very old people. The size of the House of Representatives hasn't increased in over a hundred years, unlike the population correlation prescribed in the Federalist Paper #55. Having more representatives would enable the development of better policy.

There's no reason we have to stop our dream of progress in 1788 though. Do I have to remind you that we have better technology for communication now? We can come up with something better than 535 people meeting in a centralized location to debate face-to-face for a few months per year.

Proof of Personhood will allow us to begin chipping away at the roles filled by government. We will be able to implement voting and progressive taxation. Government should be leading in offering proof of person

@numtel
numtel / example.js
Last active August 4, 2023 09:07
Restart ZongJi gracefully on error
var ZongJi = require('zongji');
var RETRY_TIMEOUT = 4000;
function zongjiManager(dsn, options, onBinlog) {
var newInst = new ZongJi(dsn, options);
newInst.on('error', function(reason) {
newInst.removeListener('binlog', onBinlog);
setTimeout(function() {
// If multiple errors happened, a new instance may have already been created
@numtel
numtel / rummikub.js
Last active May 29, 2023 17:29
Rummikub
const crypto = require('crypto');
const http = require('http');
const url = require('url');
const ws = require('ws');
// Generate a new tileset with all tiles upside down in a random pile
const newRummikubGame = () => [1,2,3,4,5,6,7,8,9,10,11,12,13]
// Each ordinal in the various color sets, classname first, tile text second
.map(i => [['green', i], ['red', i], ['orange', i], ['blue', i]])
// Don't forget the wilds, ...except the mirror wild!
@numtel
numtel / index.js
Last active June 11, 2022 16:52
ABI directly on chain
const fs = require('fs');
const zlib = require('zlib');
const Web3 = require('web3');
const solc = require('solc');
(async function() {
// Stick whatever metadata you want in a zip
const file = fs.readFileSync('VerifiedGroup.abi');
@numtel
numtel / AWSPingTest.js
Created May 14, 2017 07:59
Find your closest AWS region
'use strict';
(function() {
// inspired by cloudping.info
var regions = {
'us-east-1': 'US-East (Virginia)',
'us-east-2': 'US East (Ohio)',
'us-west-1': 'US-West (California)',
'us-west-2': 'US-West (Oregon)',
'ca-central-1': 'Canada (Central)',
'eu-west-1': 'Europe (Ireland)',
@numtel
numtel / auto-cake-fetcher.js
Last active April 27, 2022 10:25
Auto Cake Fetcher
const https = require('https');
function post(hostname, data, path) {
const options = {
hostname, path: path || '/', method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': data.length
}
};
@numtel
numtel / BuskVault.sol
Created February 16, 2022 00:42
Crowdfunding smart contract (not tested)
pragma solidity >=0.8.0 <0.9.0;
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(
address sender,

The US wants to impose KYC/AML identity verification on DeFi protocols.

This is not a feasible requirement for developers of these protocols.

Instead, the US should offer a service for linking cryptocurrency addresses with individual identities.

This could be a website or offered at post offices (since they issue passports).

  1. The individual is identified by their government issued documents.
  2. The individual may add/remove/change associated addresses.
@numtel
numtel / breaking-the-rules.js
Created September 23, 2019 04:28
Node.js server example for chunked server events response handling
const http = require('http');
const url = require('url');
const querystring = require('querystring');
http.createServer((req, res) => {
const parsedUrl = url.parse(req.url);
switch(parsedUrl.pathname) {
case '/task':
// Browser RPC method
const PROGRESS_COUNT = 10, PROGRESS_INTERVAL = 300;
const globalHandlerKey = querystring.parse(parsedUrl.query).x;