- Optional/nullable data types.
- Variant data types.
- Flag with extra information needed only in some cases (or different in different cases).
- Modeling states in a state machine where each state can have some data associated with it.
- List of operations for batch processing, where each operation can have its own arguments.
- Alternative to function overloading that allows avoiding combinatorial explosion when there are multiple parameters that need variants.
- Nested data structures with heterogenous nodes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as web3 from "@solana/web3.js"; | |
| ////////////////////////////////////////////////// | |
| function readBytes(buf: Buffer, offset: number, length: number): Buffer { | |
| const end = offset + length; | |
| if (buf.byteLength < end) throw new RangeError("range out of bounds"); | |
| return buf.subarray(offset, end); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def numberToBase(n, b): | |
| if n == 0: | |
| return [0] | |
| digits = [] | |
| while n: | |
| digits.append(int(n % b)) | |
| n //= b | |
| return digits[::-1] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * parsesats.js | |
| * | |
| * This script is used to parse short sat names from a UTXO output it scrapes the explorer html | |
| * | |
| * Command usage: | |
| * node parsesats.js [output] [name] [host] | |
| * | |
| * [output]: The UTXO | |
| * [name]: The name short names like 4 charcters are pretty common. Must be less than 11 characters. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| Convert between rune symbols and values using Base 26 (A=1) | |
| Similar rust implementation at https://github.com/ordinals/ord/blob/f3cae5400fdebf31bfd494a02c846a90ea12310d/src/sat.rs#L63 | |
| */ | |
| class Rune { | |
| constructor(public value: number) { } | |
| public get name(): string { | |
| let x = this.value; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "1": { | |
| "rpcs": [ | |
| "https://api.mycryptoapi.com/eth", | |
| "https://rpc.flashbots.net/", | |
| "https://eth-mainnet.gateway.pokt.network/v1/5f3453978e354ab992c4da79", | |
| "https://cloudflare-eth.com/", | |
| "https://mainnet-nethermind.blockscout.com/", | |
| "https://nodes.mewapi.io/rpc/eth", | |
| "https://main-rpc.linkpool.io/", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 1. Import everything | |
| import { Wallet, BigNumber, ethers, providers } from 'ethers' | |
| const { FlashbotsBundleProvider, FlashbotsBundleResolution } = require('@flashbots/ethers-provider-bundle') | |
| /* | |
| Mainnet | |
| const provider = new providers.JsonRpcProvider('https://eth-mainnet.g.alchemy.com/v2/cmHEQqWnoliAP0lgTieeUtwHi0KxEOlh') | |
| const wsProvider = new providers.WebSocketProvider('wss://eth-mainnet.g.alchemy.com/v2/cmHEQqWnoliAP0lgTieeUtwHi0KxEOlh') | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
| <title>Momoglyphs Test Visualizer</title> | |
| <link rel='icon' href='favicon/favicon.ico' type='image/x-icon'/ > | |
| <script charset="utf-8" src="https://cdn.ethers.io/scripts/ethers-v4.min.js" type="text/javascript"></script> | |
| <script charset="utf-8" src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.12.0/d3.min.js" type="text/javascript"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env node | |
| const assert = require('assert') | |
| const Words = [ | |
| "like", "just", "love", "know", "never", "want", "time", "out", "there", "make", "look", "eye", | |
| "down", "only", "think", "heart", "back", "then", "into", "about", "more", "away", "still", "them", | |
| "take", "thing", "even", "through", "long", "always", "world", "too", "friend", "tell", "try", "hand", | |
| "thought", "over", "here", "other", "need", "smile", "again", "much", "cry", "been", "night", "ever", | |
| "little", "said", "end", "some", "those", "around", "mind", "people", "girl", "leave", "dream", "left", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CALL apoc.periodic.iterate(" | |
| CALL apoc.load.json('file:///Users/f/source/companies.json') | |
| YIELD value UNWIND value.rows AS row RETURN row | |
| ", " | |
| MERGE (c:Company {id: row.id}) | |
| ON CREATE SET c.id = row.id, c.name = row.name | |
| WITH row | |
| UNWIND row.relatedPersons as item | |
| MERGE (p:Person {id: item.person.id}) | |
| ON CREATE SET p.id = item.person.id, p.name = item.person.name |
NewerOlder