Skip to content

Instantly share code, notes, and snippets.

@bradtraversy
bradtraversy / eslint_prettier_airbnb.md
Created July 19, 2019 17:54
ESLint, Prettier & Airbnb Setup

VSCode - ESLint, Prettier & Airbnb Setup

1. Install ESLint & Prettier extensions for VSCode

Optional - Set format on save and any global prettier options

2. Install Packages

npm i -D eslint prettier eslint-plugin-prettier eslint-config-prettier eslint-plugin-node eslint-config-node
@dvcrn
dvcrn / index.ts
Last active June 15, 2024 23:34
get metadata from metaplex
// EDIT: It's now much easier to get metadata from metaplex using the js package.
// Check the new gist here: https://gist.github.com/dvcrn/a1b0ff0a0b4b3ab02aff44bc84ac4522
// I didn't want to edit this gist because a lot of people found it helpful to see how to manually decode a account
import * as web3 from "@solana/web3.js";
import * as metadata from "./metadata"; // see metadata.ts
const tokenAddress = new web3.PublicKey(
"CxkKDaBvtHqg8aHBVY8E4YYBsCfJkJVsTAEdTo5k4SEw"
);

fiveoutofnine simplified

Some of the bit twiddling in my Solidity implementation of an on-chain engine, fiveoutofnine.sol, can be quite esoteric, so I've recreated some of the logic below. Note that the code below is only logically equivalent (gives same results, but do different things). Functions have similar names, so it should be pretty easy to match up to the functions from Chess.sol and Engine.sol. The main abstraction in these files are using an array for the board (as opposed to 64 bitpacked uint4s) and struct for moves (as opposed to 2 bitpacked uint6s). To further simplify it, it's in a language anyone can read easily: Python.

Chess.py

class Move:
    def __init__(self, from, to):
        self.from = from
        self.to = to