Skip to content

Instantly share code, notes, and snippets.

@RepComm
RepComm / fix_gltf_lights.gd
Last active August 24, 2024 21:53
@tool gdscript to fix godot blend/gltf light imports via hacks (iterate tree and scale light intensity when threshold met) - attach to a node3d (any will work), assign your scene root in the editor block, and restart godot, listens to scene add and init, as well as a manual boolean "fix now"
@tool
extends Node3D
@export
var scene: Node
@export
var light_energy_max: float = 200.0
@export
@RepComm
RepComm / EZAction.java
Created August 5, 2024 02:23
Android broadcast listener/receiver, but it's not annoying to use and smaller scope
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
/**Intent Broadcast receiver shit is too verbose, fixed it for ya*/
public class EZAction {
public static void Fire(Context ctx, String action) {
Intent intent = new Intent(action);
@RepComm
RepComm / cypher.html
Last active July 12, 2024 22:26
vigenere cipher experiment html app
<!DOCTYPE html>
<html>
<head>
<style>
body {
margin: 0;
height: 100svh;
padding: 0;
overflow: hidden;
@RepComm
RepComm / spring.gd
Last active June 30, 2024 02:43
2d spring implementation for godot v4 gdscript, simply assign a and b RigidBody2D, script doesn't have to be attached to rigidbodys, just needs to be in the scene
extends Node2D
@export
var a: RigidBody2D = null
@export
var b: RigidBody2D = null
@export
var a_affected: bool = false
@export
var b_affected: bool = false
@RepComm
RepComm / schema2jsdoc.d.ts
Last active August 8, 2024 16:25
pocketbase pb_schema.json to typescript definitions ( ex usage: ./schema2jsdoc.mjs > schema.d.ts ) - runs where-ever current directory is and finds pb_schema.json, outputs to stdout, pipe to a file to save, or copy paste text
export interface pb_schema_entry_schema_options {
min: number;
max: number;
pattern: string;
}
export interface pb_schema_entry_schema {
system: boolean;
id: string;
name: string;
type: string;
@RepComm
RepComm / sigterm.go
Created April 2, 2024 19:51
handle signal termination and interupt in golang
package common
import (
"os"
"os/signal"
"syscall"
)
func HandleSigTerm(cb func(sig os.Signal)) {
signalChannel := make(chan os.Signal, 2)
@RepComm
RepComm / autoappend.pb.js
Created February 4, 2024 00:02
pocketbase auto-append to container from created item.container reference
onModelBeforeCreate((e)=>{
const item_name = "responses";
const container_name = "tickets";
const container_ref = "ticket";
const container_id = e.model.get(container_ref);
if (container_id) {
@RepComm
RepComm / snippet.cs
Created February 1, 2024 05:07
Godot absolute force to rigidbody relative force
var upThrust = 1;
var forwardThrust = 2;
var absoluteForce = new Vector3 ( 0, upThrust, forwardThrust );
var relativeForce = absoluteForce * Basis.Transposed(); //The magic BS that makes it work
ApplyCentralForce( relativeForce );
@RepComm
RepComm / PhysicsHole.cs
Created January 30, 2024 03:33
Godot 4 C# physics hole cutter (does nothing visually, just disables cutLayer or re-enables it based on Area3D contact)
using Godot;
// Attach to an Area3D
// listens to collisions with area3d (use area3d's collision mask to select what objects should walk thru holes)
// sets or unsets the cutLayer (see in editor after attaching this script)
// dont forget to build C# project once to see the editor field for PhysicsHole)
public partial class PhysicsHole : Area3D {
[Export]
@RepComm
RepComm / index.ts
Created September 20, 2023 14:38
Arbitrary math function tensorflow learning
import { Tensor, layers, sequential, tensor, train } from "@tensorflow/tfjs-node";
function create_model () {
const model = sequential();
model.add(layers.dense({
units: 16,
activation: "relu",
inputShape: [1]
}));