Skip to content

Instantly share code, notes, and snippets.

View FreedomBen's full-sized avatar
💭
Currently setting my status

Ben Porter FreedomBen

💭
Currently setting my status
View GitHub Profile
@FreedomBen
FreedomBen / .bashrc
Created December 28, 2023 19:25
Bash functions for controlling a chromecast with google TV from the CLI
adbdevicecount()
{
adb devices | grep -P '\sdevice$' | sed -e 's/device//g' | wc -l
}
adbkeyevent()
{
if [ -z "${1}" ]; then
echo "oops! Pass one arg with button. example 'adbkeyevent ENTER'"
elif [ -z "${ANDROID_SERIAL}" ] && [ "$(adbdevicecount)" = '1' ]; then
@FreedomBen
FreedomBen / keyevents.json
Created December 8, 2022 18:03 — forked from arjunv/keyevents.json
All Android Key Events for usage with adb shell
{
"key_events": {
"key_unknown": "adb shell input keyevent 0",
"key_soft_left": "adb shell input keyevent 1",
"key_soft_right": "adb shell input keyevent 2",
"key_home": "adb shell input keyevent 3",
"key_back": "adb shell input keyevent 4",
"key_call": "adb shell input keyevent 5",
"key_endcall": "adb shell input keyevent 6",
"key_0": "adb shell input keyevent 7",
@FreedomBen
FreedomBen / vmware2libvirt.py
Created June 17, 2022 01:56
Python script to convert VMware image format to libvirt XML
#! /usr/bin/env python
#
# vmware2libvirt: migrate a vmware image to libvirt
# Author: Jamie Strandboge <jamie@canonical.com>
#
# Copyright (C) 2008 Canonical Ltd.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3,
# as published by the Free Software Foundation.
# Install cockpit and pcp and activate services
dnf install -y cockpit pcp cockpit-pcp
systemctl enable --now cockpit.socket
systemctl enable --now pmlogger
# If needed, open port 9090 in the firewall
firewall-cmd --zone=public --permanent --add-service=cockpit
# Alternatively you can open port 9090 to only your own IP
firewall-cmd --zone=public --permanent --add-rich-rule='rule family="ipv4" source address="38.14.154.124" port protocol="tcp" port="9090" accept'
wget https://raw.githubusercontent.com/FreedomBen/digall/main/digall \
&& chmod +x digall
dig +noall +answer '<domain>' '<type>'
dig +noall +answer gmail.com SOA
dig +noall +answer gmail.com NS
dig +noall +answer gmail.com SPF
dig +noall +answer gmail.com TXT
dig +noall +answer gmail.com MX
dig +noall +answer gmail.com AAAA
dig +noall +answer gmail.com A
@FreedomBen
FreedomBen / digall.sh
Last active May 7, 2022 17:22
the bash "digall" command - Ben Porter
# Paste this into your shell and you can use the 'digall' command like:
# digall example.com
# digall something.example.com
# You can also add it to your ~/.bashrc file to have it always available
declare -rx color_restore='\033[0m'
declare -rx color_red='\033[0;31m'
declare -rx color_light_green='\033[1;32m'
@FreedomBen
FreedomBen / elasticsearch-forward.sh
Created March 30, 2022 23:00
Forward local port 9200 to Elasticsearch in the Kubernetes Cluster
kubectl port-forward es-cluster-0 9200:9200 --namespace=kube-logging
# Now you can curl the elasticsearch API on localhost 9200
curl http://localhost:9200/_cluster/state?pretty
@FreedomBen
FreedomBen / kibana-forward.sh
Created March 30, 2022 22:58
Forward local port 5601 to Kibana in the Kubernetes Cluster
KIBANA_POD_NAME="$(kubectl get po -lapp=kibana -o jsonpath={.items[0].metadata.name})"
kubectl port-forward "${KIBANA_POD_NAME}" 5601:5601 --namespace=kube-logging
echo "Open http://localhost:5601 in your browser"