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
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 / 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,
@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
}
};

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 / 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 / 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;
@numtel
numtel / index.js
Last active February 20, 2018 23:08
node-raiblocks-pow threaded implementation starting
// Change index.js to this contents
var cp = require('child_process');
var os = require('os');
var addon = require('bindings')('functions.node');
function zeroPad(num, size) {
// Max 32 digits
var s = "00000000000000000000000000000000" + num;
return s.substr(s.length-size);
};
function genPow(hash, timeout) {
timeout = timeout || 15000000;
const start = Date.now();
const hashBytes = hex_uint8(hash);
let i=0;
while(Date.now() - start < timeout) {
const workBytes = nacl.randomBytes(8);
for(let j=0;j<256;j++) {
workBytes[7] = j;
@numtel
numtel / ec2-rai-node.md
Last active May 12, 2019 22:18
Install rai_node on EC2 Ubuntu instance

Follow these instructions to start an EC2 instance running Ubuntu that will run rai_node on startup

  1. Select Ubuntu Server 16.04 LTS (HVM), SSD Volume Type. A t2.small or larger instance type is recommended.

  2. Configure the security group to match the screenshot.

  3. Download install_rai_node.sh below, update the URLs with their latest versions.

    Get latest rai_node archive URL from https://github.com/clemahieu/raiblocks/releases.

    Get latest gdrive-linux-x64 version URL from https://github.com/prasmussen/gdrive#downloads

@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)',