Skip to content

Instantly share code, notes, and snippets.

@dakom
dakom / ECS notes.md
Last active April 28, 2024 04:50
ECS with sparse array notes (EnTT style)

Intro

The below is a breakdown / bird's eye view of how a sparse-array backed ECS like EnTT or Shipyard works.

Please see the thanks and references at the bottom - without their help I would not have been able to share this breakdown with you... everything here is really just notes and rephrasing of what they've written already :)

Also, these notes do not cover archetype systems (like unity) nor adaptations of archetypes (like in Flecs). Though there's a couple comparative footnotes at the end.

Here we go!

@dakom
dakom / cosmwasm notes.md
Last active November 19, 2023 08:49
Cosmwasm notes

Wasmd setup

Basic WASMD Setup

after make install (or on apple silicon: LEDGER_ENABLED=false make install)

our chain-id is going to be localwasmd our gas denomination is going to be configured to uwasm staking denomination is the default ustake

the following sortof mimics the explicit steps in https://github.com/CosmWasm/wasmd/blob/main/contrib/local/setup_wasmd.sh

@dakom
dakom / route.rs
Created February 14, 2023 16:54
rust frontend page routing example w/ pure web_sys
use wasm_bindgen::JsValue;
use web_sys::{window, Url};
#[derive(Debug, Clone, PartialEq)]
pub enum Route {
Home,
Profile {
// optional user id
// None means "me"
user_id: Option<String>
@dakom
dakom / cosmwasm_vm_gas_profile.rs
Last active November 17, 2022 15:34
cosmwasm vm gas profiling
// EXAMPLE:
// let contract_1 = Contract::new("contract_1", contract_1::msg::InstantiateMsg{});
// let (gas_used, resp) = contract_1.execute(contract_1::msg::ExecuteMsg::Foo{inner_msg_data: "bar"});
// println!("computational gas used: {}", gas);
// println!("execution response: {:?}", resp);
//
// storage actions can also be calculated by estimating as follows:
@dakom
dakom / terra.ts
Last active April 2, 2022 19:54
Terra helpers
import {AccAddress, Coins, Wallet, CreateTxOptions, MsgStoreCode, MsgInstantiateContract, MsgExecuteContract} from "@terra-money/terra.js";
import {TxResult} from '@terra-dev/wallet-types';
// frequency of polling a transaction to see if it's ready
export const DEFAULT_TRANSACTION_INFO_POLL_WAIT:number = 500; //500ms
// amount of time to wait before giving up on transaction finishing
export const DEFAULT_TRANSACTION_INFO_TIMEOUT:number = 1000 * 60 * 5; // 5 mins
// amount of time to wait after uploading, due to localterra weirdness
@dakom
dakom / socat port tunnel.txt
Last active December 22, 2021 18:10
forward ports
this will allow connections to local machines local port to be forwarded to remote_ip and remote port
socat tcp-listen:[LOCAL_PORT],reuseaddr,fork tcp:[REMOTE_IP]:[REMOTE_PORT]
@dakom
dakom / run.sh
Created December 22, 2021 18:09
Re-run some command until clean exit
#!/bin/sh
until cargo +nightly run --bin parse
do
echo "crashed with exit code $?. Respawning.." >&2
sleep 1
done
@dakom
dakom / Components Snippets.json
Last active January 19, 2021 15:49
components snippets
{
"ComponentSetup": {
"scope": "javascript,typescript",
"body": [
"import {argsToAttrs} from \"@utils/attributes\";",
"import \"@elements/path/to/$2\";",
"",
"export default {",
"\ttitle: \"\"",
"}",
@dakom
dakom / wasm-async-002.md
Created October 22, 2020 08:08
Rust Async notes from Pauan

(I asked): what's the reason for async requiring its data to be 'static? I want to say it's because of multithreading, that the async runtime is free to move everything between threads... but that doesn't apply with JS...

Pauan answered:

@dakom nothing to do with multithreading all heap allocated things must be 'static, because they outlive the stack references are always on the stack therefore they cannot outlive the stack so if you put something onto the heap... such as by using Box, or Rc...