Skip to content

Instantly share code, notes, and snippets.

@buzzkillb
buzzkillb / getAnchorBalance.js
Created April 30, 2022 04:59 — forked from tstachl/getAnchorBalance.js
Google App Script to get Anchor Protocol Earn balance for a terra wallet address.
function getAnchorBalance(addr) {
const contract = 'terra1hzh9vpxhsk8253se0vv5jj6etdvxu3nv8z07zu';
const aUstBalance = JSON.parse(JSON.parse(UrlFetchApp.fetch("https://mantle.terra.dev/?cw20--balance=" + contract, {
method: 'post',
headers: { 'Accept-Encoding': 'gzip, deflate, br', 'Content-Type': 'application/json', 'Accept': 'application/json' },
payload: JSON.stringify({
operationName: null,
variables: {},
query: `{\n ${contract}: WasmContractsContractAddressStore(ContractAddress: \"${contract}\", QueryMsg: \"{\\\"balance\\\":{\\\"address\\\":\\\"${addr}\\\"}}\") {\n Height\n Result\n __typename\n }\n}\n`
})
@buzzkillb
buzzkillb / geth_rpc_server.md
Created April 22, 2021 20:32 — forked from akaron/geth_rpc_server.md
create private geth rpc server using ssh port forwarding

note: create private geth rpc server using ssh port forwarding

In short, user provide ssh key to rpc server manager. Once the manager configured, then everytime the user need to type folowing commands to access to the geth rpc server:

  1. ssh -N -L 9545:localhost:8545 geth@machine_A_addr
  2. ... and set the rpc to http://localhost:9545

For convenienve, in the following I use these abbreviations:

  • machine A: run geth full node with RPC server
  • machine B: using the geth RPC from machine A
@buzzkillb
buzzkillb / 01nginx-tls-sni.md
Created February 1, 2021 23:08 — forked from kekru/01nginx-tls-sni.md
nginx TLS SNI routing, based on subdomain pattern

Nginx TLS SNI routing, based on subdomain pattern

Nginx can be configured to route to a backend, based on the server's domain name, which is included in the SSL/TLS handshake (Server Name Indication, SNI).
This works for http upstream servers, but also for other protocols, that can be secured with TLS.

prerequisites

  • at least nginx 1.15.9 to use variables in ssl_certificate and ssl_certificate_key.
  • check nginx -V for the following:
    ...
    TLS SNI support enabled
@buzzkillb
buzzkillb / bitcoin_connection.py
Created May 17, 2020 08:24 — forked from sappelt/bitcoin_connection.py
How to establish a connection to the bitcoin manually. Peer discovery + connecting and sending version message
# Import requests and regex library
import requests
import re
def get_external_ip():
# Make a request to checkip.dyndns.org as proposed
# in https://en.bitcoin.it/wiki/Satoshi_Client_Node_Discovery#DNS_Addresses
response = requests.get('http://checkip.dyndns.org').text
# Filter the response with a regex for an IPv4 address
@buzzkillb
buzzkillb / addrgen
Created May 4, 2020 21:18 — forked from JBaczuk/addrgen
addrgen
#!/bin/bash
echo
echo "Welcome to the Bitcoin address generator!"
echo "input private key (32 bytes, hex format)"
read priv
echo ""
echo "#####################################"
# priv=0C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D # Testing only