Skip to content

Instantly share code, notes, and snippets.

View GrantBirki's full-sized avatar
:octocat:
Security @github

Grant Birkinbine GrantBirki

:octocat:
Security @github
View GitHub Profile
@GrantBirki
GrantBirki / git_diff.py
Last active September 8, 2022 19:18
GitDiff Python
import git
from unidiff import PatchSet
import os
from io import StringIO
class GitDiff:
"""
Class to get the diff between two branches

Salty Orange

DIY version of the ZeroLyte Salty Orange electrolyte mix

image

Mix

  • 2.5 grams of Sodium Chloride (NaCl)
  • 0.4 grams of Magnesium Malate (Mg)
@GrantBirki
GrantBirki / github.rb
Last active February 6, 2025 00:33
GitHub App Authentication with Octokit (Ruby)
# frozen_string_literal: true
# This class provides a wrapper around the Octokit client for GitHub App authentication.
# It handles token generation and refreshing, and delegates method calls to the Octokit client.
# Helpful: https://github.com/octokit/handbook?tab=readme-ov-file#github-app-authentication-json-web-token
# Go ahead and rename all the environment variables that start with "YOUR_..." to match your setup.
#
# Usage (examples):
# require_relative "github"
# github = GitHub.new
@GrantBirki
GrantBirki / ruby_logger_mocking.md
Last active October 9, 2024 17:53
Ruby Logger Mocking

Ruby Logger Mocking

TL;DR Best Option

The following statement is generally the best overall for mocking:

let (:log) { instance_double(Logger).as_null_object }
# - Creates an instance double of Logger with interface validation
# - Converts it into a null object that absorbs any unexpected method calls