Skip to content

Instantly share code, notes, and snippets.

View turboBasic's full-sized avatar
🔮
Focusing

andriy melnyk turboBasic

🔮
Focusing
View GitHub Profile
@turboBasic
turboBasic / convertSshFingerprint.md
Last active January 24, 2021 09:40
Convert OpenSSH public key fingerprints to different formats #ssh #openssh

Convert SHA256 OpenSSH digests to other representations

➜  ssh-add -l
256 SHA256:DpDdSJhFYZAa1jz4cE9PMAevia1C/yb4Gi5nW7dMqmw i@example.com (ED25519)
@turboBasic
turboBasic / getLocaleDiff.sh
Last active January 21, 2021 14:19
Get detailed difference between two locales #locale #linux
#!/usr/bin/env bash
locale1=${1:-uk_UA.UTF-8}
locale2=${2:-ru_UA.UTF-8}
shopt -s nocasematch
if [[ $locale1 != POSIX ]] \
&& [[ ! $locale1 =~ ' '$ ]] \
&& [[ ! $locale1 =~ @.+$ ]] \
@turboBasic
turboBasic / new-github-repo.sh
Last active January 4, 2021 13:38
create Github repo from command line using Github REST API with correct escaping #shell #git #github
#!/bin/sh
# Create repository in Github with correct escaping in repo name
# Requires {@code GITHUB_TOKEN} env var.
# @return ssh url to created repository which can be used in git clone command
jq --null-input --compact-output \
--arg repo 'my-awesome-project' \
'{name: $repo}' \
| curl \
@turboBasic
turboBasic / Add-multiple-exit-traps-to-bash.md
Last active December 17, 2020 17:16
Add multiple exit traps to Bash program #bash

Add multiple exit traps to Bash program

extract_trap_cmd() { printf '%s\n' "${3-}"; }
get_exit_trap_cmd() {
    eval "extract_trap_cmd $(trap -p EXIT)"
}
@turboBasic
turboBasic / localeSettingsForUbuntu.md
Last active December 14, 2020 04:02
Locale Settings For Ubuntu #locale #linux

Set locale in Ubuntu

Locale settings

cat <<-EOF  >/etc/default/locale
@turboBasic
turboBasic / jenkinsDependencies.md
Last active December 12, 2020 02:43
Jenkins core and plugin dependencies #jenkins

ace-editor (1.1) => [ bouncycastle-api (2.16.0) optional, command-launcher (1.0) optional, jdk-tool (1.0) optional, trilead-api (1.0.4) optional ]

analysis-core (1.96) => [ maven-plugin (2.17), antisamy-markup-formatter (1.5),

@turboBasic
turboBasic / convertPamToShell.sh
Last active February 12, 2021 18:00
Convert .pam_environment file to shell statements #shell #bash
#!/usr/bin/env bash
# shellcheck disable=SC1090,SC1110,SC2086
if [ -z "$BASH_VERSION" ]; then
echo This file should be executed or sourced by Bash shell
exit 2
fi
perl -pe 's/\\\n/ /' ~/.pam_environment \
| sed --regexp-extended $'
@turboBasic
turboBasic / generate-passphrase.sh
Last active November 30, 2020 11:48
Generate passphrase from N random words
#!/bin/sh
/usr/bin/shuf --head-count "${1:-5}" /usr/share/dict/words \
| awk '{printf "%s ", $0} END{print}'
@turboBasic
turboBasic / IndentWriter.groovy
Last active November 28, 2020 17:52
Pretty print maps and objects in #groovy
import java.io.PrintWriter;
import java.io.Writer;
import org.codehaus.groovy.tools.Utilities;
public class IndentWriter extends PrintWriter
{
protected boolean needIndent = true;
protected String indentString;
protected int indentLevel = 0;
@turboBasic
turboBasic / SemVer.groovy
Created November 28, 2020 13:07 — forked from michaellihs/SemVer.groovy
Semantic Versioning class for Groovy #groovy
enum PatchLevel {
MAJOR, MINOR, PATCH
}
class SemVer implements Serializable {
private int major, minor, patch
SemVer(String version) {
def versionParts = version.tokenize('.')