Skip to content

Instantly share code, notes, and snippets.

View madeinfree's full-sized avatar
🐱
Focusing

Whien_Liou madeinfree

🐱
Focusing
View GitHub Profile
import random
from typing import Tuple
def get_reciprocal(value: int, mod: int) -> int:
for i in range(1, mod):
if (i * value) % mod == 1:
return i
return -1
@madeinfree
madeinfree / MerkleTree.ts
Created January 10, 2023 05:02 — forked from johnson86tw/MerkleTree.ts
A TypeScript implementation of Merkle Tree rewrite from tornado-core: https://github.com/tornadocash/tornado-core/blob/master/lib/MerkleTree.js
const circomlib = require("circomlib");
const mimcsponge = circomlib.mimcsponge;
export function MiMCSponge(left: string, right: string): string {
return mimcsponge.multiHash([BigInt(left), BigInt(right)]).toString();
}
export interface IMerkleTree {
root: () => string;
proof: (index: number) => {
@madeinfree
madeinfree / BeaconProxy.sol
Created August 5, 2022 05:52 — forked from hihiben/BeaconProxy.sol
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.14+commit.80d49f37.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.14;
import "https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-contracts/master/contracts/proxy/beacon/BeaconProxy.sol";
import "https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-contracts/master/contracts/proxy/beacon/UpgradeableBeacon.sol";
import {ImplementationV1, ImplementationV2} from "./Implementation.sol";
contract Setup {
address immutable public proxy1;
address immutable public proxy2;
@madeinfree
madeinfree / README.txt
Created May 13, 2022 02:11
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
REMIX DEFAULT WORKSPACE
Remix default workspace is present when:
i. Remix loads for the very first time
ii. A new workspace is created
iii. There are no files existing in the File Explorer
This workspace contains 3 directories:
1. 'contracts': Holds three contracts with different complexity level, denoted with number prefix in file name.
@madeinfree
madeinfree / .deps...npm...@openzeppelin...contracts...token...ERC20...ERC20.sol
Created May 13, 2022 02:09
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";
/**
@madeinfree
madeinfree / input.html
Last active July 23, 2021 07:58
上傳圖片
<input type="file" />
@madeinfree
madeinfree / basic.jsx
Last active December 19, 2020 09:29
透過 Web Workers API 改善 React 大量計算阻塞渲染幀數01.medium
import React, { useState, useEffect } from "react";
import "./styles.css";
export default function App() {
const [sum, setSum] = useState(0);
useEffect(() => {
const worker = new Worker("./computing.js");
worker.addEventListener("message", (e) => {
const data = e.data;
@madeinfree
madeinfree / psql_useful_stat_queries.sql
Created November 26, 2020 06:37 — forked from anvk/psql_useful_stat_queries.sql
List of some useful Stat Queries for PSQL
--- PSQL queries which also duplicated from https://github.com/anvk/AwesomePSQLList/blob/master/README.md
--- some of them taken from https://www.slideshare.net/alexeylesovsky/deep-dive-into-postgresql-statistics-54594192
-- I'm not an expert in PSQL. Just a developer who is trying to accumulate useful stat queries which could potentially explain problems in your Postgres DB.
------------
-- Basics --
------------
-- Get indexes of tables
let servers = null
let pcConstraint = null
let dataConstraint = null
const localConnection = new RTCPeerConnection(null)
const remoteConnection = new RTCPeerConnection(null)
const dataChannel = localConnection.createDataChannel('chat', {
negotiated: true,
id: 0
})
const dataChannel2 = remoteConnection.createDataChannel('chat', {