Skip to content

Instantly share code, notes, and snippets.

View orihomie's full-sized avatar
:octocat:

Orkhan orihomie

:octocat:
View GitHub Profile
#!/usr/bin/env bash
JENKINS_URL="https://user:token@jenkins.domain" #"http://<jenkins-server>"
JENKINS_URI="/job/full/path" #"my-job"
# Trigger the job with parameters
RESPONSE_FILE=/tmp/$(uuidgen).txt
response_code=$(curl -I -X POST -so "$RESPONSE_FILE" -w "%{http_code}" "${JENKINS_URL}${JENKINS_URI}/build")
if [[ "$response_code" != "201" ]]; then
#!/usr/bin/env bash
gitlab_pipeline_job_name=$1
image_name=gitlab/gitlab-runner:latest
running_image=$(docker ps --format "{{.Image}}")
if [[ "${running_image}" != "${image_name}" ]]; then
docker run -d \
--name gitlab-runner \
@orihomie
orihomie / launch_gitlab_runner_docker_executor.sh
Last active March 12, 2024 09:45
This is how you register gitlab runner to run in docker
#!/usr/bin/env bash
token=$1
url=$2
name=$3
docker_image_version="docker:dind"
tags=$4
docker_user="root"
docker run --rm -it -v /data/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register \
@orihomie
orihomie / filebeat.yml
Created September 12, 2022 05:22
Filebeat json message parsing sample
filebeat.inputs:
- type: docker
combine_partial: true
tags: ["my-tag-docker"]
containers:
path: "/var/lib/docker/containers"
ids:
- "*"
@orihomie
orihomie / inspect-docker-networks.sh
Created August 31, 2022 11:02
Inspect docker networks
#!/usr/bin/env bash
networks=($(docker network ls | awk '{print $1}' | tail -n+2))
delta=1
arraylength=${#networks[@]}
for (( i=0; i<${arraylength}; i=$((i+$delta)) ));
do
docker network inspect --format='{{.Name}} {{.IPAM.Config}}' ${networks[i]};
#docker network inspect ${networks[i]} | grep Subnet
@orihomie
orihomie / check_domains.sh
Created August 31, 2022 09:28
Simple domain check
#!/usr/bin/env bash
domains=($(cat $1 | awk '{print $1}'))
delta=1
arraylength=${#domains[@]}
for (( i=0; i<${arraylength}; i=$((i+$delta)) ));
do
host "${domains[i]}"
echo "${domains[i]} checked"
@orihomie
orihomie / logsample.md
Last active August 23, 2022 06:56
haproxy json logging sample

Documentation is here

log-format '{"host":"%H","ident":"haproxy","pid":%pid,"time":"%Tl","internal":{"conn":{"act":%ac,"fe":%fc,"be":%bc,"srv":%sc},"queue":{"backend":%bq,"srv":%sq},"time":{"tq":%Tq,"tw":%Tw,"tc":%Tc,"tr":%Tr,"tt":%Tt},"termination_state":"%tsc","retries":%rc,"network":{"client_ip":"%ci","client_port":%cp,"frontend_ip":"%fi","frontend_port":%fp},"ssl":{"version":"%sslv","ciphers":"%sslc"},"request":{"method":"%HM","hu":"%HU","hp":"%HP","hq":"%HQ","protocol":"%HV","header":{"host":"%[capture.req.hdr(0),json(utf8s)]","xforwardfor":"%[capture.req.hdr(1),json(utf8s)]","referer":"%[capture.req.hdr(2),json(utf8s)]","user_agent":"%[capture.req.hdr(3),json(utf8s)]"}},"name":{"backend":"%b","frontend":"%ft","server":"%s"},"response":{"status_code":%ST,"header":{"xrequestid":"%[capture.res.hdr(0),json(utf8s)]"}},"bytes":{"uploaded":%U,"read":%B}}}'

keep in mind that [caputre.*.hdr(i)] variables working only if you explic

@orihomie
orihomie / remove-s3-backend.sh
Created June 11, 2022 09:44
Removes terraform s3 backend along with user and DynamoDB
BUCKET_NAME=terraform-your_company_name-remote-store
BUCKET_REGION=eu-central-1
USER_NAME=terraform-deployer
AWS_PROFILE=your_company_name
aws s3api delete-bucket \
--profile $AWS_PROFILE \
--bucket $BUCKET_NAME \
--region $BUCKET_REGION
@orihomie
orihomie / init-s3-backend.sh
Last active April 8, 2024 23:25
Create s3 backend along with user and Dynamo DB
BUCKET_NAME=terraform-your_company-remote-store # this should be unique, and by that I mean really UNIQUE
BUCKET_REGION=eu-central-1
USER_NAME=terraform-deployer
POLICY_FILE_NAME=$PWD/policy.json
AWS_PROFILE=your_company
aws s3api create-bucket \
--profile $AWS_PROFILE \
--bucket $BUCKET_NAME \
--region $BUCKET_REGION \
@orihomie
orihomie / bench.ts
Last active May 21, 2022 03:28
Comparing bluebird to a custom promise processing
const Bluebird = require('bluebird')
async function delay(ms) {
await new Promise(resolve => setTimeout(resolve, ms))
}
async function saveToDB(fromWhere, value) {
const saveStartedAt = Date.now()
if (value % 5 === 0) {
await delay(2000)