Skip to content

Instantly share code, notes, and snippets.

View OleksandrKucherenko's full-sized avatar

Oleksandr OleksandrKucherenko

View GitHub Profile
@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 / sample-of-use.sh
Created August 17, 2022 08:29
Sample script that demonstrate usage of the Logger feature.
#!/usr/bin/env bash
#set -x # Uncomment to DEBUG
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/logger.sh"
logger token "$@" # controlled by DEBUG=token,*
logger refresh "$@" # controlled by DEBUG=refresh,*
# terminal colors and utility functions, like: cl_grey, cl_reset
@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 / 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 / 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 / git-cheats.sh
Last active March 27, 2023 09:37
GIT useful commands
#!/bin/bash
# Get root folder path of the project under git
# Output: /Users/oleksandr.kucherenko/projects/klarna-app
git rev-parse --show-toplevel
# Get latest commit hash
# Output: 1b03718dabad03aaef917eff3ea8bb15e4fa1c46
git rev-parse @
@Test
@Config(sdk = Build.VERSION_CODES.P)
public void testFingerprintConfigured_api28() throws Exception {
// GIVEN:
// API28 android version
// for api24+ system feature should be enabled
// fingerprints are configured
ReactApplicationContext context = getRNContext();
shadowOf(context.getPackageManager()).setSystemFeature(PackageManager.FEATURE_FINGERPRINT, true);
@Test
@Config(sdk = Build.VERSION_CODES.M)
public void testFingerprintConfigured_api23() throws Exception {
// GIVEN:
// API23 android version
// Fingerprints are configured
// fingerprint feature is ignored by android os
ReactApplicationContext context = getRNContext();
@Test
@Config(sdk = Build.VERSION_CODES.M)
public void testFingerprintAvailableButNotConfigured_api23() throws Exception {
// GIVEN:
// fingerprint api available but not configured properly
// API23 android version
ReactApplicationContext context = getRNContext();
KeychainModule module = new KeychainModule(context);
// set that hardware is available
@Test
@Config(sdk = Build.VERSION_CODES.LOLLIPOP)
public void testFingerprintNoHardware_api21() throws Exception {
// GIVEN: API21 android version
ReactApplicationContext context = getRNContext();
KeychainModule module = new KeychainModule(context);
// WHEN: verify availability
final int result = BiometricManager.from(context).canAuthenticate();
final boolean isFingerprintAvailable = module.isFingerprintAuthAvailable();