Skip to content

Instantly share code, notes, and snippets.

@tauoverpi
Created September 3, 2023 09:57
Show Gist options
  • Save tauoverpi/2467b6ee3330c1a3f5f51ec82c775d21 to your computer and use it in GitHub Desktop.
Save tauoverpi/2467b6ee3330c1a3f5f51ec82c775d21 to your computer and use it in GitHub Desktop.
Diagrams used when explaining stuff
// stack over time
// ,-------------,
var outputTable = Table.init(4, allocator); // ,-> | outputTable |
// | |-------------|---,
for (alerts.value.data.alerts) |a| { // | | outputTable | a | stack location of `r`
// | |-------------|---|---,
var r = [_][]u8{ // | | outputTable | a | r | stack location of the fields of `a` when placed in the array of slices passed to `r` -------,
// | |-------------|---|---|-------------------, |
a.labels.instance, // f | | outputTable | a | r | a.labels.instance | |
// l | |-------------|---|---|-------------------|---------, |
a.state, // o | | outputTable | a | r | a.labels.instance | a.state | |
// w | |-------------|---|---|-------------------|---------|--------------------, |
a.labels.alertname, // | | outputTable | a | r | a.labels.instance | a.state | a.labels.alertname | |
// | |-------------|---|---|-------------------|---------|--------------------|---------------------------, |
a.annotations.description, // | | outputTable | a | r | a.labels.instance | a.state | a.labels.alertname | a.annotations.description | |
}; // | |-------------|---|---|-------------------|---------|--------------------|---------------------------|--------------,
try outputTable.addRow(&r); // | | outputTable | a | r | a.labels.instance | a.state | a.labels.alertname | a.annotations.description | addRow frame |
// | |-------------|---'---'-------------------'---------'--------------------'---------------------------'--------------'
} // '-- | outputTable | everything within is dropped at the end of scope <--------------------------------------------------'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment