Skip to content

Instantly share code, notes, and snippets.

MicahZoltu / zoom-fix-chat.js
Created Jul 15, 2022
Fix Zoom Chat Box Focus bug
View zoom-fix-chat.js
(function () { const chatBox = document.querySelector('#wc-container-right > div.participants-section-container > > div > textarea'); chatBox.onblur = chatBox.focus })()
MicahZoltu / script.bash
Last active Mar 26, 2021
Generate Ethereum Mnemonic & Address
View script.bash
mkdir temp
cd temp
cat >index.mjs <<'EOF'
import { ethereum, mnemonic, secp256k1, hdWallet } from '@zoltu/ethereum-crypto'
// necessary so @peculiar/webcrypto looks like browser WebCrypto, which @zoltu/ethereum-crypto needs
import webcrypto from '@peculiar/webcrypto'
globalThis.crypto = new webcrypto.Crypto()
export async function generateAccount() {
MicahZoltu / github-widescreen-bookmarklet.js
Last active Aug 30, 2021
GitHub Widescreen Boookmarklet
View github-widescreen-bookmarklet.js
javascript:(function(){ const style = document.createElement('style'); = 'injected-css'; style.innerText = `.container-xl, #review-changes-modal .SelectMenu-modal, .inline-comment-form-container, .inline-comment-form, .comment-holder, #pull_request_review_body { max-height: none !important; max-width: none !important; } .js-resolvable-timeline-thread-container, .js-line-comments { max-width: calc(100vw - 100px); }`; document.head.appendChild(style); })();
View FoodToken.sol
pragma solidity >= 0.7.0;
contract FoodToken {
uint256 constant public totalSupply = 10_000_000 * 10**18;
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
string constant public symbol = "FOOD";
uint8 constant public decimals = 18;
string constant public name = "Food Token";
MicahZoltu / Dockerfile
Last active Dec 16, 2020
Augur ENS Verification
View Dockerfile
FROM node:14-alpine
RUN npm install --save eth-ens-namehash content-hash @zoltu/ethereum-abi-encoder
RUN echo $'\n\
import Contenthash from "content-hash"\n\
import Namehash from "eth-ens-namehash"\n\
import AbiEncoder from "@zoltu/ethereum-abi-encoder"\n\
function stringToBytes(hex) {\n\
const match = /^(?:0x)?([a-fA-F0-9]*)$/.exec(hex)\n\
MicahZoltu /
Last active Mar 2, 2021
Trusted Anonymous DAO

Trusted Anonymous DAO

The goal of this process is to create a DAO that the public can weakly trust, while protecting DAO participants from wrench attacks by someone looking to takeover the DAO.


  1. A secret is given out to n publicly trusted individuals.
  2. The individual's with secrets are instructed to secretly nominate one person they trust to participate in the DAO.
  3. The nominated individuals all sign the secret and publish the signature plus the address they signed with publicly (and anonymously).
    1. Nominated individuals should accept multiple nominations if offered, and not tell anyone they were nominated multiple times.
    2. Nominated individuals are strongly encouraged to participate, but they should not inform their nominator if they fail to participate.
  4. After a pre-defined amount of time has passed, all valid signatures (verifiable by anyone who has seen the secret) are collected and the trusted individuals all assert that:
View augur-constant-product.sol
contract AugurConstantProduct {
IAugurMarket market = 0x0;// TODO
IErc20 dai = 0x0; // TODO
uint256 numTicks;
function addLiquidity(uint256 amountInAttodai) {
uint256 poolBalanceBefore = poolBalance();
dai.transferFrom(msg.sender, this, amountInAttodai);
MicahZoltu / merkle-patritia-proof.sol
Last active Apr 1, 2020
Merkle Patritia Proof Validator in Solidity
View merkle-patritia-proof.sol
pragma solidity 0.6.4;
library RLP {
uint constant DATA_SHORT_START = 0x80;
uint constant DATA_LONG_START = 0xB8;
uint constant LIST_SHORT_START = 0xC0;
uint constant LIST_LONG_START = 0xF8;
uint constant DATA_LONG_OFFSET = 0xB7;
uint constant LIST_LONG_OFFSET = 0xF7;


  1. User has 10 ETH.
  2. User wants 10 ETH worth of an insured YES position.
  3. User buys 10 complete sets, giving them 10 YES + 10 NO + 10 INVALID.
  4. User trades 10 NO for x YES on the open market.
  5. User ends up with 10+x YES + 10 INVALID.
  • If the market resolves as YES, they get 10+x ETH (net profit == x).
  • If the market resolves as NO, they get 0 ETH (net loss == VAR).
  • If the market resolves as INVALID, they get 10 ETH (net neutral).
View gist:ef452e9f51c0a01000279dcd4c01f7ec
"xhrStatus": "complete",
"request": {
"method": "GET",
"url": "api/datasources/proxy/2/query",
"params": {
"db": "my_database",
"q": "SELECT last(\"number\") FROM \"my_measurement\" WHERE time >= now() - 30m GROUP BY time(1s) fill(previous)",
"epoch": "ms"