Skip to content

Instantly share code, notes, and snippets.

Avatar

Brendan McGrath redmcg

  • Melbourne, Australia
View GitHub Profile
@redmcg
redmcg / isLUHNValid.sh
Last active Jan 12, 2017
LUHN Check in Bash
View isLUHNValid.sh
#!/usr/bin/env bash
. library.sh
pan="$1"
isLUHNValid "$pan"
@redmcg
redmcg / WRTest.cs
Created Nov 12, 2018
Simple Web Request test (fails under Wine with dotnet install and IPv6 disabled)
View WRTest.cs
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 / findHostName.sh
Last active Jan 17, 2020
An awk script that provides the same functionality as ssh-keygen -F <host>
View findHostName.sh
#!/usr/bin/env bash
host=$1
awk -v host=$host '
/^|1/ {
split($1, a, /\|/)
key=a[3]
hmac=a[4]
@redmcg
redmcg / d3d9Test.cpp
Last active Feb 17, 2020
Get number of D3D9 adapters
View d3d9Test.cpp
// compile with: x86_64-w64-mingw32-g++ d3d9Test.cpp
#include <d3d9.h>
#include <stdio.h>
int main(int argc, char **argv) {
HRESULT hr = E_FAIL;
HMODULE libHandle = NULL;
UINT m_uD3DAdapterCount = 0;
@redmcg
redmcg / dumpSSHFP.sh
Last active Aug 25, 2020
Given a base64 public SSH key, output fingerprint
View dumpSSHFP.sh
#!/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 / gnome-to-more-like-unity.sh
Last active Oct 16, 2021
Add 2x2 Workspaces and Unity tiling keyboard shortcuts (i.e. Alt-Ctrl Numpad Direction)
View gnome-to-more-like-unity.sh
#!/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 / kubedf
Last active Nov 15, 2021
Bash script to show k8s PVC usage
View kubedf
#!/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")) | '\