Skip to content

Instantly share code, notes, and snippets.

@a-shevtsov
a-shevtsov / .bash_profile
Last active September 24, 2020 20:54
Bash profile for Mac OS X
#!/usr/bin/env bash
# Start SSH agent
SSH_ENV="$HOME/.ssh/environment"
function start_agent {
echo "Initialising new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
@a-shevtsov
a-shevtsov / examine-pvc.sh
Created July 2, 2019 20:54
Start pod with mounted PVC
kubectl run -i --rm --tty busybox --overrides='
{
"kind": "Pod",
"apiVersion": "v1",
"spec": {
"containers": [
{
"name": "busybox",
"image": "busybox",
"args": [
@a-shevtsov
a-shevtsov / bash-arg-parsing.sh
Created April 15, 2019 19:36
Bash argument parsing with 'set -euo pipefail'
#!/usr/bin/env bash
# https://web.archive.org/web/20190329060125/https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
set -euo pipefail
# Set default values for mandatory arguments
CLONE_URL=''
BRANCH_NAME=''
print_help() {
@a-shevtsov
a-shevtsov / jmeter-preprocessor-aws-sigv4.jmx
Created March 19, 2019 00:19
Signing requests with AWS Sigv4 in JMeter
/**
* This example has been tested against API Gateway
* The following HTTP Headers must be set (in HTTP Header Manager)
* Host: <hostname>
* Content-Type: application/json
* x-amz-date: ${amzDate}
* Authorization: ${amzAuth}
*/
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
@a-shevtsov
a-shevtsov / Jenkinsfile
Created October 6, 2018 01:08
Running Docker container in Jenkins scripted pipeline
node {
// First parameter represents additional docker run options, second parameter is arguments passed to the image
// docker run [OPTIONS|<First parameter>] IMAGE [COMMAND] [ARG...|<Second parameter>]
docker.image('mesosphere/aws-cli').withRun('--entrypoint /bin/sh', '') {
stage('Build') {
sh 'aws --version'
}
}
}
@a-shevtsov
a-shevtsov / start_jenkins.sh
Last active October 6, 2018 00:27
Dockerized Jenkins with Docker
#!/usr/bin/env bash
JENKINS_VERSION=2.89.4
JENKINS_HOME_VOLUME=jenkins_home
docker run -d --rm \
--name jenkins \
-p 8080:8080 \
-p 50000:50000 \
-v ${JENKINS_HOME_VOLUME}:/var/jenkins_home \
@a-shevtsov
a-shevtsov / .bashrc
Last active August 2, 2018 17:15
.bashrc
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
# Set alias for nvim
@a-shevtsov
a-shevtsov / .bash_profile
Last active August 15, 2018 18:50
My Bash profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
export PATH=$PATH:$HOME/.local/bin:$HOME/bin
@a-shevtsov
a-shevtsov / centos-rhel-7-ws-setup.sh
Last active September 9, 2020 19:30
CentOS/RHEL 7 workstation set up
# Create .ssh directory and authorized_keys file
mkdir -m 700 ~/.ssh
touch ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
# Set/restore SELinux permissions on the authorized_keys file
sudo /sbin/restorecon -v ~/.ssh/authorized_keys
# Append the public key
@a-shevtsov
a-shevtsov / .tmux.conf
Last active August 1, 2018 22:53
My tmux config (compatible with Tmux v2.3+)
# remap prefix to Control + a
set -g prefix C-a
# bind 'C-a C-a' to type 'C-a'
bind C-a send-prefix
unbind C-b
# Allow to scroll and resize panes with mouse
set -g mouse on