Skip to content

Instantly share code, notes, and snippets.

View CoffeeVampir3's full-sized avatar

Z CoffeeVampir3

View GitHub Profile
@CoffeeVampir3
CoffeeVampir3 / draganddrop.rs
Last active January 11, 2023 00:53
rust drag&drop sprites
fn handle_mouse_interactions(
button_input: Res<Input<MouseButton>>,
windows: Res<Windows>,
mut interactables: Query<(Entity, &mut Interactable)>,
sprites: Query<(Entity, &GlobalTransform), With<Sprite>>,
rapier_context: Res<RapierContext>,
) {
//Sequence note: This happens first because we want to know if the mouse button was released event outside our window.
if button_input.just_released(MouseButton::Left) {
@CoffeeVampir3
CoffeeVampir3 / InventoryComponent.cpp
Created March 11, 2023 02:45
part of an inventory example
// Fill out your copyright notice in the Description page of Project Settings.
#include "InventoryComponent.h"
// Sets default values for this component's properties
UInventoryComponent::UInventoryComponent()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don't need them.
@CoffeeVampir3
CoffeeVampir3 / EnumSet.rs
Last active March 16, 2023 07:22
N Length Bit Set
mod testing_suite;
use std::ops::{BitAnd, BitOr};
use std::marker::PhantomData;
#[derive(Debug, Clone, PartialEq, Eq)]
struct EnumSet<E, const N: usize = 2> {
flags: [u64; N],
_phantom: PhantomData<E>,
}
use nalgebra::{Vector3, Vector6, Unit};
// Converts an axis-angle representation to a twist
fn axis_angle_to_twist(axis: Unit<Vector3<f64>>, angle: f64) -> Vector6<f64> {
let angular_velocity = angle * axis;
Vector6::new(0.0, 0.0, 0.0, angular_velocity.x, angular_velocity.y, angular_velocity.z)
}
// Rotates a point using a twist
fn rotate_point(point: Vector3<f64>, twist: Vector6<f64>, angle: f64) -> Vector3<f64> {
@CoffeeVampir3
CoffeeVampir3 / compute.rs
Last active April 4, 2023 23:00
compute.rs
//! A compute shader that simulates Conway's Game of Life.
//!
//! Compute shaders use the GPU for computing arbitrary information, that may be independent of what
//! is rendered to the screen.
use bevy::{
prelude::*,
render::{
extract_resource::{ExtractResource, ExtractResourcePlugin},
render_asset::RenderAssets,
@CoffeeVampir3
CoffeeVampir3 / Example Usage.cpp
Created April 9, 2023 01:04
Example interface in Unreal Engine 5.
AActor* ActorToUse = /* Get the actor that implements the ItemInterface */;
if (ActorToUse && ActorToUse->GetClass()->ImplementsInterface(UItemInterface::StaticClass()))
{
IItemInterface::Execute_Use(ActorToUse);
}
@CoffeeVampir3
CoffeeVampir3 / convert.py
Last active June 4, 2023 04:41
GGML train, convert & quant
import argparse
import concurrent.futures
import copy
import enum
import faulthandler
import functools
import io
import itertools
import json
import math
from langchain import LLMMathChain, LLMChain, ConversationChain, PromptTemplate
from langchain.chains.conversation.memory import ConversationBufferWindowMemory
from langchain.agents import Tool, initialize_agent
from functools import partial
import random
def random_gen(input=""):
return random.randint(0, 5)
def meaning_of_life(input=""):
@CoffeeVampir3
CoffeeVampir3 / error
Last active June 15, 2023 09:35
gradio-thing
Traceback (most recent call last):
File "/home/blackroot/mambaforge/lib/python3.10/site-packages/gradio/routes.py", line 437, in run_predict
output = await app.get_blocks().process_api(
File "/home/blackroot/mambaforge/lib/python3.10/site-packages/gradio/blocks.py", line 1344, in process_api
inputs = self.preprocess_data(fn_index, inputs, state)
File "/home/blackroot/mambaforge/lib/python3.10/site-packages/gradio/blocks.py", line 1194, in preprocess_data
processed_input.append(block.preprocess(inputs[i]))
File "/home/blackroot/mambaforge/lib/python3.10/site-packages/gradio/components.py", line 2463, in preprocess
sample_rate, data = processing_utils.audio_from_file(
File "/home/blackroot/mambaforge/lib/python3.10/site-packages/gradio/processing_utils.py", line 133, in audio_from_file
@CoffeeVampir3
CoffeeVampir3 / theme.js
Created June 15, 2023 00:52
llm-matrix-theme
<script>
var canvas = document.getElementById('matrixCanvas');
var ctx = canvas.getContext('2d');
canvas.height = window.innerHeight;
canvas.width = window.innerWidth;
var characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789@$%&";
characters = characters.split("");