Skip to content

Instantly share code, notes, and snippets.

Avatar

Jiri Tyr jtyr

View GitHub Profile
@jtyr
jtyr / README.md
Last active May 12, 2020
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 Jan 28, 2020
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 May 9, 2020
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 Dec 20, 2019
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 Oct 3, 2019
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 Jan 22, 2019
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 Jun 2, 2019
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 Aug 28, 2018
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 Jun 23, 2020
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
@jtyr
jtyr / GitAliases.txt
Last active Aug 4, 2020
Useful Git aliases
View GitAliases.txt
git config --global alias.workprofile 'config user.email jiri.tyr@client.domain'
git config --global alias.tagv '!git show-ref --tags | sort -V -k2'
git config --global alias.last 'rev-parse HEAD'
git config --global alias.ltag "\!git tag | sort -V | tail -n1 | egrep '^.+\$'"
git config --global alias.ltagv '!git show-ref --tags | sort -V -k2 | tail -n1'
git config --global alias.itag "\!(git ltag || echo 0.0.0) | awk '{split(substr(\$0, 2), a, \".\"); printf \"v%d.%d.%d\", a[1]+1, 0, 0}'"
git config --global alias.iitag "\!(git ltag || echo 0.0.0) | awk '{split(substr(\$0, 2), a, \".\"); printf \"v%d.%d.%d\", a[1], a[2]+1, 0}'"
git config --global alias.iiitag "\!(git ltag || echo 0.0.0) | awk '{split(substr(\$0, 2), a, \".\"); printf \"v%d.%d.%d\", a[1], a[2], a[3]+1}'"
git config --global alias.aitag '!git tag $(git itag)'
git config --global alias.aiitag '!git tag $(git iitag)'
You can’t perform that action at this time.