Skip to content

Instantly share code, notes, and snippets.

View revolter's full-sized avatar

iulianOnofrei (U-lee-aan) revolter

View GitHub Profile
@keenahn
keenahn / git-default-branch.sh
Last active November 16, 2023 10:21
A simple bash script to check if the default branch is main or master for a given repo
#!/bin/bash
# Check if the remote 'origin' has a 'main' branch
if git show-branch remotes/origin/main > /dev/null 2>&1; then
echo "main"
else
echo "master"
fi
@TheSherlockHomie
TheSherlockHomie / RenewExpiredGPGkey.md
Created January 3, 2021 16:36
Updating expired GPG keys and backing them up 🔑🔐💻

Updating expired GPG keys and their backup 🔑🔐💻

I use a GPG key to sign my git commits.

An error like this one might be a sign of an expired GPG key.

error: gpg failed to sign the data fatal: failed to write commit object
@samvrlewis
samvrlewis / longest-git-commit-message
Last active January 18, 2024 12:48
Get the longest git commit messages
git rev-list --no-merges "${1:-HEAD}" | while read rev; do echo "$(git show -s --format='%b' $rev | wc -w) words: $rev"; done | sort -rn | head -6 | cut -f2 -d: | xargs -I{} git rev-list --pretty=medium {} --max-count=1
@mohanpedala
mohanpedala / bash_strict_mode.md
Last active May 13, 2024 18:55
set -e, -u, -o, -x pipefail explanation
@paolocarrasco
paolocarrasco / README.md
Last active May 3, 2024 15:20
How to understand the `gpg failed to sign the data` problem in git

Problem

You have installed GPG, then tried to commit and suddenly you see this error message after it:

error: gpg failed to sign the data
fatal: failed to write commit object

Debug

@mdonkers
mdonkers / server.py
Last active May 6, 2024 23:32
Simple Python 3 HTTP server for logging all GET and POST requests
#!/usr/bin/env python3
"""
License: MIT License
Copyright (c) 2023 Miel Donkers
Very simple HTTP server in python for logging requests
Usage::
./server.py [<port>]
"""
from http.server import BaseHTTPRequestHandler, HTTPServer
@judy2k
judy2k / parse_dotenv.bash
Created March 22, 2017 13:34
Parse a .env (dotenv) file directly using BASH
# Pass the env-vars to MYCOMMAND
eval $(egrep -v '^#' .env | xargs) MYCOMMAND
# … or ...
# Export the vars in .env into your shell:
export $(egrep -v '^#' .env | xargs)
@algal
algal / ScaleAspectFitImageView.swift
Last active September 24, 2023 10:19
UIImageView subclass that works with Auto Layout to express its desired aspect ratio
import UIKit
// known-good: Xcode 8.2.1
/**
UIImageView subclass which works with Auto Layout to try
to maintain the same aspect ratio as the image it displays.
This is unlike the usual behavior of UIImageView, where the
@JaseHadd
JaseHadd / ioslocaleidentifiers.csv
Last active March 31, 2022 08:23 — forked from jacobbubu/ioslocaleidentifiers.csv
iOS Locale Identifiers
localeIdentifier Description
eu Basque
hr_BA Croatian (Bosnia & Herzegovina)
en_CM English (Cameroon)
rw_RW Kinyarwanda (Rwanda)
en_SZ English (Swaziland)
tk_Latn Turkmen (Latin)
he_IL Hebrew (Israel)
ar Arabic
uz_Arab Uzbek (Arabic)
struct Regex {
let pattern: String
let options: NSRegularExpressionOptions
private var matcher: NSRegularExpression {
return try! NSRegularExpression(pattern: pattern, options: options)
}
init(pattern: String, options: NSRegularExpressionOptions! = nil)
{