Skip to content

Instantly share code, notes, and snippets.

View jabbott-iii's full-sized avatar

Joseph Abbott III jabbott-iii

View GitHub Profile
@jabbott-iii
jabbott-iii / CompositeKey.java
Created July 11, 2026 22:23
Java merge two foreign keys into one composite key for table using lombok and springboot
package com.jabbott.d288.entities;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.io.Serializable;
@jabbott-iii
jabbott-iii / Carts.java
Created July 11, 2026 21:36
Java enum usage
package com.jabbott.d288.entities;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import java.util.Date;
import java.util.Set;
@jabbott-iii
jabbott-iii / Product.java
Created July 7, 2026 20:11
Java - ManytoOne relationship between two tables
package com.jabbott.fsas.entity;
import jakarta.persistence.*;
import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import java.math.BigDecimal;
import java.util.Date;
@Entity
@jabbott-iii
jabbott-iii / app.py
Created July 7, 2026 03:28
Python - LLM prompting API example
from fastapi import FastAPI, HTTPException, Header, Depends
import ollama
import os
from dotenv import load_dotenv
load_dotenv() # Load environment variables from .env file
API_KEY_CREDITS = {os.getenv('API_KEY'): 5} # Example: Each API key starts with 5 credits
app = FastAPI() # Create FastAPI app instance
@jabbott-iii
jabbott-iii / errors.py
Created July 7, 2026 03:26
Python - invalid endpoint error handling
import requests
try:
response = requests.get(url='https://jsonplaceholder.typicode.com/invalid_endpoint', timeout=5) # Intentionally incorrect URL to trigger an error
response.raise_for_status() # Raise an error for bad responses (4xx and 5xx)
print('Success', response.json())
except requests.exceptions.Timeout: # Handle timeout exception
print('The request timed out')
except requests.exceptions.RequestException as e: # Catch all other request-related errors
print('An error occurred:', e)
@jabbott-iii
jabbott-iii / token.py
Created July 7, 2026 03:25
Python - token authentication request
import requests
token = 'your_api_token_here' # Replace with your actual token
base_url = 'https://api.example.com/data' # Replace with the actual API endpoint
headers = {
'Authorization': f'Bearer {token}'
}
response = requests.get(base_url, headers=headers) # Send GET request with authorization header
@jabbott-iii
jabbott-iii / main.py
Created July 7, 2026 03:22
Python - uvicorn webserver deployment localhost
import uvicorn # webserver for FastAPI
if __name__ == "__main__":
uvicorn.run("app:app", host="0.0.0.0", port=8000, reload=True) # app.app:app refers to app folder, app.py file, and app variable
@jabbott-iii
jabbott-iii / main.rs
Created July 7, 2026 03:19
Rust - Tip calculator
use std::io;
use std::io::BufRead;
// f64 is a data type that represents a 64-bit floating point number
fn main() {
println!("Tip Calculator");
// Get user input for total bill
println!("What is the total bill? $");
let mut bill = String::new();
@jabbott-iii
jabbott-iii / main.rs
Created July 7, 2026 03:16
Rust - Basic binary logic using modulo 2
use std::io::BufRead;
fn main() {
println!("Odd or Even Check");
println!("Please enter a number: ");
// Get user input
let mut userdata = String::new();
std::io::stdin()
.read_line(&mut userdata)
.expect("Failed to read line");
@jabbott-iii
jabbott-iii / cargo.toml
Created July 7, 2026 03:11
Cargo workspace to tie multiple packages in one repository together.
[workspace]
members = [
"basic_variable",
"basic_calc",
"basic_if",
"basic_if_2",
"basic_if_3",
"basic_odd_vs_even",
"cli_ls",
]