Skip to content

Instantly share code, notes, and snippets.

View RepComm's full-sized avatar

Jonathan Crowder RepComm

View GitHub Profile
@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 May 16, 2024 04:08
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]
}));
@RepComm
RepComm / init.vim
Created May 15, 2023 15:43
My ~/.config/nvim/init.vim script - updated as I change it
set number
set tabstop=2
set shiftwidth=2
set expandtab
call plug#begin('~/.vim/plugged')
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'neoclide/coc.nvim', {'do': 'yarn install --frozen-lockfile'}
call plug#end()
@RepComm
RepComm / evt.ts
Created April 18, 2023 17:13
Generic Event Dispatcher in TypeScript
interface EventCallback<T> {
(evt: T): boolean|void;
}
class EventDispatcher<EventMap> {
listeners: Map<string, Set<EventCallback<keyof EventMap>>>;
constructor () {
this.listeners = new Map();