Skip to content

Instantly share code, notes, and snippets.

View primaryobjects's full-sized avatar

Kory Becker primaryobjects

View GitHub Profile
@primaryobjects
primaryobjects / twoSum.py
Created July 15, 2024 21:31
Two Sum solved in Python using brute force and hash map https://leetcode.com/problems/two-sum/
class Solution:
def twoSum1(self, nums: List[int], target: int) -> List[int]:
# O(n^2)
for i in range(len(nums)):
for j in range(i+1, len(nums)):
if target - nums[i] == nums[j]:
return [i, j]
return None
@primaryobjects
primaryobjects / ml.py
Created July 15, 2024 02:22
Machine learning tutorial with confusion matrix calculations in Python https://replit.com/@primaryobjects/MachineLearning
# make predictions
from pandas import read_csv
from sklearn.metrics import accuracy_score, classification_report, confusion_matrix
from sklearn.model_selection import train_test_split
from sklearn.svm import SVC
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
# Load dataset
from __future__ import annotations
class Node:
value = None
next = None
def __init__(self, value: int, next: Node = None):
self.value = value
self.next = next
@primaryobjects
primaryobjects / exam.txt
Last active July 8, 2024 20:36
Get Started with Data Engineering on Databricks certification exam https://www.databricks.com/learn/training/getting-started-with-data-engineering
1)
Which statement describes the Databricks workspace?
** It is a solution for organizing assets within Databricks.
It is a classroom setup for running Databricks lessons and exercises.
It is a set of predefined tables and path variables within Databricks.
It is a mechanism for cleaning up lesson-specific assets created during a learning session.
Score: 10.00
@primaryobjects
primaryobjects / prompt.txt
Created July 7, 2024 01:25
GraphPlan GPT prompt
Write a js implementation of GraphPlan, the planning algorithm based on STRIPS. The input will be a JSON object for domain and problem as provided below in examples.
The algorithm should include the following requirements:
1. The code should find mutexes as part of the process in order to only find a solution that satisfies the goal and with a path that does not contain mutexes among the actions.
2. Make sure that at each new level all available actions are added into the possibilities, as well as all valid combinations of parameters so that every valid action and parameter combination is considered at each level, as long as they do not violate a mutex.
3. Actions can also be 'noop' in which case action.action == 'noop' and action.effect == null.
Work slowly and step-by-step to create a correct and accurate implementation to perform this task. Think through each step in the process and write the code to implement the solution.
@primaryobjects
primaryobjects / script.js
Created July 4, 2024 02:14
Example Google Spreadsheet Apps Script to call Cohere API. Integrate AI LLM large language model in a spreadsheet.
function callCohereAPI(user_prompt) {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); // get active sheet
user_prompt = user_prompt || sheet.getRange('B1').getValue();
const dataRange = sheet.getRange('E2:G100').getValues();
let dataStrings = dataRange.map(function(row) {
// Check if the row is not empty
if (row.filter(String).length) {
return row.join(',');
}
@primaryobjects
primaryobjects / 1-exam.md
Last active July 17, 2024 10:36
Oracle Cloud Infrastructure 2024 Generative AI Professional 1Z0-1127-24 Practice Exam Questions

How are documents usually evaluated in the simplest form of keyword-based search? According to the length of the documents Based on the number of images and videos contained in the documents By the complexity of language used in the documents ** Based on the presence and frequency of the user-provided keywords

When is fine-tuning an appropriate method for customizing a Large Language Model (LLM)? When you want to optimize the model without any instructions When the LLM requires access to the latest data for generating outputs ** When the LLM does not perform well on a task and the data for prompt engineering is too large

@primaryobjects
primaryobjects / index.html
Last active May 19, 2024 23:20
Gauntlet-like game created with ChatGPT4o using HTML and Javascript https://jsbin.com/ketusuveve/1/edit?js,output
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gauntlet-like Game</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<canvas id="gameCanvas" width="800" height="600"></canvas>
@primaryobjects
primaryobjects / Readme.md
Created May 17, 2024 21:29
How to fix: PayPal IPN 403 Error

PayPal IPN 403 Error

Solution

Disable ModSecurity in cpanel.

What is it?

HTTP 403 is an HTTP status code meaning access to the requested resource is forbidden. The server understood the request, but will not fulfill it, if it was correct.

@primaryobjects
primaryobjects / ff2-utility.au3
Last active February 25, 2024 21:28
Automatic Level 16 Spells in Final Fantasy II using Emulator for PS1
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$count = 125
$label = 0
$button = 0
Func _WriteErrorLog($ErrorMessage)
FileWriteLine(@ScriptDir & "\" & @ScriptName & ".log", @HOUR & ":" & @MIN & ":" & @SEC & ": " & $ErrorMessage)