Skip to content

Instantly share code, notes, and snippets.

View aleskiontherun's full-sized avatar

Aleksei Vesnin aleskiontherun

View GitHub Profile
@aleskiontherun
aleskiontherun / pritunl-backup.sh
Last active February 19, 2024 15:31
Backup and restore Pritunl database.
sudo service pritunl stop
mongodump -d pritunl -o pritunl-bkp
tar -czvf pritunl-bkp.tar.gz pritunl-bkp
@aleskiontherun
aleskiontherun / _ctl.sh
Last active June 10, 2022 13:24
Pause/resume/stop process control in bash.
#!/usr/bin/env bash
TASK=$@
FAIL_CNT=0
RUN=
TASK_PID=
LOOPID=1
_ctl() {
@aleskiontherun
aleskiontherun / haproxy-ec2-register.sh
Created August 28, 2019 14:49
Register AWS EC2 instance in HAProxy.
#!/bin/bash
set -e
region=eu-central-1
haproxy_url=http://haproxy.internal:5555
haproxy_username=admin
haproxy_password=password
cluster_size=3
@aleskiontherun
aleskiontherun / bulkDeleteJobs.groovy
Last active April 6, 2020 10:10
Groovy script to delete old disabled Jenkins jobs.
/*** BEGIN META {"name" : "Bulk Delete Jobs",
"comment" : "Delete jobs disabled and where last build is older than specified param",
"parameters" : [ 'dryRun', 'numberOfDays', 'excludeRegexp' ],
"core": "2.0",
"authors" : [{ name : "Benjamin Francisoud" }, { name : "Aleksei Vesnin" }]} END META**/
import jenkins.model.*
import java.util.regex.Pattern
@aleskiontherun
aleskiontherun / ClassFinder.groovy
Last active December 23, 2019 09:59
Find groovy classes in a package and all its subpackages. Scans the package directory and subdirectories. Works when running from a jar or the filesystem.
class ClassFinder {
static List<Class> findClasses(Class clazz) {
URL srcLocation = clazz.getProtectionDomain().getCodeSource().getLocation()
String packageName = clazz.package.name
List<String> classNames
if (srcLocation.toString().endsWith('.jar')) {
String packagePath = packageName.replaceAll(/\./, '/')
classNames = loadClassNamesFromJar(srcLocation, packagePath)
} else {
File dir = new File(clazz.getResource('').toURI())
@aleskiontherun
aleskiontherun / cw2es.py
Last active July 23, 2020 08:53
Copy existing logs from CloudWatch to Elasticsearch
import json
import boto3
import gzip
import base64
import time
# AWS account ID
AWS_ACCOUNT_ID = "001234567890"
# CloudWatch log group name