Skip to content

Instantly share code, notes, and snippets.

View kshcherban's full-sized avatar
🏠
Working from home

Konstantin Shcherban kshcherban

🏠
Working from home
View GitHub Profile
@kshcherban
kshcherban / Dockerfile
Created April 2, 2019 22:13
jenkins casc example
FROM jenkins/jenkins:2.150.3
# Install plugins
RUN /usr/local/bin/install-plugins.sh \
git:3.9.1 \
git-client:2.7.3 \
amazon-ecs:1.19 \
job-dsl:1.69 \
configuration-as-code:1.7 \
configuration-as-code-support:1.7 \
@kshcherban
kshcherban / prometheus_remote_writer.go
Last active February 9, 2023 19:23
Write to prometheus over remote write protocol
package main
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/prompb"
"github.com/golang/snappy"
"net/http"
"log"
def consequitive_max_sum(int_list):
# last_seq = []
max_sum = sum(int_list)
for index, val in enumerate(int_list):
new_sum = sum(int_list[index:])
if new_sum > max_sum:
max_sum = new_sum
# for index, val in enumerate(int_list):
# last_sum = sum(last_seq)
# System language
lang en_US
# Language modules to install
langsupport en_US
# System keyboard
keyboard us
# System mouse
@kshcherban
kshcherban / ecs-rollback.py
Created April 12, 2017 08:44
ECS task definition rollback script
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import json
import argparse
from datetime import datetime
from subprocess import Popen, PIPE
@kshcherban
kshcherban / aws-mfa.sh
Last active September 1, 2021 20:20
Simple script to set AWS creds with MFA auth, just put it in your bashrc like `alias mfa='. ~/.local/bin/aws-mfa.sh $@'`
#!/bin/bash
#set -eo pipefail
#
# Sample for getting temp session token from AWS STS
#
# aws --profile youriamuser sts get-session-token --duration 3600 \
# --serial-number arn:aws:iam::012345678901:mfa/user --token-code 012345
#
# 1 or 2 args ok
@kshcherban
kshcherban / auto-update-terraform
Last active April 23, 2020 19:14
Bash script to auto update terraform on linux
#!/bin/bash
INSTALL_DIR="${1:-/opt/terraform}"
URL="https://releases.hashicorp.com/terraform"
VER="$(curl -sL $URL | grep -v beta | grep -Po "_(\d*\.?){3}" | sed 's/_//' | sort -V | tail -1)"
ZIP="terraform_${VER}_linux_amd64.zip"
echo "* Downloading ${URL}/${VER}/terraform_${VER}_linux_amd64.zip"
curl -s ${URL}/${VER}/terraform_${VER}_linux_amd64.zip -o ${INSTALL_DIR}/${ZIP}
root@8d3475ae6b05:/opt/Downloads/PyOxidizer# ls -lah target/debug/pyapp
-rwxr-xr-x 2 root root 86M Feb 20 07:40 target/debug/pyapp
root@8d3475ae6b05:/opt/Downloads/PyOxidizer# ldd target/debug/pyapp
linux-vdso.so.1 (0x00007ffca7ddd000)
libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f56f1ea7000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f56f1ca3000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f56f1a9b000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f56f187e000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f56f1667000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f56f12c8000)
@kshcherban
kshcherban / ec2-root-resize.sh
Created November 13, 2018 14:28
ec2 root volume resize
#!/bin/bash -e
if [ $# -ne 2 ]; then
echo "Usage: $0 <instance-id> <volume-size-gb> [PARITION_NAME=/dev/xvda2]"
exit 2
fi
INSTANCE="$1"
VOLUME_SIZE="$2"
PARTITION="${3:-/dev/xvda2}"
@kshcherban
kshcherban / asg-ecs-rolling-upgrade.py
Created July 10, 2018 07:37
Script to upgrade autoscaling group
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import boto3
from multiprocessing.dummy import Pool as ThreadPool
import sys
import time
group_name = sys.argv[1]
ag = boto3.client('autoscaling')