Skip to content

Instantly share code, notes, and snippets.

View mfornet's full-sized avatar
🌎
on earth

Marcelo Fornet mfornet

🌎
on earth
View GitHub Profile
N = 2000
R = 5
def matmul(a, b):
c = [[0] * R for _ in range(R)]
for i in range(R):
for j in range(R):
for k in range(R):
c[i][j] += a[i][k] * b[k][j]
@mfornet
mfornet / a_request.py
Created May 23, 2022 11:25
Validators Ordered
import requests
import json
url = "https://archival-rpc.mainnet.near.org/"
payload = json.dumps({
"jsonrpc": "2.0",
"id": "dontcare",
"method": "EXPERIMENTAL_validators_ordered",
"params": [
for j in range(1, 100):
for i in range(1, 100):
b = i**j
b_s, i_s, j_s = map(str, (b, i, j))
if b_s.startswith('1') and b_s.endswith(i_s + j_s):
x = b_s[1:-len(i_s + j_s)]
print(f"{b} = 1^{x} * {i}^{j}")
@mfornet
mfornet / client.rs
Last active February 11, 2022 22:46
Macros expanded for rainbow bridge contracts
#![feature(prelude_import)]
#[prelude_import]
use std::prelude::rust_2018::*;
#[macro_use]
extern crate std;
use borsh::{BorshDeserialize, BorshSerialize};
use eth_types::*;
use near_plugins::{only, pause, FullAccessKeyFallback, Ownable, Pausable, Upgradable};
use near_sdk::collections::UnorderedMap;
use near_sdk::AccountId;
@mfornet
mfornet / Front.sol
Last active November 19, 2021 13:29
Multicontract Update
//SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.7;
interface Router {
function get_implementatino_address() external returns (address);
}
contract Front {
Router router;
This file has been truncated, but you can view the full file.
╔════════════════════════════════════════════╤═════════╤══════╤════════╤══════════════════════╤════════╗
║ address │ tickets │ wins │ aurora │ eth │ kyc ║
╟────────────────────────────────────────────┼─────────┼──────┼────────┼──────────────────────┼────────╢
║ 0xdabd4c9c5e5f3ca23e6316f92eec1419066223a5 │ 2442 │ 84 │ 4200 │ 29475000000000000000 │ passed ║
╟────────────────────────────────────────────┼─────────┼──────┼────────┼──────────────────────┼────────╢
║ 0x4467554da9e6e79ef5f90f0c0fcbf7d645c394cf │ 1876 │ 43 │ 2150 │ 22912500000000000000 │ passed ║
╟────────────────────────────────────────────┼─────────┼──────┼────────┼──────────────────────┼────────╢
║ 0x9da59d5b67ae4b05a3c2c93feeb3ce82a3cb6f7a │ 1626 │ 42 │ 2100 │ 19800000000000000000 │ passed ║
╟────────────────────────────────────────────┼─────────┼──────┼────────┼──────────────────────┼────────╢
║ 0x47705c55e46802ddf233d7497a5f4e1b4a423b83 │ 1223 │ 39 │ 1950 │ 148000
@mfornet
mfornet / near-borsh-io.md
Last active November 18, 2021 04:30
Borsh I/O in NEAR Smart Contracts

Borsh I/O in NEAR Smart Contracts

Manual encoding single parameter

pub fn set_status_borsh(&mut self, #[serializer(borsh)] message: Vec<u8>) {}

To call this function you need to pass arguments borsh serialized, and those bytes encoded as base64

"""
https://twitter.com/bitshiftmask/status/1323809212875608066?s=20
Let P(i, j) be the probability that if there are `i` devices, then after one
round `j` devices selected a unique number, so they are out. The expected
value of the number of rounds required so that each device selected a unique number is:
E(n) = p(n, n) * E(0) + p(n, n - 1) * E(1) + ... + p(n, 0) * E(n)
E(n) * (1 - p(n, 0)) = p(n, n) * E(0) + p(n, n - 1) * E(1) + ...
@mfornet
mfornet / remove_high_frequency.py
Created July 26, 2020 02:45
Discover the animal
# %%%
import PIL.Image
import numpy as np
import matplotlib.pyplot as plt
# %%
im = PIL.Image.open("panda.jpeg")
arr = np.array(im).mean(2)