Skip to content

Instantly share code, notes, and snippets.

View smiled0g's full-sized avatar
🐻
Fighting bear market by BUIDLing great products

Paul N. smiled0g

🐻
Fighting bear market by BUIDLing great products
  • Band Protocol, TripAdvisor, Turfmapp
  • Bangkok, Thailand
  • X @PNattapatsiri
View GitHub Profile
function anagram(lp, word) {
const m = lp.reduce((o, w) => Object.assign(o, {[w]: (o[w] || 0)+1}), {})
return !word.split('').some(c => !m[c]--)
}
function check(letterPool, word) {
// S1
const map = {}
for (let i=0; i<letterPool.length; i++) {
const character = letterPool[i]
if (map[character] === undefined) {
map[character] = 1
} else {
map[character] += 1
}
@smiled0g
smiled0g / CoinGecko-OpenAPI-Spec.json
Last active November 21, 2019 10:15
A CoinGecko token volume spec for Band Protocol's OpenAPI
{
"meta": {
"version": "1",
"info": {
"image": "https://www.coingecko.com/thumbnail.png",
"description": "CoinGecko: 24hr Trading Volume"
},
"aggregation": "MEDIAN",
"variables": [
"string"
@smiled0g
smiled0g / CoinGeckoVolumeDemo.sol
Last active November 21, 2019 12:45
Solidity example code for getting volume data from CoinGecko via Band Protocol's OpenAPI
pragma solidity ^0.5.0;
interface Oracle {
enum QueryStatus { INVALID, OK, NOT_AVAILABLE, DISAGREEMENT }
function query(bytes calldata input)
external payable returns (bytes32 output, uint256 updatedAt, QueryStatus status);
function queryPrice() external view returns (uint256);
}
contract CoinGeckoVolumeContract {
@smiled0g
smiled0g / goldchain.json
Created April 16, 2020 14:15
Relayer config file for the GoldChain
{
"key": "consumer",
"chain-id": "band-consumer",
"rpc-addr": "http://localhost:26657",
"account-prefix": "cosmos",
"gas": 1000000,
"gas-prices": "0.025stake",
"default-denom": "stake",
"trusting-period": "330h"
}
@smiled0g
smiled0g / gaia.json
Created April 16, 2020 14:17
Relayer config file for the testnet Gaia
{
"key": "gaia",
"chain-id": "band-cosmoshub",
"rpc-addr": "http://gaia-ibc-hackathon.node.bandchain.org:26657",
"account-prefix": "cosmos",
"gas": 1000000,
"gas-prices": "0.001uatom",
"default-denom": "uatom",
"trusting-period": "330h"
}
@smiled0g
smiled0g / bandchain.json
Created April 16, 2020 15:45
Relayer config file for the BandChain
{
"key": "band-chain",
"chain-id": "ibc-bandchain",
"rpc-addr": "http://54.169.14.201:26657",
"account-prefix": "band",
"gas": 1000000,
"gas-prices": "0.025uband",
"default-denom": "uband",
"trusting-period": "330h"
}
# Install bandd, change its permission, and move to /usr/local/bin
wget -O bandd https://github.com/bandprotocol/bandchain/releases/download/v0.2.4/bandd_linux_amd64
chmod +x bandd
sudo mv bandd /usr/local/bin
# Install bandcli, change its permission, and move to /usr/local/bin
wget -O bandcli https://github.com/bandprotocol/bandchain/releases/download/v0.2.4/bandcli_linux_amd64
chmod +x bandcli
sudo mv bandcli /usr/local/bin
@smiled0g
smiled0g / create_account_and_init_chain.sh
Created June 11, 2020 08:18 — forked from sorawit/create_account_and_init_chain.sh
create_account_and_init_chain.sh
# Create a new Band wallet. Do not lose your mnemonic!
bandcli keys add [[YOUR_WALLET]]
# Initialize a blockchain environment for generating genesis transaction.
bandd init --chain-id band-wenchang-mainnet [[YOUR_MONIKER]]
# Download genesis file from the repository.
wget https://raw.githubusercontent.com/bandprotocol/launch/master/band-wenchang-mainnet/genesis.json
# Move the genesis file to the proper location
mv genesis.json $HOME/.bandd/config
# Add some persistent peers
sed -E -i \
's/persistent_peers = \".*\"/persistent_peers = \"[email protected]:26656,[email protected]:26656\"/' \
$HOME/.bandd/config/config.toml