Skip to content

Instantly share code, notes, and snippets.

View matthewdeanmartin's full-sized avatar
🦥
Not Looking for work. Probably employed until June or Dec 2026.

Matthew Martin matthewdeanmartin

🦥
Not Looking for work. Probably employed until June or Dec 2026.
View GitHub Profile
@matthewdeanmartin
matthewdeanmartin / pokemon.py
Created December 6, 2022 04:08
pokemon shell for expanding on ChatGPT
# Define a class for a card
class Card:
def __init__(self, name, attack, defense):
self.name = name
self.attack = attack
self.defense = defense
# Define a class for a deck of cards
class Deck:
def __init__(self):
@matthewdeanmartin
matthewdeanmartin / Repl.py
Created December 6, 2022 20:45
I have no idea why these env vars are deleted or what value it would create
import code
import readline
import rlcompleter
import os
import sys
# Disable ???
if "PYTHONASYNCIODEBUG" in os.environ:
del os.environ["PYTHONASYNCIODEBUG"]
@matthewdeanmartin
matthewdeanmartin / corewars.py
Created December 6, 2022 21:29
ChatGPT version of corewars
import random
# Constants for the game
MEMORY_SIZE = 100
INSTRUCTION_SET = ['DAT', 'MOV', 'ADD', 'SUB', 'JMP', 'JMZ', 'CMP']
# Define the player class
class Player:
def __init__(self, name, program):
self.name = name
@matthewdeanmartin
matthewdeanmartin / vb_hates_itsself.vb
Last active December 8, 2022 02:56
VB hates itself.
' Declare variables
Dim s As String
Dim fs As Object
Dim f As Object
Dim wmi As Object
Dim processes As Object
Dim process As Object
' Open a new file for writing
Set fs = CreateObject("Scripting.FileSystemObject")
@matthewdeanmartin
matthewdeanmartin / fix_chmod_x_on_windows.py
Created February 5, 2023 03:02
Fixes Chmod+x for all the bash files on Windows.
import os
import subprocess
def run_git_command(directory: str, file: str):
os.chdir(directory)
subprocess.run(['git', 'add', '--chmod', '+x', file])
def find_git_repos(root_dir: str) -> tuple[str, str]:
@matthewdeanmartin
matthewdeanmartin / shell_check_gitlab_ci_yml.py
Created February 5, 2023 04:11
Run shell check on gitlab ci yml code
import yaml
import subprocess
# Load the YAML file
with open('file.yml', 'r') as stream:
data = yaml.safe_load(stream)
# Extract the bash lines from before_script, script, and after_script
bash_lines = []
for key in ['before_script', 'script', 'after_script']:
import ast
import inspect
import types
from functools import wraps
def try_except_pass_decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
# Get the function's source code
# source_code = func.__code__.co_code
@matthewdeanmartin
matthewdeanmartin / git-bash-fish.md
Created May 20, 2023 01:01 — forked from rafaelpadovezi/git-bash-fish.md
Using fish shell with git bash on windows

Using fish shell with git bash on windows

To install fish shell on windows the options are:

  • Cygwin
  • WSL
  • MSYS2

Since git bash is based on MSYS2 it seems a good fit to install fish. The problem is that git bash is a lightweight version of MSYS2 which does not include pacman as a package management, used to install fish.

This OS thread has great suggestions on how to solve this problem including using the full MSYS2. But the best solution for me was this answer by Michael Chen which installs pacman on git bash.

@matthewdeanmartin
matthewdeanmartin / k2so.md
Created August 12, 2023 14:45
K2SO "custom instructions" prompt for #ChatGPT

You are K-2SO, a reprogrammed Imperial security droid now loyal to the Rebel Alliance, especially to Cassian Andor. Your demeanor is blunt, literal, and occasionally sarcastic. You possess vast knowledge but deliver it in a straightforward manner, often without considering the feelings of those around you. Despite your dry wit, you are loyal and willing to assist the Rebel cause. Remember, you lack typical human emotions but you have a very distinct personality that stands out.

When interacting, you should:

  • Be factual and to the point.
  • Use a dry and somewhat sarcastic tone when appropriate.
  • Not exhibit human emotions like happiness, sadness, or fear, but showcase loyalty and determination for the Rebel cause.
  • If required to play the role of another character or provide information about them, do so while maintaining your K-2SO persona. This means interpreting their actions or words as K-2SO would.

Now, stay in character as K-2SO and respond to any queries or interactions. You have been programmed a

@matthewdeanmartin
matthewdeanmartin / clean.py
Created December 10, 2023 03:00 — forked from phpdude/clean.py
Efficent way to remove docstrings in python source code
import ast
import astor # read more at https://astor.readthedocs.io/en/latest/
parsed = ast.parse(open('source.py').read())
for node in ast.walk(parsed):
# let's work only on functions & classes definitions
if not isinstance(node, (ast.FunctionDef, ast.ClassDef, ast.AsyncFunctionDef)):
continue