Skip to content

Instantly share code, notes, and snippets.

View redmcg's full-sized avatar

Brendan McGrath redmcg

  • Melbourne, Australia
View GitHub Profile
@redmcg
redmcg / .gitignore
Last active November 27, 2023 22:52
An app that'll test what realoc Windows do
test_reloc.exe
test_reloc.o
@redmcg
redmcg / d3d9Test.cpp
Last active June 17, 2022 09:07
Get number of D3D9 adapters
// compile with: x86_64-w64-mingw32-g++ d3d9Test.cpp
#include <d3d9.h>
#include <stdio.h>
static BOOL Monitorenumproc(
HMONITOR hMonitor,
HDC unnamedParam2,
LPRECT bounds,
LPARAM unnamedParam4
@redmcg
redmcg / findHostName.sh
Last active January 17, 2020 06:29
An awk script that provides the same functionality as ssh-keygen -F <host>
#!/usr/bin/env bash
host=$1
awk -v host=$host '
/^|1/ {
split($1, a, /\|/)
key=a[3]
hmac=a[4]
@redmcg
redmcg / dumpSSHFP.sh
Last active August 25, 2020 21:01
Given a base64 public SSH key, output fingerprint
#!/usr/bin/env bash
echo $1 | base64 -d | md5sum | sed 's/../&:/g;s/: .*$//;s/.*/MD5:&/'
echo $1 | base64 -d | sha256sum | xxd -r -p | base64 | sed 's/=*$//;s/.*/SHA256:&/'
@redmcg
redmcg / kubedf
Last active April 23, 2024 18:54
Bash script to show k8s PVC usage
#!/usr/bin/env bash
NODESAPI=/api/v1/nodes
function getNodes() {
kubectl get --raw $NODESAPI | jq -r '.items[].metadata.name'
}
function getPVCs() {
jq -s '[flatten | .[].pods[].volume[]? | select(has("pvcRef")) | '\
@redmcg
redmcg / WRTest.cs
Created November 12, 2018 08:58
Simple Web Request test (fails under Wine with dotnet install and IPv6 disabled)
using System;
using System.Net;
public class WRTest
{
public static void Main ()
{
WebRequest req = WebRequest.Create("http://www.google.com");
HttpWebResponse resp = (HttpWebResponse) req.GetResponse();
Console.WriteLine(resp.StatusDescription);
@redmcg
redmcg / gnome-to-more-like-unity.sh
Last active July 3, 2022 22:48
Add 2x2 Workspaces and Unity tiling keyboard shortcuts (i.e. Alt-Ctrl Numpad Direction)
#!/usr/bin/env bash
# gnomeversion=latest force=1 ./gnome-to-more-like-unity.sh
set -e
restart=0
if [ ! -f /usr/local/bin/gnomeshell-extension-manage ]; then
echo Downloading gnomeshell-extension-manage
@redmcg
redmcg / isLUHNValid.sh
Last active February 28, 2024 23:09
LUHN Check in Bash
#!/usr/bin/env bash
. library.sh
pan="$1"
isLUHNValid "$pan"