Skip to content

Instantly share code, notes, and snippets.

View primaryobjects's full-sized avatar

Kory Becker primaryobjects

View GitHub Profile
@primaryobjects
primaryobjects / view.html
Last active September 17, 2024 00:58
Jinja syntax to add a new property to sort a list by
{% set updated_users = [] %}
{% for user in all_users %}
{% set names = user.full_name.split() %}
{% set first_name = names[0] %}
{% set last_name = names[1:] | join(' ') %}
{% set updated_user = user.copy() %}
{% set _ = updated_user.update({'first_name': first_name, 'last_name': last_name}) %}
{% set _ = updated_users.append(updated_user) %}
{% endfor %}
@primaryobjects
primaryobjects / fullscreen.md
Created July 30, 2024 03:57
How to enable full screen in RetroPi RetroArch on Ubuntu 23

How to enable fullscreen mode in RetroPi/RetroArch

The following steps allow hiding all top menu bars, allowing fullscreen mode for games running in RetroArch (including nes/snes).

Ubuntu 23 / Gnome 45

  1. Download Hide Top Bar from the Gnome Extensions Store.
  2. Download latest version of Unite-shell.
  3. Extract unite-shell to ~/.local/share/gnome-shell/extensions
@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 August 6, 2024 07:38
Oracle Cloud Infrastructure 2024 Generative AI Professional 1Z0-1127-24 Practice Exam Questions https://medium.com/code-like-a-girl/i-passed-the-oracle-generative-ai-professional-exam-heres-what-i-learned-bdf28be53864

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>