Skip to content

Instantly share code, notes, and snippets.

View OleksandrKucherenko's full-sized avatar

Oleksandr OleksandrKucherenko

View GitHub Profile
@OleksandrKucherenko
OleksandrKucherenko / version-up.sh
Last active May 2, 2024 13:04
Calculate Next Suitable Version Tag for Your Git based project
#!/usr/bin/env bash
# shellcheck disable=SC2155
## Copyright (C) 2017, Oleksandr Kucherenko
## Last revisit: 2023-09-30
## Version: 2.0.2
## License: MIT
## Fix: 2023-10-01, prefix for initial INIT_VERSION was not applied
## Fix: 2023-10-01, correct extraction of latest tag that match version pattern
## Added: 2023-09-30, @mrares prefix modification implemented
@OleksandrKucherenko
OleksandrKucherenko / configureMyMac.sh
Last active April 22, 2024 07:49
Pre-configure My mac
#!/usr/bin/env bash
set -x # uncomment to debug
# required for Homebrew
xcode-select —-install
sudo xcodebuild -license accept
# install https://brew.sh/
which brew || (/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" )
@OleksandrKucherenko
OleksandrKucherenko / settings.json
Created April 18, 2024 09:47
VsCode ToDo Tree Configuration for Unit Tests highlighting
{
// ... trimmed ...
"todo-tree.general.tags": [
"BUG",
"HACK",
"FIXME",
"TODO",
"XXX",
"[ ]",
"[x]",
@OleksandrKucherenko
OleksandrKucherenko / dumpviewshierarchy.java
Created February 1, 2018 08:18
Dump Android View hierarchy (very good for unit tests)
package your.name;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Build;
import android.os.Bundle;
@OleksandrKucherenko
OleksandrKucherenko / dependencies.sh
Created August 30, 2022 09:51
MACOSX Script contains helper functions that allows verification of script dependencies. Is required tool installed on the laptop? Is the tool version is right? What developer should do to fix the dependency?
#!/usr/bin/env bash
# shellcheck disable=SC2034
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck disable=SC1090 source=commons.sh
source "$SCRIPT_DIR/commons.sh"
logger dependencies "$@" # register own debug tag & logger functions
#set -x # Uncomment to DEBUG
@OleksandrKucherenko
OleksandrKucherenko / directory-autocomplete-prompts.ts
Created June 2, 2023 06:57
Prompts NPM, ask for current working directory with autocomplete/autosuggestions with use of globs
import { glob } from 'glob'
import fs from 'node:fs'
const cwd = {
message: `Current working directory (ex. ~/project, ../project, ./project):`,
type: `autocomplete`,
limit: 10,
choices: [
/* force prompts to render 10 lines */
{ title: `Current working directory`, value: process.cwd() },
@OleksandrKucherenko
OleksandrKucherenko / logger.sh
Created August 17, 2022 08:06
BASH logger that listen to DEBUG environment variable
#!/usr/bin/env bash
# shellcheck disable=SC2155,SC2034,SC2059
# get script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
#
# Register debug logger functions that are controlled by DEBUG= environment variable
# Examples:
# DEBUG=* - print all logs
@OleksandrKucherenko
OleksandrKucherenko / dependencies.sh
Created August 17, 2022 08:13
How to verify BASH script dependencies
#!/usr/bin/env bash
# shellcheck disable=SC2034
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck disable=SC1090 source=commons.sh
source "$SCRIPT_DIR/commons.sh"
logger dependencies "$@" # register own debug tag & logger functions
#set -x # Uncomment to DEBUG
@OleksandrKucherenko
OleksandrKucherenko / commons.sh
Created August 30, 2022 09:56
MACOSX helper functions for writing user friendly scripts. Contains: logger, execution time tracking, user input validation, inject of secrets, flags as script arguments detection;
#!/usr/bin/env bash
# shellcheck disable=SC2155,SC2034,SC2059
# get script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# is allowed to use macOS extensions (script can be executed in *nix environment)
use_macos_extensions=false
if [[ "$OSTYPE" == "darwin"* ]]; then use_macos_extensions=true; fi
@OleksandrKucherenko
OleksandrKucherenko / _commons.sh
Created September 12, 2023 12:49
Parse BASH script input arguments in a simplest way
#!/usr/bin/env bash
# shellcheck disable=SC2155,SC2034,SC2059
# get script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# is allowed to use macOS extensions (script can be executed in *nix environment)
use_macos_extensions=false
if [[ "$OSTYPE" == "darwin"* ]]; then use_macos_extensions=true; fi