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 / 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 / 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 / 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 / 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 / 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 / private_fork.md
Created September 7, 2022 12:30 — forked from 0xjac/private_fork.md
Create a private fork of a public repository

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)

git clone --bare [email protected]:usi-systems/easytrace.git

@rubensa
rubensa / pipewire.md
Created April 1, 2022 18:46 — forked from the-spyke/pipewire.md
Enable PipeWire on Ubuntu 21.10

Enable PipeWire on Ubuntu 21.10

Ubuntu 21.10 has PipeWire partially installed and enabled as it's used by browsers (WebRTC) for recoding the screeen under Wayland. We can enable remaining parts and use it for audio and Bluetooth instead of PulseAudio.

This guide is only for original Ubuntu out-of-the-box packages. If you have added a custom PPA, you might get into conflicts.

Based on the Debian Wiki, but adopted for Ubuntu 21.10.

Install

Configure systemd-resolved to use a specific DNS nameserver for a given domain

Use case

Given

  • I use a VPN to connect to my work network
  • I'm on a Linux computer that uses systemd-resolved
  • I have a work domain called example.com
  • example.com is hosted by both public and private DNS nameservers
@rubensa
rubensa / uncheck-checkboxes.js
Last active December 14, 2021 05:35
Chrome DevTools Snippet to click on an element and uncheck all contained checkboxes.
// uncheck-checkboxes.js
// https://gist.github.com/rubensa/5128d5c8b85eb82ca970d89222693128
// Chrome DevTools Snippet to click on an element and uncheck all contained checkboxes.
// Starting Firefox 72, you can import a Javascript file content in the console input with Ctrl + O (Cmd + O on macOS), as well as saving the console input content to a file using Ctrl + S (Cmd + S on macOS).
(function() {
function uncheckCheckboxes(e) {
e.preventDefault();
e.stopPropagation();
window.removeEventListener('mousedown', uncheckCheckboxes, true);