Skip to content

Instantly share code, notes, and snippets.

View rubensa's full-sized avatar
💭
¯\(°_o)/¯ ¯\_(ツ)_/¯

Ruben Suarez Alvarez rubensa

💭
¯\(°_o)/¯ ¯\_(ツ)_/¯
View GitHub Profile
@rubensa
rubensa / bash_strict_mode.md
Created August 3, 2023 12:02 — forked from vncsna/bash_strict_mode.md
set -e, -u, -o, -x pipefail explanation

set -e, -u, -o, -x pipefail

The set lines

  • These lines deliberately cause your script to fail. Wait, what? Believe me, this is a good thing.
  • With these settings, certain common errors will cause the script to immediately fail, explicitly and loudly. Otherwise, you can get hidden bugs that are discovered only when they blow up in production.
  • set -euxo pipefail is short for:
set -e
set -u
@rubensa
rubensa / docker-multiarch-custom-builder.sh
Created August 9, 2023 10:03
Docker multiarch custom builder
#!/usr/bin/env bash
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker buildx create --name multiarch --driver docker-container --use
docker buildx inspect --bootstrap
@rubensa
rubensa / who_is_my_mummy.sh
Created September 19, 2023 06:44 — forked from joechrysler/who_is_my_mummy.sh
Find the nearest parent branch of the current git branch
#!/usr/bin/env zsh
git show-branch -a \
| grep '\*' \
| grep -v `git rev-parse --abbrev-ref HEAD` \
| head -n1 \
| sed 's/.*\[\(.*\)\].*/\1/' \
| sed 's/[\^~].*//'
# How it works:
@rubensa
rubensa / index.html
Created November 3, 2023 07:44 — forked from miguelmota/index.html
Swagger UI authorization header bearer access token
<script>
window.onload = function() {
fetch('./swagger.json')
.then(function(response) {
response.json()
.then(function(json) {
json.schemes[0] = window.location.protocol.slice(0, -1)
json.host = window.location.host
const ui = SwaggerUIBundle({
@rubensa
rubensa / get-latest-tag-on-git.sh
Created November 28, 2024 17:09 — forked from rponte/get-latest-tag-on-git.sh
Getting latest tag on git repository
# The command finds the most recent tag that is reachable from a commit.
# If the tag points to the commit, then only the tag is shown.
# Otherwise, it suffixes the tag name with the number of additional commits on top of the tagged object
# and the abbreviated object name of the most recent commit.
git describe
# With --abbrev set to 0, the command can be used to find the closest tagname without any suffix:
git describe --abbrev=0
# other examples
@rubensa
rubensa / get-latest-tag-on-git.sh
Created November 28, 2024 17:09 — forked from rponte/get-latest-tag-on-git.sh
Getting latest tag on git repository
# The command finds the most recent tag that is reachable from a commit.
# If the tag points to the commit, then only the tag is shown.
# Otherwise, it suffixes the tag name with the number of additional commits on top of the tagged object
# and the abbreviated object name of the most recent commit.
git describe
# With --abbrev set to 0, the command can be used to find the closest tagname without any suffix:
git describe --abbrev=0
# other examples
@rubensa
rubensa / display.py
Last active June 10, 2025 07:36
Display JSON data as HTML in Jupyter Notebook for VSCode.
import json
import uuid
from IPython.display import display_html, display_javascript
__all__ = [
"display_json",
"display_json_with_vanillajavascript",
"display_with_renderjson",
"display_with_jsonview",