Skip to content

Instantly share code, notes, and snippets.

View tiagoad's full-sized avatar
🔨

Tiago tiagoad

🔨
View GitHub Profile
@tiagoad
tiagoad / git-pull-readonly.md
Last active September 28, 2026 18:23
Force read-only HTTPs pulls on SSH github remotes.

I have my main git SSH key stored in 1Password, and I use the 1Password agent to make it available in my system.
This means whenever I run git pull or similar read-only commands I need to touch my fingerprint sensor. I was looking for a solution that would only prompt me for pushes.

Unfortunately, git doesn't support read-only SSH keys.

This gist describes a workaround which:

  • Forces clones/pulls/etc to use HTTPS with a read-only finegrained personal access token
  • Forces pushes to use SSH with specific public key

This solution is not limited to 1Password, it works with any type of ssh private key.

@tiagoad
tiagoad / check-coreutils.sh
Created July 21, 2026 05:40
Find GNU coreutils executable (portable)
#!/bin/sh
is_gnu() {
command -v "$1" >/dev/null \
&& "$1" --help 2>&1 | grep "@gnu.org" >/dev/null
}
get_gnu() {
if is_gnu "$1"; then
# is regular name
Summary of ANSI standards for ASCII terminals Joe Smith, 18-May-84
Contents:
1. Overview and Definitions
2. General rules for interpreting an ESCape Sequence
3. General rules for interpreting a Control Sequence
4. C0 and C1 control codes in numeric order
5. Two and three-character ESCape Sequences in numeric order
6. Control Sequences in numeric order
7. VT100 emulation requirements
@tiagoad
tiagoad / nonprint.md
Created January 13, 2025 13:24
Script/command to replace non-printable characters with a placeholder in the format used by Sublime Text

Example:

Screenshot 2025-01-13 at 13 18 51

Add to .bashrc/.zshrc as an alias:

alias nonprint='perl -pe "use Term::ANSIColor; s/([^[:print:]\n])/colored(sprintf(\"<0x%02x>\", ord($1)), magenta)/ge"'

Use it as a script:

@tiagoad
tiagoad / top-commands.sh
Created January 13, 2025 12:50
Top commands in bash/zsh history (Linux/Mac)
fc -ln 1 | sed 's/^\t //' | awk '{print $2}' | sort | uniq -c | sort -n
@tiagoad
tiagoad / check-updates.sh
Last active January 13, 2025 12:51
Check updated golang direct dependencies in go module
go list -mod=mod -f '{{if and (not .Indirect) .Update}}{{.String}}{{end}}' -m -u all
@tiagoad
tiagoad / push_to_talk.ahk
Last active August 5, 2021 21:49
A AutoHotKey script to implement push-to-talk at the Windows mixer level.
; ------------
; Push to talk
; ------------
;
; This AutoHotKey script implements push-to-talk at the Windows mixer level.
;
; The hotkey set by HOTKEY_TOGGLE will toggle between "Open" and "PTT" mode:
; - Open: Microphone is unmuted;
; - PTT: Microphone is only unmuted while HOTKEY_PTT is pressed.
;
@tiagoad
tiagoad / fix_wayland.sh
Created December 4, 2020 11:47
Fix "Firefox is already running" when opening links through other software on a wayland environment.
sudo su -c 'echo "export MOZ_DBUS_REMOTE=1" > /etc/profile.d/firefox_wayland_fixes.sh'
@tiagoad
tiagoad / concelhos.csv
Created October 27, 2020 14:15
População por concelho (Portugal)
ABRANTES 35377
AGUIAR DA BEIRA 4740
ALANDROAL 5064
ALBERGARIA-A-VELHA 24128
ALBUFEIRA 41123
ALCANENA 12860
ALCOBAÇA 53641
ALCOCHETE 19505
ALCOUTIM 2244
ALCÁCER DO SAL 11712
@tiagoad
tiagoad / docker-compose.yml
Created May 21, 2020 21:28
Uber Cadence on Docker Swarm + mySQL
version: '3.5'
networks:
# for use by containers in other docker-compose files to connect to cadence
cadence:
# telegraf network (set up in another docker-compose file, you can replace with your own logging solution)
monitoring_monitoring:
external: true