Skip to content

Instantly share code, notes, and snippets.

@MicahZoltu
MicahZoltu / standard-notes-proxy.js
Created March 11, 2024 03:04
Standard Notes CloudFlare Proxy
export default {
/**
* @param {Request} request
*/
async fetch(request) {
const corsHeaders = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET,HEAD,POST,OPTIONS",
"Access-Control-Max-Age": "86400",
};
@MicahZoltu
MicahZoltu / faster.js
Created June 2, 2023 11:07
Faster Video Playback Bookmarklet
javascript:(() => { let speed = 2; let indicator; let indicatorTimeout; function createIndicator() { indicator = document.createElement("div"); indicator.setAttribute(`style`, ` position: fixed; left: 15px; top: 15px; background-color: black; color: white; font-size: 20px; padding: 10px; display: none; z-index: 99999999999999; `); document.body.appendChild(indicator); }; function show(text) { if (!indicator) createIndicator(); indicator.innerText = text; indicator.style.display = "block"; indicatorTimeout && clearTimeout(indicatorTimeout); indicatorTimeout = setTimeout(() => { indicator.style.display = "none"; }, 5000); } function round(value, precision) { const scalar = 10 ** precision; return Math.round(value * scalar) / scalar; }; function conformSpeed(value) { return Math.min(Math.max(value, 1 / 16), 16); }; function syncSpeed() { document.querySelectorAll("video").forEach(video => { video.playbackRate = speed; }); }; function changeSpeed(value) { speed = conformSpeed(value); show(round(speed, 2).t
@MicahZoltu
MicahZoltu / tornado-community-build.md
Last active July 18, 2023 22:00
Tornado Cash Community Build
@MicahZoltu
MicahZoltu / vitalik-mode.js
Last active June 14, 2023 08:54
vitalik-mode
(function () {
var request = async ({method, params}) => {
if (method === 'eth_requestAccounts') {
return ['0xd8da6bf26964af9d7eed9e03e53415d37aa96045']
}
else {
const response = await fetch('https://cloudflare-eth.com/v1/mainnet', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({jsonrpc:'2.0',id:1,method,params})})
if (!response.ok) throw new Error(`${response.status}: ${response.statusText}\n${await response.text()}`)
const json = await response.json()
if ('error' in json) throw new Error(json.error)
@MicahZoltu
MicahZoltu / zoom-fix-chat.js
Created July 15, 2022 14:43
Fix Zoom Chat Box Focus bug
(function () { const chatBox = document.querySelector('#wc-container-right > div.participants-section-container > div.chat-container > div > textarea'); chatBox.onblur = chatBox.focus })()
@MicahZoltu
MicahZoltu / script.bash
Last active March 18, 2024 14:46
Generate Ethereum Mnemonic & Address
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
MicahZoltu / github-widescreen-bookmarklet.js
Last active August 30, 2021 07:58
GitHub Widescreen Boookmarklet
javascript:(function(){ const style = document.createElement('style'); style.id = '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); })();
@MicahZoltu
MicahZoltu / FoodToken.sol
Last active February 5, 2021 14:37
Testnet Tokens
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
MicahZoltu / Dockerfile
Last active December 16, 2020 09:15
Augur ENS Verification
FROM node:14-alpine
WORKDIR /app
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\
\n\
function stringToBytes(hex) {\n\
const match = /^(?:0x)?([a-fA-F0-9]*)$/.exec(hex)\n\
@MicahZoltu
MicahZoltu / markdown.md
Last active March 2, 2021 22:39
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.

Process

  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: