Skip to content

Instantly share code, notes, and snippets.

@rrrkren
rrrkren / tool.sql
Last active February 21, 2024 20:44
postgres toolbox
-- find blocking PIDs
select pid,
usename,
pg_blocking_pids(pid) as blocked_by,
query as blocked_query
from pg_stat_activity
where cardinality(pg_blocking_pids(pid)) > 0;
-- check vacuum stat
select * from pg_stat_progress_vacuum;
@rrrkren
rrrkren / rootheight.go
Created April 3, 2023 18:38
get root height of a flow sporked network through binary search
package main
import (
"fmt"
flowclient "github.com/onflow/flow-go-sdk/client"
"google.golang.org/grpc"
)
import (
script="import AllDay from 0xe4cf4bdc1751c65d
pub fun main(): UInt64 { return AllDay.totalSupply }"
curl 'https://rest-mainnet.onflow.org/v1/scripts?block_height=sealed' -s \
-H 'content-type: application/json' \
-d '{"script":"'`echo "$script" | base64`'"}' \
|tr -d '"'|base64 --decode
@rrrkren
rrrkren / fetch_moment.sh
Last active April 5, 2022 17:04
fetching topshot moment link by flow ID
curl --request POST 'https://public-api.nbatopshot.com/graphql' \
--header 'Content-Type: application/json' \
--data-raw '{"query":"query {getMintedMoment(momentId: \"13251145\") {data {id\n flowId}}}"}'
# {"data":{"getMintedMoment":{"data":{"id":"909806bb-60fd-4d72-b38f-42be7c5da5d7","flowId":"13251145"}}}}
# the `13251145` is the moment's flow ID that you can find on events, the ashes ID is the same TS moment ID it came from.
# the ID you get in the response is the topshot's offchain moment ID. you can put compose the moment URL in this format:
# https://nbatopshot.com/moment/909806bb-60fd-4d72-b38f-42be7c5da5d7
# this actually works in the other way around, the ID you passed in can also be the moment's UUID

Keybase proof

I hereby claim:

  • I am rrrkren on github.
  • I am rrrkren (https://keybase.io/rrrkren) on keybase.
  • I have a public key ASCPTxPvekg7By_r5TSTcfiyeFEyjU_F7jWw5iJTt6DkGgo

To claim this, I am signing this object:

0xa4dd9085B3c42d7960CfE6eaB7cfeb4fFfF256CF