Skip to content

Instantly share code, notes, and snippets.

View jtyr's full-sized avatar
🐧

Jiri Tyr jtyr

🐧
View GitHub Profile
@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 / 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 / GitAliases.txt
Last active January 3, 2022 18:19
Useful Git aliases
git config --global alias.workprofile 'config user.email jiri.tyr@client.domain'
git config --global alias.tagv "\!git --no-pager tag --sort=v:refname --sort=creatordate --format='%(objectname) %(refname:strip=2)'"
git config --global alias.lv 'rev-parse HEAD'
git config --global alias.ltag "\!git tag --sort=v:refname --sort=creatordate | tail -n1"
git config --global alias.ltagv '!git tagv | 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)'
@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 / docker_image_builder.yaml
Last active September 25, 2022 15:45
Ansible Playbook to build multiple Docker images without any Dockerfile (requires Ansible v2.0)
---
### Inventory hosts file should contain this:
# test1 docker_source_image=centos:7
# test2 docker_source_image=centos:7
###
### Run the playbook like this:
# ansible-playbook -i hosts --diff ./docker_image_builder.yaml
###
@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 / zshrc
Last active January 9, 2023 20:17
ZSH configuration for GBT
###[ 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 / 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 / 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 / corporate-linux-desktop-howto.md
Created November 3, 2015 17:09 — forked from anonymous/corporate-linux-desktop-howto.md
How to run Linux desktop in a corporate environment

How to run Linux desktop in a corporate environment

DISCLAIMER

Some of the practices described in this HOWTO are considered to be illegal as they often break internal corporate policies. Anything you do, you do at your own risk.