Skip to content

Instantly share code, notes, and snippets.

@anton-yurchenko
anton-yurchenko / jenkins-create-token.groovy
Created October 30, 2022 10:27
Jenkins Console Groovy Script to Generate New User Token
// Source: https://docs.cloudbees.com/docs/cloudbees-ci-kb/latest/client-and-managed-masters/how-to-generate-change-an-apitoken
import hudson.model.*
import jenkins.model.*
import jenkins.security.*
import jenkins.security.apitoken.*
// script parameters
def userName = 'admin'
def tokenName = 'token'
@anton-yurchenko
anton-yurchenko / golang-generic-struct.md
Created April 16, 2022 08:14
GoLang Generic Struct

The following snippet contains an example for GoLang Generics for Structs:

package main

import "fmt"

// Structs definition
type ObjectOne struct {
	Name string      `json:"name"`
@anton-yurchenko
anton-yurchenko / curl-performance.md
Created March 21, 2022 21:01
Simple perfomance testing using curl
  1. Create a format.txt file with the following content:
time_namelookup:      %{time_namelookup}s\n 
time_connect:         %{time_connect}s\n
time_appconnect:      %{time_appconnect}s\n 
time_pretransfer:     %{time_pretransfer}s\n
time_redirect:        %{time_redirect}s\n 
time_starttransfer:   %{time_starttransfer}s\n
 ----------\n 
@anton-yurchenko
anton-yurchenko / mirror_bitbucket_repos.py
Created February 26, 2022 11:00
Mirror BitBucket Repositories
#!/usr/bin/python
import os
import stashy
projects = [
"PROJ-1",
"PROJ-2",
"PROJ-3",
]
@anton-yurchenko
anton-yurchenko / github_string_search.py
Last active April 28, 2023 16:19
String search on GitHub organization
from requests import get
from sys import argv, exit
from os import environ
from requests.models import HTTPBasicAuth
def main():
if len(argv) < 3:
print('invalid input, expected arguments: `python3.9 script.py <account-name> <search-string>`')
exit(1)
@anton-yurchenko
anton-yurchenko / aws-org-cloudtrail.md
Last active April 16, 2022 08:17
Query AWS Organization CloudTrail Logs Using Athena

Notice: if you want to query logs for multiple days (week or so), you might need to transform them to pargquet first

Table Creation DDL:

CREATE EXTERNAL TABLE cloudtrail_logs(
    eventVersion STRING,
    userIdentity STRUCT<
        type: STRING,
        principalId: STRING,
@anton-yurchenko
anton-yurchenko / jenkins-print-credentials.groovy
Created July 19, 2021 11:16
Jenkins Console Groovy Script to Print Credentials username/password
import jenkins.*
import jenkins.model.*
import hudson.*
import hudson.model.*
def jenkinsCredentials = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
com.cloudbees.plugins.credentials.Credentials.class,
Jenkins.instance,
null,
null
@anton-yurchenko
anton-yurchenko / list-active-github-repositories.md
Last active April 16, 2022 08:30
List Active Repositories with GitHub Actions Flows

This script will list all active repositories in an organization with GitHub Actions workflows.

  1. Generate Access Token with repo scope and replace <TOKEN>
  2. Replace <ORGANIZATION> with your organizaiton name
  3. Save to file and run the script
#!/bin/sh

token="<TOKEN>"
@anton-yurchenko
anton-yurchenko / mirror_repositories_to_github.sh
Last active December 12, 2021 03:40
Mirror repositories to GitHub
#!/usr/bin/env bash
CYAN='\033[0;36m'
RED='\033[0;31m'
NOCOLOR='\033[0m'
function log {
echo -e "${CYAN}INFO${NOCOLOR} $*"
}
function logerror {