Skip to content

Instantly share code, notes, and snippets.

@jesugmz
jesugmz / Deploy-Next.js-static-to-GitLab-pages.md
Last active April 9, 2024 14:33
Deploy Next.js static to GitLab pages

Deploy Next.js static to GitLab pages

Create a basic GitLab CI config:

$ cat .gitlab-ci.yml
image: node

before_script:
 - npm install
@jesugmz
jesugmz / Configure-SSH-with-multiple-git-accounts.md
Last active July 17, 2024 10:11
Configure SSH with multiple git accounts

Configure SSH with multiple git accounts

Scenario: same git provider, for this example GitHub (this trick is provider agnostic, has been tested with GitLab as well), and we want to have SSH configured for two different users (or more): jesugmz and myseconduser.

Step 1

Configure SSH config in order to get an alias with different configuration as follow:

$ cat ~/.ssh/config
@jesugmz
jesugmz / count-all-the-lines-of-given-directories-recursively.md
Last active October 23, 2019 16:50
Count all the lines of given directories recursively

Count all the lines of given directories recursively

In this example want to count the number of lines of every PHP file in two directories, dir-1 and dir-2/subdir:

find {dir-1,dir-2/subdir} -name '*.php' | xargs wc -l

The output is the sumarize of each line:

@jesugmz
jesugmz / git-tag-regex-validation-using-makefile .md
Last active July 17, 2019 20:04
Git tag regex validation using Makefile

Git tag regex validation using Makefile

This is a portion of a Makefile where I select a Git tag, validate its name using regular expresion and build a Docker image with it as tag.

# it is evaluated when is used (recursively expanded variable)
# https://ftp.gnu.org/old-gnu/Manuals/make-3.79.1/html_chapter/make_6.html#SEC59
git_tag = $(shell git describe --abbrev=0 --tags)
# Semantic versioning format https://semver.org/
tag_regex := ^v([0-9]{1,}\.){2}[0-9]{1,}$
@jesugmz
jesugmz / check-if-there-is-shell-command-output.md
Last active February 24, 2019 22:46
Check if there is shell command output

Check if there is shell command output

Consider the following scenario:

Problem The execution of a shell command (Radon in this example) does not retrieve an status code different to 0 when there is output (if there is output there are issues). The command does not gives parameter to handle it.

Simple solution

Check if the length of the output is non empty (-n).

@jesugmz
jesugmz / docker-hub-automated-builds-with-multi-stages.md
Last active November 15, 2022 22:45
Docker Hub automated builds with multi-stages

Docker Hub automated builds with multi-stages

Docker Hub automated builds are nice to build automatically Docker images when code is pushed to the linked git repository but they do not support Docker multi-stages by default.

To do so is needed to override the default commands that Docker Hub uses internally by using hooks.

In this example we have two stages:

  • dev will be built from master branch only
  • prod will be built per git tag
@jesugmz
jesugmz / ignore-deprecationwarning-in-pytest.md
Created January 29, 2019 20:26
Ignore DeprecationWarning in Pytest

Just add the following flag: pytest -W ignore::DeprecationWarning

More info

@jesugmz
jesugmz / check-docker-swarm-labels-of-a-specific-docker-swarm-node.md
Last active November 28, 2018 22:57
Check Docker Swarm labels of a specific Docker Swarm node
@jesugmz
jesugmz / coreos-notes.md
Last active December 26, 2019 15:42
CoreOS notes
@jesugmz
jesugmz / let-s-encrypt-certificate-for-dockerized-nginx-under-cloudflare.md
Last active October 19, 2023 08:23
Let’s Encrypt certificate for dockerized Nginx under Cloudflare