Skip to content

Instantly share code, notes, and snippets.

View chadbrewbaker's full-sized avatar

Chad Brewbaker chadbrewbaker

View GitHub Profile
@chadbrewbaker
chadbrewbaker / climate.py
Last active July 17, 2024 20:58
Napkin math climate calculation
import numpy as np
from astropy.time import Time
from astropy.coordinates import get_body_barycentric, solar_system_ephemeris
from astropy import units as u
def calculate_earth_sun_distance(date):
"""
Calculate the distance between Earth and the Sun on a given date.
Parameters:
@chadbrewbaker
chadbrewbaker / LAMS.py
Created December 2, 2023 03:08
Labeled Acyclic Mexican Standoffs
import itertools
# 1, 3, 25, 443, 13956
def generate_graphs(n):
""" Generate all directed graphs for n vertices """
all_possible_edges = [(i, j) for i in range(n) for j in range(n) if i != j]
for edges in itertools.product([False, True], repeat=len(all_possible_edges)):
graph = {i: [] for i in range(n)}
for edge, edge_exists in zip(all_possible_edges, edges):
if edge_exists:
@chadbrewbaker
chadbrewbaker / injections.txt
Created November 27, 2023 20:41
Apple Messages Injection surface
SHANA - trnscript cells %@ - index path %@
sms://open?groupid=%@
Still presenting %@
Search "%@" number of results
After clearing "%@" should have no results
%@ -- %@
%@Units
Failed to enter conversation with chat identifier %@
Failed to find chat: %@
%@-%@
@chadbrewbaker
chadbrewbaker / Makefile
Created November 16, 2023 20:41
ChadCloudForm
.PHONY: create-keypair launch-instance connect-instance shutdown-instance clean log-details
# Variables
KEY_NAME = MyKeyPair
INSTANCE_TYPE = t2.micro
AMI_ID = ami-12345678
SECURITY_GROUP_ID = sg-12345678
SUBNET_ID = subnet-12345678
KEY_FILE = $(KEY_NAME).pem
INSTANCE_IP = # Put your instance's public IP or DNS here
@chadbrewbaker
chadbrewbaker / llmCodeParsing.md
Created September 23, 2023 20:58
LLM Code Parsing
@chadbrewbaker
chadbrewbaker / aks.py
Created May 3, 2023 02:06
AKS Primality Test
# ChatGPT4 spit it out with some coaxing - looks legit, haven't tested.
import math
def is_prime(n):
def is_power(a, b):
if a == 1:
return b != 1
power = 1
while power < b:

ChatGPT prompt: How would you write an LLVM optimization pass to lint for register spilling?

An LLVM optimization pass is a way to analyze or transform LLVM Intermediate Representation (IR) code. To write an LLVM optimization pass that lints for register spilling, you would need to analyze the register allocation process and identify cases where register spilling occurs. Here's a high-level outline of the steps you'd need to take:

Set up an LLVM pass: First, you need to set up a new LLVM pass. To do this, create a new class that inherits from llvm::FunctionPass. In this class, you'll implement the runOnFunction method, which will be called for each function in the module you're analyzing.

#include "llvm/Pass.h"
#include "llvm/IR/Function.h"
@chadbrewbaker
chadbrewbaker / perfchat25sep2022.md
Created September 25, 2022 17:19
perfchat 25 sep 2022