Skip to content

Instantly share code, notes, and snippets.

@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();
@RepComm
RepComm / gofaster.sh
Created April 4, 2023 14:06
y mac so slo tho
# first, turn off anything that has adobe in the task name to get some instant speed boosts
echo Ending tasks with Adobe in the name
ps -A | grep Adobe | cut -f2 -d" " - | xargs kill
echo Done
echo Currently running tasks with Adobe in the name:
ps -A | grep Adobe | xargs echo
@RepComm
RepComm / urlquery.ts
Created March 30, 2023 13:51
Decompose/recompose URL to/from query params, including an allowed keys filter, and duplicate key support
export interface QueryInfo {
[key: string]: string|Array<string>;
}
export interface URLInfo {
base: string;
query: string;
queryParams: QueryInfo;
}
export function decomposeUrl (urlStr: string, allowDuplicateParamKeys: boolean = true) {
@RepComm
RepComm / _1d_2d_index_conversion.ts
Created December 13, 2022 22:54
Treat a 1d array as a 2d array by changing number space, save memory and performance
/** x and y are your 2d coordinates, width is the width of your chunk, all should be integers
* Returns an integer inside of an 1d array with size (width*height)
*/
export function _2dTo1d (x: number, y: number, width: number) {
return x + width * y;
}
/** given an index in an array w/ size (width * height) and the width of the chunk
* Returns the X coordinate inside the width, height of the chunk
*/
@RepComm
RepComm / JSON.java
Created October 7, 2022 15:53
JSON stringify / parse in java
package comm.rep.json;
import java.util.*;
import static comm.rep.json.Lexer.lex;
public class JSON {
public static class JsonValue {
}
@RepComm
RepComm / MouseHandler.java
Created October 6, 2022 14:30
Make using MouseListener and MouseMotionListener not painful, use lambas!
package comm.rep;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
/**
* Make using MouseListener and MouseMotionListener not painful, use lambas!
*
* Example:
@RepComm
RepComm / ElytraModel.java
Created August 14, 2022 18:51 — forked from samsartor/ElytraModel.java
Code for simulating the elytra item in Minecraft
/**
* An accurate simulation of the elytra item as of Minecraft 15w41b
*/
public class ElytraModel
{
public int glideTime;
public int damageTaken;
public double posX;
public double posY;