Skip to content

Instantly share code, notes, and snippets.

@g023
g023 / compress-decompress-example.htm
Last active April 13, 2024 05:31
Making dictionaries with Javascript
<!-- /*
// author: https://github.com/g023
// license: BSD 3-Clause (https://opensource.org/license/BSD-3-clause)
An example to compress and decompress some text based on a given dictionary.
Makes a simpler array from the dictionary created from findTwoCharCombinations(text) and findThreeCharCombinations(text)
That should make compression even better.
TODO: compress the dictionary using the dictionary.
*/ -->
@g023
g023 / ROM_MUD_MOBS_LOADING.gd
Created March 19, 2024 05:13
A set of Godot 4+ GDScript example programs to load a ROM 2.4 MUD server .are area file, and parse its various fields into something more readable. Loads every section from a ROM MUD area file. See the print in the console for debugging.
extends Node2D
# author: https://github.com/g023
# Called when the node enters the scene tree for the first time.
func _ready():
#var romfile = "thalos.are"
var romfile = "sewer.are"
var romcontents = get_contents(romfile)
@g023
g023 / 2key_array_manager_encrypted_saving_and_loading_godot4.gd
Last active March 13, 2024 12:03
Godot 4 - Double Key Array Management w/Encrypted File Storage - GDScript
# BEGIN :: Multidimensional array with 2 keys and a value
# Multidimensional array with 2 keys and a value
# Godot version of my plist class that was made for my C++ mud
# encrypted file saving and loading
class TwoKeyArray:
var data = {}
# Initialize the array with default values
func _init():
data = {}
@g023
g023 / get_one_arg_and_parameter_godot4.gd
Created March 7, 2024 06:17
Godot 4 - Get One Argument Out Of String - Return Argument and Parameter - GDScript
func one_arg(command_str):
# strips out a single word before a space
# returns [0] -> command, [1] -> param
var split_str = []
command_str = command_str.strip_edges()
command_str = self.processBackspace(command_str)
var command = ""
var params = ""
@g023
g023 / process_backspaces_out_of_strings_godot4.gd
Created March 7, 2024 06:13
Godot 4 - Process Backspaces Out Of A String - GDScript
func processBackspace(input_string):
var result = ""
var stack := []
if input_string.find("\b") == -1:
return input_string
for char in input_string:
if char == "\b":
if stack.size() > 0:
@g023
g023 / boxjump2.htm
Created February 25, 2024 05:57
A Box Jump Game - Simple 2d Platformer Barebones Minimalist Game Example in JavaScript
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Box Jump - Simple 2d Platformer Barebones</title>
<style>
#gameCanvas {
background-color: #ccc;
}
@g023
g023 / jquery_horizontal_infinite_image_scroller.html
Last active November 6, 2023 00:26
A jQuery example for infinite horizontal scrolling. It is a simple example that can be used to create an infinite horizontal scrolling effect. It is lightweight and easy to use.
<!--
jQuery Infinite Horizontal Scroll
license: 3-clause BSD license (http://opensource.org/licenses/BSD-3-Clause)
author: https://github.com/g023 (gists: https://gist.github.com/g023 )
version: 0.0.1a
notes: some parts configured in the CSS (speed, width, height ) and some parts in the JS (image URLs)
-->
<!DOCTYPE html>
@g023
g023 / lmstudio_gptclass_chat_agent.py
Created October 30, 2023 04:57
This python class uses LM Studio's Server API to generate text in the style of chat LLMs like ChatGPT, GPT4ALL, etc. Has example usage with a default agent at bottom of source code.
# class: GPTClient Python Class for LM Studio API (Runs local LLM LLAMA style quantized models)
# author: https://github.com/g023
# License: 3-clause BSD License - https://opensource.org/license/BSD-3-clause/
# Note: Example usage attached at bottom of file
# Description: This class is a wrapper for the LM Studio API. It is designed to be used with the LLAMA style quantized models.
# Tags: API, LM Studio, LLAMA, LLAMA style quantized models, LLAMA style quantized model, LLM, LM, NLP, NLG, Chatbot, Chatbots, Conversational AI, Conversational Artificial Intelligence, Conversational AI Chatbot, Conversational Artificial Intelligence Chatbot, Conversational AI Chatbots, Conversational Artificial Intelligence Chatbots, Conversational AI Chatbots, Conversational Artificial Intelligence Chatbots, Conversational AI Chatbot, Conversational Artificial Intelligence Chatbot, Conversational AI Chatbot, Conversational Artificial Intelligence Chatbot
import requests
import json