Skip to content

Instantly share code, notes, and snippets.

View chiro-hiro's full-sized avatar
🤖
Bleep bloop, I am a robot. Eh, just kidding.

Chiro Hiro chiro-hiro

🤖
Bleep bloop, I am a robot. Eh, just kidding.
View GitHub Profile
@chiro-hiro
chiro-hiro / recover.ts
Last active December 25, 2022 12:39
Validate ethereum proof
import { ethers } from 'ethers';
(async () => {
let proofs = [
'0x4f54e1c15ca1d7aec6d16fcc8b524ef298a470b5dd61fd4aeccdd2abd4755e437340fe513a8267397ae468cc8643e1ea0d86f78d029ab35871c0d61d81ba32c51c',
'0x6fca48d5a3522f42984dda6ff662c63de7df537c40da53e74fcc77d00a73441c30c222612af565c74faed88830c4a4083fd9a98c46e5aeaae392dfe61c5a14941c',
'0xd3ba49eabe5cc487d012360e2d38c0238666f9ec596be5f3b7e542e67c448a187b09a9a5acda889366eb5789073b0a73961375f336d28beb4d78479405765e361b',
];
for (let i = 0; i < proofs.length; i += 1) {
console.log(
@chiro-hiro
chiro-hiro / crossbeam.rs
Last active October 17, 2022 05:42
Example data sharing and channel
use crossbeam::scope;
use crossbeam_channel::{select, unbounded};
use env_logger::{Builder, Env};
use log::info;
use std::sync::{Arc, Mutex};
use std::thread;
use std::time::Duration;
fn main() {
Builder::from_env(Env::default().default_filter_or("info")).init();
@chiro-hiro
chiro-hiro / crossbeam_http_server.rs
Last active July 20, 2022 10:27
Multithread HTTP server with crossbeam
// Try with
// RUST_LOG=debug cargo run
// [dependencies]
// crossbeam = "0.8.1"
// crossbeam-utils = "0.8.10"
// crossbeam-channel = "0.5"
// log = "0.4.17"
// env_logger = "0.9.0"
use crossbeam;
@chiro-hiro
chiro-hiro / lazy-ass-wallet.md
Last active April 29, 2022 09:28
Ethereum wallet generator

Want to generate a bunch of wallets but your are lazy as fuck?

// MIT Licensed © 2022 chiro@orochi.network
import { ethers } from "ethers";

(async () => {
  const { phrase } = ethers.Wallet.createRandom().mnemonic;
  const dataTable = [];
  console.log("Passphrase:", phrase);
@chiro-hiro
chiro-hiro / ed25519.md
Last active November 18, 2021 07:19
Use ed25519 JWT with jose

Generate keypair:

import { generateKeyPair } from "jose/util/generate_key_pair";
import fs from "fs";
import { KeyObject } from "crypto";

(async () => {
  const { publicKey, privateKey } = await generateKeyPair("EdDSA", {
    crv: "Ed25519",
@chiro-hiro
chiro-hiro / temperature.bash
Created September 1, 2021 11:00
Get CPU,GPU temperature
#!/bin/bash
# Script: my-pi-temp.sh
# Purpose: Display the ARM CPU and GPU temperature of Raspberry Pi 2/3
# Author: Vivek Gite <www.cyberciti.biz> under GPL v2.x+
# -------------------------------------------------------
cpu=$(</sys/class/thermal/thermal_zone0/temp)
echo "$(date) @ $(hostname)"
echo "-------------------------------------------"
echo "GPU => $(/opt/vc/bin/vcgencmd measure_temp)"
echo "CPU => $((cpu/1000))'C"
@chiro-hiro
chiro-hiro / token.md
Last active August 31, 2021 09:57
Stablecoin list
@chiro-hiro
chiro-hiro / hardhat-unlock-signer.js
Last active October 12, 2022 13:13
Hardhat: Unlock any signer on mainnet forking
// MIT License
// Copyright (c) 2021 Dũng Trần a.k.a Chiro Hiro <chiro8x@gmail.com>
import { Signer } from '@ethersproject/abstract-signer'
import { Contract } from '@ethersproject/contracts'
import hre from 'hardhat'
interface IKeyValues {
[key: string]: string
}
@chiro-hiro
chiro-hiro / assembler.js
Created May 24, 2021 13:22
evm assember
const fs = require("fs");
const opcode = require("./opcode");
// Map OPCODE string -> Binary value
const asmMap = new Map(opcode.map((v, i) => [v, i]));
function compile(fileName) {
const inputContent = fs.readFileSync(fileName).toString();
const fileContent = inputContent
.split("\n")
@chiro-hiro
chiro-hiro / test.ts
Created March 25, 2021 14:22
Merge array by unique key
const src = [
{ name: 'a', value: 1 },
{ name: 'b', value: 2 },
{ name: 'c', value: 3 },
];
const dst = [
{ name: 'd', value: 4 },
{ name: 'a', value: 5 },
{ name: 'f', value: 6 },