Skip to content

Instantly share code, notes, and snippets.

@chx
chx / gist:22fe4f2fee869a7ecde9e4db12d73a19
Last active April 14, 2024 16:13
Expected profit of an Einhar Harvest memory
#!/bin/bash
LEAGUE=$(curl -s https://poe.ninja/api/data/getindexstate|jq -r '.economyLeagues[0].name')
URL="https://poe.ninja/api/data/itemoverview?league=$LEAGUE&type"
# There are nine beasts in a memory and there are nine kinds of harvest beasts with equal chance. Thus, the expected value is one beast per memory and the income is the sum of their value.
# However, only five is worth selling, the two Primal C beasts are worthless, Primal Rhex Matriach (synth map) and Vivid Abberach (guardian map) we run ourselves.
BEASTS=$(curl -s "$URL=Beast" |jq -r '[.lines[]| select(.name==("Wild Hellion Alpha","Wild Brambleback","Wild Bristle Matron","Vivid Vulture","Vivid Watcher"))|.chaosValue]|add')
# There are four non-replica synth maps equally weighted, so calculate the expected value:
SYNTH=$(curl -s "$URL=UniqueMap"|jq -r '[.lines[]| select(.baseType=="Synthesised Map" and .name!="Cortex" and .name!="Replica Cortex")|.chaosValue]|add' | awk '{print $1/4}')
# It's near impossible to calculate the expected value fo
@chx
chx / YAML patch
Last active September 30, 2024 01:05
Keep comments on the top of Drupal config export files
diff --git a/core/lib/Drupal/Core/Config/FileStorage.php b/core/lib/Drupal/Core/Config/FileStorage.php
index fe202a3e0e..b0c27a32bb 100644
--- a/core/lib/Drupal/Core/Config/FileStorage.php
+++ b/core/lib/Drupal/Core/Config/FileStorage.php
@@ -147,7 +147,8 @@ public function write($name, array $data) {
}
$target = $this->getFilePath($name);
- $status = @file_put_contents($target, $encoded_data);
+ $prefix = @file_get_contents('/tmp/cexprepend' . substr($target, strlen($this->directory)));