Skip to content

Instantly share code, notes, and snippets.

View stefanopepe's full-sized avatar
💭
Back at some random coding. Cool thing, somehow it works!

Stefano Pepe stefanopepe

💭
Back at some random coding. Cool thing, somehow it works!
  • Nassau, Bahamas
  • 12:14 (UTC -04:00)
View GitHub Profile
@stefanopepe
stefanopepe / PRODUCT_BRIEF.md
Last active February 2, 2023 15:51
A basic Product Brief template in Markdown

(product name) Product Brief

The Product Brief is a high-level one-pager to explore and define the problem domain of a product. Use this document to clarify the starting point for any solution.

When ready, remove this intro text, and replace the questions below with your work.

Opportunity

What is the problem we are trying to solve?

For what audience segment(s)?

Keybase proof

I hereby claim:

  • I am stefanopepe on github.
  • I am stefanopepe (https://keybase.io/stefanopepe) on keybase.
  • I have a public key ASCUePNBFW19BQkEj-y2WOxr8iSulGyvvrNGdT8VkB39lwo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am stefanopepe on github.
  • I am stefanopepe (https://keybase.io/stefanopepe) on keybase.
  • I have a public key ASCUePNBFW19BQkEj-y2WOxr8iSulGyvvrNGdT8VkB39lwo

To claim this, I am signing this object:

@stefanopepe
stefanopepe / SeatCalc.py
Created June 17, 2021 19:54
NEAR Seat Calculator
#!/usr/bin/env python
staked = [39083288,20742627,17605710,14958721,12372225,11736051,11700857,10766231,10192733,9247144,8829467,8820923,8607624,7496028,7440797,7072148,6658986,6646311,6613536,6200873,6044540,5535635,5514813,5441478,5390617,5058487,5042476,5037097,5007809,4993358,4953007,4891731,4723753,4478417,4406591,4275230,4261006,4193711,4119969,4112941,4053846,4008247,3854746,3807783,3783853,3772500,3724032,3697405,3666975,3664753,3650362,3595469,3589451,3580855,3562831,3515380,3449636,3432393,3430539,3338958,3155647,2124049]
def findSeatPrice(stakes, num_seats):
"""
Find seat price given set of stakes and number of seats required.
Seat price is highest integer number such that if you sum `floor(stakes[i] / seat_price)` it is at least `num_seats`.
"""
stakes = sorted(stakes)
@stefanopepe
stefanopepe / commands.txt
Created January 22, 2021 19:52
NEAR lockup CLI cheatsheet
near call 7248096d7a83124b872c67eb7b5357221ed72c44.lockup.near select_staking_pool '{"staking_pool_account_id": "openshards.poolv1.near"}' --accountId patrick.near --useLedgerKey "44'/397'/0'/0'/2'"
near call 7248096d7a83124b872c67eb7b5357221ed72c44.lockup.near deposit_and_stake '{"amount": "5000000000000000000000000000"}' --accountId patrick.near --useLedgerKey "44'/397'/0'/0'/2'" --gas 200000000000000
near call 7248096d7a83124b872c67eb7b5357221ed72c44.lockup.near refresh_staking_pool_balance '' --accountId patrick.near --useLedgerKey "44'/397'/0'/0'/2'"
near call 7248096d7a83124b872c67eb7b5357221ed72c44.lockup.near unstake '{"amount": "500000000000000000000000000"}' --accountId patrick.near --useLedgerKey "44'/397'/0'/0'/2'"
near call 7248096d7a83124b872c67eb7b5357221ed72c44.lockup.near withdraw_from_staking_pool '{"amount": "500000000000000000000000000"}' --accountId patrick.near --useLedgerKey "44'/397'/0'/0'/2'"
@stefanopepe
stefanopepe / README.md
Created November 1, 2020 20:10
A simple epoch counter for NEAR validators. It takes as input the folder containing json files of every new epoch, and creates an output with a list of all validators and the times they were in the active set.

NEAR Simple Epoch Counter

Use this python script together with Frol's near-validators-scoreboard to count how many epochs each of the validators was in the active set.

  1. Clone the repo above from the tree scoreboard for betanet (use other branches for different networks)
  2. Put the three python files above in your working folder
  3. Launch with the command python3 -i folder_processor.py <scoreboard_folder>*
  4. Call function processFiles(filesList) from the REPL to begin the parsing

*Where <scoreboard_folder> is the relative path to the git repo above, such as ../near-validators-scoreboard/

@stefanopepe
stefanopepe / hashcash.py
Created October 26, 2020 17:02 — forked from i3visio/hashcash.py
hashcash.py is a clean implementation of a "proof of work" library for Python.
# ----------------------------------------------
# hashcash.py: Hashcash implementation
# ----------------------------------------------
"""
Hashcash is a "proof of work."
Example:
>>> import sha
>>> sha.new('denmark2890CF').hexdigest() '000000cf89643370c24e413ec0886ab92bd7f6e8'
{
"jsonrpc": "2.0",
"result": {
"current_validators": [
{
"account_id": "a.betanet",
"public_key": "ed25519:HTKFdCTmAbmDRWnoVizqKXSTJyJuP8woaCNG8Pk64qUe",
"is_slashed": false,
"stake": "75796455123048674322953249089",
"shards": [