Skip to content

Instantly share code, notes, and snippets.

View jtyr's full-sized avatar
🐧

Jiri Tyr jtyr

🐧
View GitHub Profile
@jtyr
jtyr / mc.md
Created January 1, 2024 22:42
MidnightCommander macros

Add several macros to format Golang code and comment/uncomment and indent/unindent code blocks.

# ~/.local/share/mc/mc.macros
[editor]
ctrl-alt-f = ExecuteScript:0
ctrl-c = ExecuteScript:1
ctrl-alt-c = ExecuteScript:2
ctrl-tab = ExecuteScript:3
@jtyr
jtyr / ghwait
Last active July 26, 2023 19:58
GitHub PR waiting
#!/usr/bin/env bash
# Exit on any error
set -o errexit -o pipefail -o noclobber -o nounset
function msg() {
TYPE="$1"
TEXT="$2"
EXIT="${3:-}"
@jtyr
jtyr / kubectl-aliases.sh
Last active October 25, 2024 18:00
kubectl aliases
# Usage: source <(curl -L https://jtyr.io/source/kubectl)
TOOLS_DIR="${TOOLS_DIR:-/tmp/tools}"
TOOLS_BIN_DIR="$TOOLS_DIR/bin"
function get_goyq() {
YQ="$TOOLS_BIN_DIR/yq"
YQ_VERSION='4.30.4'
if [[ -e $YQ ]]; then
@jtyr
jtyr / README.md
Last active December 4, 2022 11:43
Capture keyboard and mouse events on Linux

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.
#!/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
#!/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.
#!/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.
#!/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.
#!/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
###
# 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: