Skip to content

Instantly share code, notes, and snippets.

View math-queiroz's full-sized avatar
:shipit:
coding, probably

Matheus Queiroz math-queiroz

:shipit:
coding, probably
View GitHub Profile
@math-queiroz
math-queiroz / bash_logging_functions.sh
Created July 8, 2025 14:09
Some basic bash scripting log functions
#!/usr/bin/env bash
log() { local LEVEL=$1 MESSAGE=$2 NOW=$(date +%s); printf "%s[%04ds] %s\n" "$LEVEL" "$SECONDS" "$MESSAGE"; }
info() { log "$(tput setaf 4)INFO$(tput sgr0)" "$@"; }
warn() { log "$(tput setaf 3)WARN$(tput sgr0)" "$@"; }
error() { log "$(tput setaf 1)ERROR$(tput sgr0)" "$@"; }
if [ "$DEBUG" = "1" ]; then debug() { log "$(tput setaf 5)DEBUG$(tput sgr0)" "$@"; }
else debug() { :; }; fi
@math-queiroz
math-queiroz / AutoAcceptICS.js
Created August 20, 2024 16:07
Thunderbird filter using filtaquilla JS with body action to auto accept events invites to the first calendar
// Thunderbird auto adopt ICS via filtaquilla
function getMessageICSBodyTextFromHdr(msgHdr) {
let s = msgHdr.getStringProperty("subject");
if ( s != undefined && s.length != undefined && s.length > 0) {
let listener = Components
.classes["@mozilla.org/network/sync-stream-listener;1"]
.createInstance(Components.interfaces
.nsISyncStreamListener);
let uri = msgHdr.folder.getUriForMsg(msgHdr);
MailServices
@math-queiroz
math-queiroz / wtgridsplit.ps1
Last active December 12, 2023 20:35
WindowsTerminal dynamic pane grid split with support to commands from template string and item array
# Usage: ./wtgridsplit.ps1 <row> <col> <template-string> <comma-separated-array>
# obs.: Requires the wt.exe command to be known to the system via the PATH variable
# e.g.:
# ./wtgridsplit.ps1 3 3
# ./wtgridsplit.ps1 1 2 "{0}" "cmd /k echo Hello world!,cmd /c ping 127.0.0.1"
# ./wtgridsplit.ps1 2 3 "cmd /k echo This is pane {0}!" "A,B,C,D,E"
$h = [Int32] $args[0]
$w = [Int32] $args[1]
$fmts = [String[]] $args[2]
@math-queiroz
math-queiroz / pwsh-profile.ps1
Last active September 7, 2024 23:30
my powershell profile
<# Quick set from powershell with:
mkdir $HOME/Documents/PowerShell
Invoke-WebRequest -URI https://gist.githubusercontent.com/math-queiroz/bfd3f27d669d452ee81255aa479ade62/raw/pwsh-profile.ps1 -OutFile $PROFILE -UserAgent $USERAGENT
#>
# Set PowerShell to UTF-8
[console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding
# PSReadLine
Set-PSReadLineOption -BellStyle None
@math-queiroz
math-queiroz / discord_webhook.sh
Last active June 6, 2023 22:25
A simple script for integrating discord webhooks and perforce triggers through a bash script or powershell script.
#!/bin/bash
## Discord Webhooks and Perforce Commit Trigger integration shell script
##
## Usage:
## * Make sure the trigger user has proper script execution permissions;
## * Make sure the trigger user is logged in p4 server with an unlimited timeout account;
##
## Use `p4 triggers` command to append the following line to the end of the triggers file (changing the <depot_name>):
## global-change change-commit //<depot_name>/... "/p4/1/root/discord_webhook.sh %change%"