Skip to content

Instantly share code, notes, and snippets.

Avatar
🐧

Jiri Tyr jtyr

🐧
View GitHub Profile
@jtyr
jtyr / ghwait
Last active March 11, 2022 14:35
GitHub PR waiting
View ghwait
#!/bin/bash
# Usage: gh pr create -f && ghwait && gh pr merge -sd
function msg() {
TYPE="$1"
TEXT="$2"
EXIT="$3"
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $TYPE: $TEXT"
@jtyr
jtyr / README.md
Last active December 4, 2022 11:43
Capture keyboard and mouse events on Linux
View README.md

Instructions how to capture keyboard and mouse events and turn them into human readable output.

  1. Run evtest without any argments and see which event device you need to use.
  2. Run the following command for the keyboard events:
evtest /dev/input/event5 | grep --line-buffered 'EV_KEY' | sed -r -e 's/.*\(KEY_/Keyboard: /' -e 's/\), value 0/ - UP/' -e 's/\), value 1/ - DOWN/' -e 's/\), value 2/ - HOLD/'

Example of the output:

Keyboard: Z - DOWN
@jtyr
jtyr / facts.sh
Last active January 28, 2020 23:38
Shell script for gathering facts from Unix systems.
View facts.sh
#!/bin/sh
# Get the total memory in kB
if [ -f /bin/esxcli ]; then
MEM=$(esxcli hardware memory get | grep Physical | awk '{printf("%d", $3/1000)}')
elif [ -f /proc/meminfo ]; then
MEM=$( (grep MemTotal /proc/meminfo 2>/dev/null || echo 'x unknown') | awk '{print $2}')
else
MEM='unknown'
fi
@jtyr
jtyr / vcenter_dump.py
Last active March 16, 2022 20:53
Get information about all VMs from vCenter
View vcenter_dump.py
#!/usr/bin/env python
import argparse
import atexit
import getpass
import logging
import os
import re
import socket
import sys
@jtyr
jtyr / phpipam.py
Last active December 20, 2019 16:23
Script that allows to search, add or remove hostnames in phpIPAM.
View phpipam.py
#!/usr/bin/env python
import argparse
import logging
import requests
import sys
# Disable SSL warnings
try:
from requests.packages.urllib3.exceptions import InsecureRequestWarning
@jtyr
jtyr / resolv_conf.sh
Last active October 3, 2019 13:56
Script which helps to configure resolv.conf based on information pushed by the OpenVPN server.
View resolv_conf.sh
#!/bin/bash
###
#
# Description
# -----------
#
# Script which helps to configure resolv.conf based on information pushed by
# the OpenVPN server.
#
@jtyr
jtyr / json2ini.py
Last active January 22, 2019 11:04
Scripts that converts the output of an Ansible dynamic inventory script into a static INI inventory.
View json2ini.py
#!/bin/env python
import json
import sys
'''
Description
-----------
@jtyr
jtyr / play-with-k8s.com-jtyr-setup.sh
Last active June 2, 2019 22:43
Shell script used to bootstrap Kubernetes on the play-with-k8s.com service
View play-with-k8s.com-jtyr-setup.sh
###
# Shell script used to bootstrap Kubernetes on the play-with-k8s.com service
###
#
# Inspired by https://gist.github.com/jjo/78f60702fbfa1cbec7dd865f67a3728a
#
# Usage:
# source <(curl -sL bit.do/jtyr-pwk-setup)
#
# Edit:
@jtyr
jtyr / zabbix_agent_query.txt
Last active August 28, 2018 22:58
Query Zabbix Agent metric via netcat.
View zabbix_agent_query.txt
# Ask Zabbix Agent to return value of the system.cpu.load metric
echo 'system.cpu.load' | nc -w2 myserver01 10050 | sed -r 's/^ZBXD..//'
@jtyr
jtyr / zshrc
Last active January 9, 2023 20:17
ZSH configuration for GBT
View zshrc
###[ ZSH ]
# History
HISTFILE=~/.zsh_history
HISTSIZE=10000
SAVEHIST=10000
setopt append_history
setopt extended_history
setopt hist_expire_dups_first
setopt hist_ignore_dups