Skip to content

Instantly share code, notes, and snippets.

Avatar

Jean-Pierre van Riel JPvRiel

  • South Africa, Johannesburg
View GitHub Profile
@artizirk
artizirk / gnupg_scdaemon.md
Last active August 21, 2023 16:22
OpenPGP SSH access with Yubikey and GnuPG
View gnupg_scdaemon.md

OpenPGP SSH access with Yubikey and GnuPG

Yubikey, Smart Cards, OpenSC and GnuPG are pain in the ass to get working. Those snippets here sould help alleviate pain.

Notes written here should work on

  • Ubuntu 20.04 with Gnome
  • Debian 11 with Gnome
  • Linux Mint with Cinnamon (needs different environment setup, check comments)
  • Arch Linux with Gnome (pacman instead of apt)

This is not a step by step guide

@vadimkantorov
vadimkantorov / timejson.sh
Last active February 3, 2023 23:11
A Bash alias that wraps /usr/bin/time to produce parsable JSON format output.
View timejson.sh
alias timejson='/usr/bin/time -f '"'"'{"exit_code" : %x, "time_user_seconds" : %U, "time_system_seconds" : %S, "time_wall_clock_seconds" : %e, "rss_max_kbytes" : %M, "rss_avg_kbytes" : %t, "page_faults_major" : %F, "page_faults_minor" : %R, "io_inputs" : %I, "io_outputs" : %O, "context_switches_voluntary" : %w, "context_switches_involuntary" : %c, "cpu_percentage" : "%P", "signals_received" : %k}'"'"
@EdwardBetts
EdwardBetts / pprint_color.py
Last active July 11, 2023 11:08
Python pprint with color syntax highlighting for the console
View pprint_color.py
from pprint import pformat
from typing import Any
from pygments import highlight
from pygments.formatters import Terminal256Formatter
from pygments.lexers import PythonLexer
def pprint_color(obj: Any) -> None:
"""Pretty-print in color."""
@ms5
ms5 / verbos-argpary-example.py
Last active August 24, 2023 13:37
manipulating log level with python argparse
View verbos-argpary-example.py
import argparse
import logging
parser = argparse.ArgumentParser()
parser.add_argument('--verbose', '-v', action='count', default=1)
args = parser.parse_args()
args.verbose = 70 - (10*args.verbose) if args.verbose > 0 else 0
logging.basicConfig(level=args.verbose, format='%(asctime)s %(levelname)s: %(message)s',
@myusuf3
myusuf3 / delete_git_submodule.md
Created November 3, 2014 17:36
How effectively delete a git submodule.
View delete_git_submodule.md

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@endolith
endolith / gcd_and_lcm.py
Last active June 22, 2022 23:33
GCD and LCM functions in Python for several numbers
View gcd_and_lcm.py
# Greatest common divisor of 1 or more numbers.
from functools import reduce
def gcd(*numbers):
"""
Return the greatest common divisor of 1 or more integers
Examples
--------