Skip to content

Instantly share code, notes, and snippets.

@joseluisq
joseluisq / terminal-git-branch-name.md
Last active February 9, 2025 02:05
Add Git Branch Name to Terminal Prompt (Linux/Mac)

Add Git Branch Name to Terminal Prompt (Linux/Mac)

image

Open ~/.bash_profile in your favorite editor and add the following content to the bottom.

# Git branch in prompt.

parse_git_branch() {

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Gotten from the RedHat GPG migration manual

Backup the public and secret keyrings and trust database

## Export all public keys

gpg -a --export >mypubkeys.asc

@joseluisq
joseluisq / 0README.md
Last active January 28, 2025 05:31
Configuring httpd (apache2) and php 7.2 in Mac using Homebrew

Configuring httpd (apache2) and php 7.2 in Mac using Homebrew

# 0. Disable built-in Apache
sudo apachectl stop
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null

# 1. Install httpd
brew install httpd
@joseluisq
joseluisq / README.md
Last active January 19, 2025 23:20
Install and configure Traefik as Reserver Proxy in a non-docker environment.

Traefik as Reserver Proxy in RHE/CentOS 7

Install and configure Traefik as Reserver Proxy in a non-docker environment.

Donwload and install Traefik

curl -L https://github.com/containous/traefik/releases/download/v1.7.12/traefik_linux-amd64 -o /usr/local/bin/traefik
chmod +x /usr/local/bin/traefik
@joseluisq
joseluisq / resize_disk_image.md
Last active January 19, 2025 19:43
How to resize a qcow2 disk image on Linux

How to resize a qcow2 disk image on Linux

This example takes olddisk.qcow2 and resizes it into newdisk.qcow2, extending one of the guest's partitions to fill the extra space.

1. qcow2 format

1.1. Verify the filesystems of olddisk.qcow2

@joseluisq
joseluisq / disable_git_gnome_ssh_askpass.md
Last active December 26, 2024 20:50
Disable Git gnome-ssh-askpass on RedHat related OS (Fedora, CentOS)

Disable Git gnome-ssh-askpass on RedHat related OS (Fedora, CentOS)

1.- Add these lines to ~/·bashrc or ~/.zshrc file :

[ -n "$SSH_CONNECTION" ] && unset SSH_ASKPASS
export GIT_ASKPASS=

2.- Update source files:

@joseluisq
joseluisq / export_vscode_extesions.md
Last active November 29, 2024 11:15
How to export your VS Code extensions from terminal

How to export your VS Code extensions from terminal

Note: Unix-like systems only.

  1. Export your extensions to a shell file:
code --list-extensions | sed -e 's/^/code --install-extension /' > my_vscode_extensions.sh
@joseluisq
joseluisq / add_two_times.js
Last active November 6, 2024 13:45
Add two string time values (HH:mm:ss) with javascript
/**
* Add two string time values (HH:mm:ss) with javascript
*
* Usage:
* > addTimes('04:20:10', '21:15:10');
* > "25:35:20"
* > addTimes('04:35:10', '21:35:10');
* > "26:10:20"
* > addTimes('30:59', '17:10');
* > "48:09:00"
@joseluisq
joseluisq / stash_dropped.md
Last active August 5, 2024 08:36
How to recover a dropped stash in Git?

How to recover a dropped stash in Git?

1. Find the stash commits

git log --graph --oneline --decorate ( git fsck --no-reflog | awk '/dangling commit/ {print $3}' )

This will show you all the commits at the tips of your commit graph which are no longer referenced from any branch or tag – every lost commit, including every stash commit you’ve ever created, will be somewhere in that graph.

@joseluisq
joseluisq / env.ts
Last active August 2, 2024 00:46
Get a Typescript typed environment variable value from `process.env` (NodeJS) with type casting for booleans, strings and numbers
/**
* Return an environment variable typed value from `process.env`.
* It also supports a default value in case of `undefined`.
*
* The function will follow these steps to take a typed value:
* 1. First it will try to get the env value from `process.env`.
* 2. Then if `undefined` then it try with the default environment variable value if defined.
* 3. Otherwise if the default value is `undefined` then it will return the Javascript default values:
* - Boolean: `false`
* - String: `""`