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 / 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
@GrantBirki
GrantBirki / fake_private_key.pem
Last active July 31, 2025 06:06
GitHub App Authentication with Octokit (Ruby)
-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEArCtJrQ+P59A1Pjaf12EfJqltszDpqO0ufsk7N0WRXUeoYZKF
AihwLMIaHbTc1Jn/QEX8WmZGPKIcRlJ9pk2MxQbXRqxM35n61Cb8mYMne+6VXNyl
ZILvRTMXLGIVy/OTmszafTP8Lws9w8vKKLKCax4kEzbfjiRoCgspO7YudFUCxQ6Q
UUxlLPd4/yUaw5A8nUdWZrvPa3CYXG2355yhigRpnOyawoOsvAHUvQruh+z3k6NZ
g6f3eMjsrpeID84TPw1kRs+T+XNsSP21ZUFKYs54bdxlLPphT4iPKNkRwoP0SqJm
97W98B8k7+mtFPZllYGgiHrA4Egnasg9ULiXCwIDAQABAoIBACMoZ9AuWF2nN+gv
cW6jB6B2gs9P0rdLT+5WG4CK9UdOJcVfDUhGh7msHXcpgtrrY6N1ZzXyoq8pD4sQ
t1XpijCF2Bo3fy8+G2mNWJHkpYB6VQf0itW+oyvHZhkLIpZWdDLtWESvA/V7Xy6H
hA3Rfi5vpkBCOV6mcpRyeQYXit74UzDvojXSf8idsjuVDoIXuaoIJMPwyxTWJY+A

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 / 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
@GrantBirki
GrantBirki / branch-deploy.yml
Created May 19, 2022 03:22
Branch Deploy Segment #5
# Do some fake "noop" deployment logic here
# conditionally run a noop deployment
- name: fake noop deploy
if: ${{ steps.branch-deploy.outputs.continue == 'true' && steps.branch-deploy.outputs.noop == 'true' }}
run: echo "I am doing a fake noop deploy"
# Do some fake "regular" deployment logic here
# conditionally run a regular deployment
- name: fake regular deploy
if: ${{ steps.branch-deploy.outputs.continue == 'true' && steps.branch-deploy.outputs.noop != 'true' }}
@GrantBirki
GrantBirki / branch-deploy.yml
Last active June 17, 2022 18:14
Branch Deploy Segment #4
# Execute IssueOps branch deployment logic, hooray!
- uses: github/[email protected]
id: branch-deploy
with:
trigger: ".deploy"
@GrantBirki
GrantBirki / branch-deploy.yml
Created May 19, 2022 03:20
Branch Deploy Segment #3
jobs:
demo:
runs-on: ubuntu-latest
steps:
# Checkout your projects repository
- uses: actions/[email protected]
@GrantBirki
GrantBirki / branch-deploy.yml
Last active June 17, 2022 18:14
Branch Deploy Segment #2
# Permissions needed for reacting and adding comments for IssueOps commands
permissions:
pull-requests: write
deployments: write
contents: write
@GrantBirki
GrantBirki / branch-deploy.yml
Last active May 19, 2022 03:24
Branch Deploy Segment #1
# The name of the workflow, it can be anything you wish
name: "branch deploy demo"
# The workflow to execute on is comments that are newly created
on:
issue_comment:
types: [created]
@GrantBirki
GrantBirki / tarkov-time-python.py
Created March 1, 2022 07:49
Tarkov Time in Python
from datetime import datetime
# 7 seconds for every one second in real time
TARKOV_RATIO = 7
def real_time_to_tarkov_time(time, left = True):
"""
Convert real time to Tarkov time
:param time: Current UTC epoch in milliseconds -> int(datetime.datetime.utcnow().timestamp()) * 1000
:param left: True if left side, False if right side (Think eft in-game clock)