Skip to content

Instantly share code, notes, and snippets.

View SamyCoenen's full-sized avatar

Samy Coenen SamyCoenen

View GitHub Profile
@SamyCoenen
SamyCoenen / git_change_author.sh
Last active March 29, 2018 19:55
Change the git author in all the commits with a certain filter
# Author: Samy Coenen
# Company: Gluo NV
git filter-branch --commit-filter 'if [ "$GIT_AUTHOR_NAME" = "old_author" ];
then export GIT_AUTHOR_NAME="New Name"; export GIT_AUTHOR_EMAIL=new_email@example.com;
fi; git commit-tree "$@"'
@SamyCoenen
SamyCoenen / trigger_pipeline.p
Created March 27, 2018 11:03
Trigger Gitlab pipeline if it's not already running
import requests
from subprocess import call
params = (('status', 'running'),)
params2 = (('status', 'pending'),)
headers = {'PRIVATE-TOKEN': '$TOKEN'}
url = 'https://gitlab.com/api/v4/projects/......................./pipelines'
r = requests.get(url, params=params,headers=headers)
print r.text
r2 = requests.get(url, params=params2,headers=headers)
print r2.text
@SamyCoenen
SamyCoenen / yaml_check_tags.py
Created March 27, 2018 10:59
YAML begin- and endtag checker, written in Python
#!/usr/bin/env python3
# Author: Samy Coenen
# Company: Gluo NV
import os
from argparse import ArgumentParser
import glob
import checkyaml
def get_args():
parser = ArgumentParser(description='Arguments')
@SamyCoenen
SamyCoenen / upload_json_elasticsearch.sh
Created March 27, 2018 10:57
Upload json files to elasticsearch
#!/bin/bash
# Author: Samy Coenen
# Company: Gluo NV
list="$(find . -type f)"
for i in list
do
curl -XPOST 'https://......................eu-central-1.es.amazonaws.com/_bulk' -d @$i
done
@SamyCoenen
SamyCoenen / checkyaml.py
Created March 27, 2018 10:55
YAML syntax checker written in Python
#!/usr/bin/env python3
# Author: Samy Coenen
# Company: Gluo NV
import yaml
import sys
import os, glob
from argparse import ArgumentParser
def get_args():
@SamyCoenen
SamyCoenen / backup_kibana.sh
Last active March 26, 2018 21:42
Make a backup of your Kibana4 dashboard
#!/bin/bash
# Author: Samy Coenen
# Company: Gluo NV
elasticdump \
--input=https://....................eu-central-1.es.amazonaws.com/.kibana-4 \
--output=$ \
--type=data \
--searchBody='{"filter": { "or": [ {"type": {"value": "dashboard"}}, {"type" : {"value":"visualization"}}] }}' \
> kibana-exported.json
@SamyCoenen
SamyCoenen / backup_entire_elasticsearch.sh
Created March 26, 2018 21:40
Make a backup of all you indices on ElasticSearch with this Bash Script
#!/bin/bash
# Author: Samy Coenen
# Company: Gluo NV
SOURCE=https://............es.amazonaws.com
indice_list="$(curl -XGET $SOURCE/_cat/indices?pretty=true -v | cut -d $' ' -f3)"
for item in $indice_list
do
elasticdump \
--input=$SOURCE/$item \
--output=$ \
@SamyCoenen
SamyCoenen / gist:11067126071248c7e41756e6a9fb2931
Last active February 2, 2017 12:29
Linux disk read write benchmark
# show disks
lsblk
# Read Test
sudo hdparm -Tt /dev/sdb
# Write Test
dd if=/dev/zero of=/tmp/output conv=fdatasync bs=384k count=1k; rm -f /tmp/output
# Gui Benchmark
gnome-disks
# select disk and do benchmark
@SamyCoenen
SamyCoenen / gist:33c9b61c7774b1caabf466b73be3cab6
Created January 26, 2017 09:18
Certificate expand with let's encypt and reverse proxy
#!/bin/bash
# maak een kopie van de huidige instellingen en certificaten
mv /home/student/backup/letsencrypt /home/student/backup/letsencrypt.old2
# zet de reverse_proxy_nginx uit, deze luisterd al reeds op poort 80, letsencrypt heeft deze poort nodig voor certificaten aan te vragen.
cd /home/student && docker-compose down
# Nu vragen we nieuwe certificaten aan. Deze komen op de locatie van /etc/letsencrypt
letsencrypt certonly --standalone -d vikingco.me -d www.vikingco.me -d kanban.vikingco.me -d jenkins.vikingco.me -d gitlab.vikingco.me -d api.vikingco.me -d test.vikingco.me -d testapi.vikingco.me -d php.vikingco.me -d testphp.vikingco.me
@SamyCoenen
SamyCoenen / gist:c002d549a3053b2055afa9168fd735a4
Last active January 20, 2017 21:39
Connection with VM in a nested ESXI 6 from Workstation 12 Linux
sudo su
# make interface available to everyone
chmod a+rw /dev/vmnet2
# put interface in promiscuous mode
ifconfig vmnet2 promisc