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 / 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('.')
@turboBasic
turboBasic / groovySplitVsTokenize.groovy
Last active November 28, 2020 07:55
Groovy String split() vs tokenize() #groovy
final List TestCases = [
'/usr/bin/sh',
'//usr/bin/sh',
'usr//bin/sh',
'usr//bin//sh///',
'//',
'/',
' / ',
' // ',
' ',
@turboBasic
turboBasic / expand-variables-in-file.md
Last active November 28, 2020 03:53
Expand variables in text read from file #bash

Expand variables in text read from file

$ printf '%s\n' 'Hi, $name! Today is $day...' > something.txt

$ name=Andriy day=Friday  . <(echo -e echo $( < something.txt ))

Hi, Andriy! Today is Friday...
@turboBasic
turboBasic / BaseObjectDescription.groovy
Last active November 7, 2021 17:06
Use static factory to dynamically change behavior of interface #groovy #design-pattern
package xyz.bebee.example.groovy
/**
* Implements bare minimum description of object
*/
class BaseObjectDescription implements ObjectDescription {
final def object
BaseObjectDescription(def object) {
@turboBasic
turboBasic / ignore_moves.py
Last active October 27, 2020 18:14
Show diff and ignore line moves #git #diff
#!/usr/bin/python
import sys
from itertools import *
RED = 31
GREEN = 32
RESET_SEQ = "\033[0m"
COLOR_SEQ = "\033[0;%dm"