Skip to content

Instantly share code, notes, and snippets.

@Nimamoh
Nimamoh / fish.fish
Created Oct 20, 2021
Launch fish if parent process is not fish
View fish.fish
# This launches fish if parent process is not fish. Not used anymore
if [[ $(ps --no-header --pid=$PPID --format=cmd) != "fish" ]]; then
exec fish
fi
View gist:3d00d92a30810d562c1a21666768f979
from typing import Iterable, Iterator, Sequence
def range_gen(n=10):
"""Range implemented as generator"""
# It is used like an iterator,
# each time next() is called on this generator,
# code is resumed from yield clause.
# This allows for lazy computed iterators.
i = 0
@Nimamoh
Nimamoh / win-gpg-agent-relay.sh
Last active Aug 31, 2022
win-gpg-agent-relay
View win-gpg-agent-relay.sh
#!/usr/bin/env bash
GNUPGHOME="$HOME/.gnupg"
PIDFILE="$GNUPGHOME/win-gpg-agent-relay.pid"
LOGFILE="$GNUPGHOME/win-gpg-agent-relay.log"
is_pid_running() {
if [[ -z "$1" ]]; then
return 1
fi
@Nimamoh
Nimamoh / semver-to-docker-labels.sh
Last active Jan 7, 2021
Take a semantic version string and outputs potential docker tags
View semver-to-docker-labels.sh
#!/bin/sh
# GPL-3.0-or-later
#
# Usage: semver-to-docker-labels.sh SEMANTIC_VERSION_STRING
#
# Print possible docker labels for a semantic version string.
# For semantic version with no pre-release or build number. It will output:
#