Skip to content

Instantly share code, notes, and snippets.

View VictorQueiroz's full-sized avatar
🏠
Working

Victor Queiroz VictorQueiroz

🏠
Working
View GitHub Profile
@VictorQueiroz
VictorQueiroz / 99-emscripten.sh
Last active November 27, 2024 17:50
Disable automatic loading of the EMscripten SDK in the current shell, and only load it when any of its relevant executables is called (e.g. `emcc`, `emcc`, `em++`, etc.).
#!/bin/bash
# You can put this script inside `/etc/profile.d` and it will only load EMscripten
# if `emcc`, `em++`, `emsdk`, emcmake`, or `emconfigure` are used.
#
# The script is made to source `emsdk_env.sh` once and only once.
# Unless you open another terminal tab. But still, it is just a matter of calling `emsdk` or any
# of the commands mentioned.
# Unset the functions to avoid an infinite loop.
@VictorQueiroz
VictorQueiroz / cleanse-all-but-major.sh
Created September 24, 2024 18:36
Convert v20.1.2 to 20 using Bash/ZSH Script
#!/bin/bash
regular_expressions=(
's/(\.)+$//' # remove trailing dots
's/^[a-zA-Z]//' # remove leading characters
's/(\.[0-9]+)+$//' # remove any minor and patch versions
)
result="$1"
@VictorQueiroz
VictorQueiroz / enable-git-gpg-signing.sh
Created September 24, 2024 16:28
Enable Git GPG signing for every commit and tag
#!/bin/bash
git config --global tag.gpgsign true
git config --global commit.gpgsign true
@VictorQueiroz
VictorQueiroz / find-duplicates.sh
Last active September 22, 2024 03:19
Print a list of duplicate files in a folder.
#!/bin/bash
# Example: find_duplicates.sh . "*.jpg"
if [ $# -ne 1 ]; then
echo "Usage: $0 <dir> [name_pattern]"
exit 1
fi
if [ ! -d "$1" ]; then
@VictorQueiroz
VictorQueiroz / README.md
Created September 20, 2024 16:35
Select SSH key based on remote URL match

match.sh

Checks the remote URL of the Git repository in the current working directory against the given pattern. If the pattern matches, the shell script exits with a non-zero exit code.

If there isn't a match, or, if the current working directory isn't a Git repository, the shell script exits with a failure (non-zero exit code).

Usage

~/.ssh/match.sh [pattern]
@VictorQueiroz
VictorQueiroz / match.sh
Created September 20, 2024 15:49
Exit with zero in case the first argument is present in the Git remote URL at the working directory. If the current folder does not have a `.git` directory at the place where this file is executed, exit with 1.
#!/bin/sh
# Usage: ./match.sh VictorQueiroz && ls
# Usage: ./match.sh VictorQueiroz && echo "contains"
if [ ! -d .git ]; then
exit 1
fi
if git remote get-url origin | grep -q $1; then
@VictorQueiroz
VictorQueiroz / .config
Last active August 30, 2024 21:26
ThinkCentre M70q Clear Linux kernel configuration
#
# Automatically generated file; DO NOT EDIT.
# Linux/x86 6.10.6 Kernel Configuration
#
CONFIG_CC_VERSION_TEXT="gcc (GCC) 14.2.1 20240805"
CONFIG_CC_IS_GCC=y
CONFIG_GCC_VERSION=140201
CONFIG_CLANG_VERSION=0
CONFIG_AS_IS_GNU=y
CONFIG_AS_VERSION=24300
@VictorQueiroz
VictorQueiroz / gist:f05bbb64e5f5342eda93940783b07f55
Created August 30, 2024 14:16
Easy way to compile anything from the command-line to X.org using `xsel` command-line tool
# Example usage
# echo "a" | xsel -ib
@VictorQueiroz
VictorQueiroz / 10_linux.sh
Last active August 23, 2024 19:24
Append Clear Linux specific kernel parameters specifically to `clear-linux` kernel
#! /bin/sh
set -e
# grub-mkconfig helper script.
# Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc.
#
# GRUB is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
@VictorQueiroz
VictorQueiroz / get-abbreviation-from-string-start-similarity.ts
Created June 28, 2023 00:51
Get abbreviation from the string by comparing start of the string. Useful for creating convenient TypeScript enum names.
const s = [
"ApiAuthTypeFacebook",
"ApiAuthTypeGoogle",
"ApiAuthTypeLinkedIn",
"ApiAuthTypeGithub",
];
function getAbbreviationFromStartSimilarity(s: string[]) {
let match = "";
for (const n of s) {