Skip to content

Instantly share code, notes, and snippets.

@MartinHarding
MartinHarding / README.md
Last active November 10, 2021 14:17
Tic-tac-toe

Tic-tac-toe

Play Tic-tac-toe on your command line with up to four players on boards from 3x3 to 9x9 in size.

Example:

          _______            __                   __
         /_  __(_)____      / /_____ ______      / /_____  ___
          / / / / ___/_____/ __/ __ `/ ___/_____/ __/ __ \/ _ \
         / / / / /__/_____/ /_/ /_/ / /__/_____/ /_/ /_/ /  __/
@MartinHarding
MartinHarding / cracklepop.py
Created October 31, 2021 17:55
CracklePop
#!/usr/bin/env python
"""Save as: cracklepop.py
I also looked into doing it entirely with regex and ran across this very
interesting post (I confess I only partially understand it, but it's an
interesting discussion): https://stackoverflow.com/a/13223927
"""
# The normal one:
for num in range(1, 101):
@MartinHarding
MartinHarding / gist:7b22e17bc38f31bd2c6ec881b6b28b61
Created April 10, 2020 20:54
Update the expiration on an expired PGP/GPG key
$ gpg --edit-key user@domain.com
gpg> key 0
gpg> expire
gpg> Changing expiration time for a subkey.
Please specify how long the key should be valid.
0 = key does not expire
<n> = key expires in n days
<n>w = key expires in n weeks
<n>m = key expires in n months
<n>y = key expires in n years
@MartinHarding
MartinHarding / backup-github.sh
Last active March 11, 2020 17:11 — forked from darktim/backup-github.sh
If you have more than 30 Repositories, the original script will not download all. The github api limits the entries to 30 per page but you can raise that up to 100. I have added a small loop which sets the limit to 90 and cycles through all pages until the listing on a page is empty...
#!/bin/bash
# A simple script to backup an organization's GitHub repositories.
[[ -z "$GHBU_ORG" ]] && echo "Please set GHBU_ORG" && exit 1
[[ -z "$GHBU_UNAME" ]] && echo "Please set GHBU_UNAME" && exit 1
[[ -z "$GHBU_PASSWD" ]] && echo "Please set GHBU_PASSWD" && exit 1
GHBU_BACKUP_DIR=${GHBU_BACKUP_DIR-"github-backups"} # where to place the backup files
GHBU_ORG=$GHBU_ORG # the GitHub organization whose repos will be backed up
GHBU_UNAME=$GHBU_UNAME # the username of a GitHub account (to use with the GitHub API)
#!/bin/bash
# This assumes you already have the WSL installed
# Run inside WSL
apt update
apt install -y zsh zip
# Run shell-setup.sh
zsh -c "$(curl -fsSL https://gist.githubusercontent.com/MartinHarding/99c15906a61082bf563c33c7a8326e4c/raw/shell-setup.sh)"
@MartinHarding
MartinHarding / .p10k.zsh
Last active October 2, 2020 21:37
ZSH RC
# Generated by Powerlevel10k configuration wizard on 2019-11-19 at 13:55 EST.
# Based on romkatv/powerlevel10k/config/p10k-lean.zsh, checksum 29483.
# Wizard options: powerline, lean, time, 2 lines, dotted, no frame, lightest, compact,
# concise.
# Type `p10k configure` to generate another config.
#
# Config for Powerlevel10k with lean prompt style. Type `p10k configure` to generate
# your own config based on it.
#
# Tip: Looking for a nice color? Here's a one-liner to print colormap.
@MartinHarding
MartinHarding / shell-setup.sh
Last active March 1, 2023 02:13
Setup Oh My Zsh and PowerLevel10k
#!/bin/zsh
set -e
if [ -d "$HOME/.oh-my-zsh" ]; then
echo "Oh My ZSH is installed"
else
echo "Download and install Oh My ZSH before running this script"
echo 'sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"'
exit 1
fi
@MartinHarding
MartinHarding / vnc-setup.sh
Created November 18, 2019 22:26
Raspbian -> macOS VNC Setup
#!/bin/bash
# Source: https://stackoverflow.com/a/32361133
sudo apt-get update -y
sudo apt-get install -y x11vnc
x11vnc -storepasswd
X11VNC_PATH=~/.config/autostart/x11vnc.desktop
AFPD_PATH=/etc/avahi/services/afpd.service
RFB_PATH=/etc/avahi/services/rfb.service
@MartinHarding
MartinHarding / geminfo.sh
Last active November 4, 2019 23:01
Get info about your project's gems
#!/bin/bash
# Use with output of `bundle list` to get a CSV of your gems and when they were last updated
echo "gem,current_version,current_version_date,latest_version,latest_version_date"
while read line; do
if [[ $line == 'Gems included by the bundle:' ]]; then
continue
fi
gem_name=`echo "$line" | cut -d' ' -f2`
current_version_num=`echo "$line" | cut -d' ' -f3 | sed 's/[\(\)]//g'`
@MartinHarding
MartinHarding / toggle_mouse_button.lua
Last active October 28, 2023 10:35
Logitech Gaming Software Mouse Button Toggle script
-- Toggles a mouse button when you press another mouse button.
-- 1. Change your mouse to "Automatic Game Detection" mode
-- 2. Right click on a profile's icon and choose scripting
-- 3. Paste this into the default profile script box, save, enjoy!
toggle_button = 7 -- What mouse button should control the toggle
button_to_toggle = 1 -- What button to toggle
button_toggled = false
function OnEvent(event, arg)
if event == "MOUSE_BUTTON_PRESSED" and arg == toggle_button then
button_toggled = not button_toggled