Skip to content

Instantly share code, notes, and snippets.

View mikedotexe's full-sized avatar
🤙
hakuna matata

Mike Purvis mikedotexe

🤙
hakuna matata
View GitHub Profile
@encody
encody / lib.rs
Created February 10, 2024 05:44
NEAR Spinner
use near_sdk::{
borsh::{self, BorshDeserialize, BorshSerialize},
env,
json_types::U64,
log, near_bindgen, Promise,
};
#[derive(BorshSerialize, BorshDeserialize, Default, Debug)]
#[near_bindgen]
struct Contract {}
@ElijahLynn
ElijahLynn / monitor-number-tcp-connection-states.sh
Last active January 20, 2024 22:49
Monitor the number of all TCP connection states
watch -n 1 "netstat -an | awk '/^tcp/ { ++S[\$NF] } END { for(a in S) print a, S[a] }'"
# Every 1.0s: netstat -an | awk '/^tcp/ { ++S[$NF] } END { for(a in S) print a, S[a] }'
# LISTEN 7
# FIN_WAIT_2 1
# CLOSE_WAIT 1
# CLOSED 33
# TIME_WAIT 1
# ESTABLISHED 63
#!/bin/bash
# Some helper functions for working with cosmos-sdk txs from the command line or
# in bash scripts.
#
# Example: say, if you want to send coins to multiple recipients. We need to:
#
# - compose a tx containing multiple "send" messages
# - set an appropriate gas limit and fee amount
# - sign it
@CyberHoward
CyberHoward / optimize.sh
Created June 20, 2023 16:39
Arch agnostic optimize command
#!/usr/bin/env bash
if [[ $(arch) == "arm64" ]]; then
image="cosmwasm/workspace-optimizer-arm64"
else
image="cosmwasm/workspace-optimizer"
fi
# Optimized builds
docker run --rm -v "$(pwd)":/code \
@JakeHartnell
JakeHartnell / README.md
Last active November 8, 2024 01:52
Include README.md files in rust documentation generation

Include README.md in documentation generation and tests

Recentely, I was trying to make sure our README.md files for DAO DAO were included in the documentation generated by cargo doc or rustdoc. Moreover, I wanted code examples in our README.md files to be tested.

Here's a quick gist...

There is of course the doc attribute, and the rust book contains the following example which you are meant to include in your lib.rs or main.rs:

@webmaster128
webmaster128 / config.toml
Last active February 28, 2023 09:39
Nois blocktime settings
# How long we wait for a proposal block before prevoting nil
timeout_propose = "2000ms"
# How much timeout_propose increases with each round
timeout_propose_delta = "500ms"
# How long we wait after receiving +2/3 prevotes for “anything” (ie. not a single block or nil)
timeout_prevote = "1s"
# How much the timeout_prevote increases with each round
timeout_prevote_delta = "500ms"
# How long we wait after receiving +2/3 precommits for “anything” (ie. not a single block or nil)
timeout_precommit = "1s"
/*
* Wraps a cw721 contract with helpers.
* Adapted from https://github.com/CosmWasm/cw-plus/blob/main/contracts/cw721-base/helpers.ts.
*/
import {
CosmWasmClient,
SigningCosmWasmClient,
} from '@cosmjs/cosmwasm-stargate';
import { coins } from '@cosmjs/stargate';
@microchipgnu
microchipgnu / diff.md
Last active September 15, 2021 16:05
Metadata diff

NEAR_ENV=mainnet near view pluminite.near nft_tokens "{\"from_index\":\"0\",\"limit\":\"10\"}"

NEAR_ENV=mainnet near view x.paras.near nft_tokens "{\"from_index\":\"0\",\"limit\":10}"

NEAR_ENV=mainnet near view uhhmnft.near nft_tokens "{\"from_index\":\"0\",\"limit\":10}"

Pluminite

@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

@KoryNunn
KoryNunn / handshake-airdrop.md
Last active March 12, 2024 07:03
Handshake airdrop for github users.

Had 15 github followers in 2019? You can get about $4kAUD of crypto for minimal effort.

Explain this scam

That's legitimately a good default position to hold, however, in this case, the free money is a function of time, and not only charity.

In February 2020, in order to promote Handshake (HNS) to developers, an airdrop was offered to any Github user with more than 15 followers. The Airdrop would give you 4246HNS, at the time worth around at $0.08USD per coin, for a total of $339.68USD, pretty generous!

Today, 4246HNS is worth around $4000 dollarydoos, and there are plenty of github users who haven't claimed theirs.