Instantly share code, notes, and snippets.
Discover gists
t3dotgg /try-catch.ts
Last activeMarch 23, 2025 11:17
Theo's preferred way of handling try/catch in TypeScript This file contains 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
// Types for the result object with discriminated union | |
typeSuccess<T>={ | |
data:T; | |
error:null; | |
}; | |
typeFailure<E>={ | |
data:null; | |
error:E; | |
}; |
This file contains 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{LiquidityPoolKeysV4,MARKET_STATE_LAYOUT_V3,Market,TOKEN_PROGRAM_ID}from"@raydium-io/raydium-sdk"; | |
import{Connection,Logs,ParsedInnerInstruction,ParsedInstruction,ParsedTransactionWithMeta,PartiallyDecodedInstruction,PublicKey}from"@solana/web3.js"; | |
constRPC_ENDPOINT='https://api.mainnet-beta.solana.com'; | |
constRAYDIUM_POOL_V4_PROGRAM_ID='675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8'; | |
constSERUM_OPENBOOK_PROGRAM_ID='srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX'; | |
constSOL_MINT='So11111111111111111111111111111111111111112'; | |
constSOL_DECIMALS=9; | |
constconnection=newConnection(RPC_ENDPOINT); |
jakub-g /async-defer-module.md
Last activeMarch 23, 2025 11:13
async scripts, defer scripts, module scripts: explainer, comparison, and gotchasWith the addition of ES modules, there's now no fewer than 24 ways to load your JS code: (inline|not inline) x (defer|no defer) x (async|no async) x (type=text/javascript | type=module | nomodule) -- and each of them is subtly different.
This document is a comparison of various ways the<script>
tags in HTML are processed depending on the attributes set.
If you ever wondered when to use inline<script async type="module">
and when<script nomodule defer src="...">
, you're in the good place!
Note that this article is about<script>
s inserted in the HTML; the behavior of<script>
s inserted at runtime is slightly different - seeDeep dive into the murky waters of script loading by Jake Archibald (2013)
CMCDragonkai /makeWrapper_and_wrapProgram.md
CreatedAugust 24, 2018 07:50
makeWrapper and wrapProgram #nixfbradyirl /sigen_modbus_card.yaml
Last activeMarch 23, 2025 11:06
Recreate Sigenergy UI (using modbus sensors) as Home Assistant Card This file contains 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
type:custom:button-card | |
show_state:true | |
tap_action:none | |
custom_fields: | |
home_image: | |
card: | |
type:picture | |
image:local/Sigenergy/home_has_solar_has_car.png | |
card_mod: | |
style:| |
nd3w /install-lapp-ubuntu-20.04.md
Last activeMarch 23, 2025 11:03
Install Apache2, PostgreSQL and PHP-FPM on Ubuntu 20.04NewerOlder