Skip to content

Instantly share code, notes, and snippets.

@Nimamoh
Nimamoh / fish.fish
Created October 20, 2021 15:42
Launch fish if parent process is not 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
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 August 31, 2022 06:34
win-gpg-agent-relay
#!/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 January 7, 2021 17:52
Take a semantic version string and outputs potential docker tags
#!/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:
#