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 / 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
@madeinfree
madeinfree / what-forces-layout.md
Created August 15, 2018 11:43 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
/* file: Recompose.re */
/* The very definition of a HOC, it's a function that gets a react component and returns another react component */
type hoc = ReasonReact.reactClass => ReasonReact.reactClass;
module type CreateWithStateParams = {
/* This is the secret sauce ingredient, with it the users can pass whatever state they want */
type state;
let defaultValue: state;
};