Skip to content

Instantly share code, notes, and snippets.

View carnoxen's full-sized avatar

Kaben carnoxen

View GitHub Profile
use std::{iter, slice, vec};
use std::iter::FromIterator;
/// A unique identifier with an associated usize index. Indexes are valued proportional to the
/// number of indexes allocated, are reused after being freed, and do not grow without bound. When
/// an index is re-used, an associated "generation" is incremented, so that within the life of a
/// single allocator, no two GenerationalIndex values will ever be equal. Since the indexes do not
/// grow without bound, GenerationalIndex values are particularly suited to being stored by their
/// index in extremely fast contiguous arrays.
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, Debug)]
@carnoxen
carnoxen / README.md
Created January 25, 2023 03:09 — forked from minibox24/README.md
Get cookies.txt는 당신의 정보를 훔쳐갑니다
@carnoxen
carnoxen / gashapon_test.js
Last active September 19, 2021 01:40
Gashapon test by hardhat
const { ethers } = require("hardhat");
// json -> solidity struct
function encodeData(str) {
const {users, ranks} = JSON.parse(str)
return [users, ranks.map(({name, count}) => [name, count, []])]
}
// solidity struct -> json
function decodeData(enc) {
@carnoxen
carnoxen / contracts...gashapon.sol
Last active October 24, 2021 13:03
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime.
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.4;
contract Gashapon {
// struct of rank. count is a maximum size of winners array. winners array stores users from user lists
struct Rank {
string name;
uint count;
string[] winners;