Skip to content

Instantly share code, notes, and snippets.

@szydan
szydan / gist:2b52906bb58b41c59993527f277dd414
Created July 29, 2025 10:39
Bash error reporting trick
From
https://utcc.utoronto.ca/~cks/space/blog/programming/BashGoodSetEReports
Suppose that you have a shell script that's not necessarily complex but is at least long. For reliability, you use 'set -e' so that the script will immediately stop on any unexpected errors from commands, and sometimes this happens. Since this isn't supposed to happen, it would be nice to print some useful information about what went wrong, such as where it happened, what the failing command's exit status was, and what the command was. The good news is that if you're willing to make your script specifically a Bash script, you can do this quite easily.
The Bash trick you need is:
trap 'echo "Exit status $? at line $LINENO from: $BASH_COMMAND"' ERR
This uses three Bash features: the special '$LINENO' and '$BASH_COMMAND' environment variables (which have the command executed just before the trap and the line number), and the special 'ERR' Bash 'trap' condition that causes your 'trap' statement to be invoked right when 'set -e' is c
ffmpeg -i input.mov \
-c:v libx264 -preset medium -crf 28 \
-c:a aac -b:a 128k \
output.mp4
ffmpeg -i input.mov \
-vf scale=1280:-2 \
-c:v libx264 -preset medium -crf 28 \
-an \
@szydan
szydan / gist:05ba4b6024e72ff716bf97c14c9c97b7
Created May 22, 2025 14:46
replacing file inside zip
// THIS is the trick to have the same folder structure as in the archive you are modifying
mkdir -p siren-platform-demo-data-14.8.0-SNAPSHOT-darwin-x86_64/siren-investigate
unzip -p siren-platform-demo-data-14.8.0-20250513.083732-50-darwin-x86_64.zip 'siren-platform-demo-data-14.8.0-SNAPSHOT-darwin-x86_64/siren-investigate/package.json' > siren-platform-demo-data-14.8.0-SNAPSHOT-darwin-x86_64/siren-investigate/package.json
less siren-platform-demo-data-14.8.0-SNAPSHOT-darwin-x86_64/siren-investigate/package.json
// HERE MODIFY THE VERSION
zip -ur siren-platform-demo-data-14.8.0-20250513.083732-50-darwin-x86_64.zip 'siren-platform-demo-data-14.8.0-SNAPSHOT-darwin-x86_64/siren-investigate/package.json'
GET .siren/_search
{
"_source": false,
"query": {
"bool": {
"must": [
{ "exists": { "field": "search.indexPattern.fieldFormatMap.keyword" }},
{
"script": {
"script": {
@szydan
szydan / gist:35160debce7d1c8039a36c1a13f0bfa6
Created March 20, 2025 23:04
To manually fix unassigned shard
GET _cat/nodes?format=json
GET _cat/shards/index-name
GET _cat/indices/index-name
POST _cluster/reroute
{
"commands": [{
"allocate_empty_primary": {
@szydan
szydan / gist:7328a32927bddd942fac1cd13331cc2d
Created January 6, 2025 21:27
Number of existing fields in .siren
curl -s -H "Content-Type: application/json" -XGET -k -u admin:password https://localhost:9220/.siren/_field_caps?fields=* | jq '.fields | length'
@szydan
szydan / gist:5495a40aad1f0378634e978a95c7c199
Created December 4, 2024 17:38
Change node-pool size
gcloud container clusters update cicd \
--node-pool=pr-build-investigate-1 \
--enable-autoscaling \
--min-nodes=1 \
--max-nodes=100 \
--zone=europe-west1-c
docker pull europe-west1-docker.pkg.dev/siren-cicd/docker/jenkins-agent:chrome-128-latest
docker run -it europe-west1-docker.pkg.dev/siren-cicd/docker/jenkins-agent:chrome-128-latest /bin/bash
google-chrome --version
google-chrome-stable --version
@szydan
szydan / gist:073d913b75399faf6273d013bd5d2057
Last active October 4, 2024 11:49
How to redeploy the deployment with new image
Before running the commands make sure you are on correct cluster
kubectl config use-context gke_siren-cicd_europe-west1-c_cicd-volatile
kubectl -n branch-er set image deployment/branch-er-er \
platform-bundle-demo-data-snapshot=eu.gcr.io/siren-cicd/siren-platform-demo-data-snapshot:branch-er-75
kubectl -n branch-er rollout status deployment/branch-er-er
@szydan
szydan / gist:20664ed46f7fd172f0f63f5705872900
Created September 5, 2024 07:47
To start debugging session pod with mounted filesystem
create a debugging pod
file system mounted at
/host
kubectl debug node/gke-cicd-build-pool-4509cbfd-vh9s -it --image=ubuntu
see how much space is taken there
all the overlay