Skip to content

Instantly share code, notes, and snippets.

View jasonswearingen's full-sized avatar

JasonS jasonswearingen

  • Woodinville WA, USA
  • 04:22 (UTC -07:00)
View GitHub Profile
@jasonswearingen
jasonswearingen / run-godot-console.ps1
Created March 5, 2025 04:30
godot launcher Powershell script for developers
<#
.SYNOPSIS
Runs Godot editor and automatically restarts it if it closes.
.DESCRIPTION
This script launches the Godot editor with specified arguments, and automatically restarts it if it closes.
.PARAMETER ExePath
The path to the Godot executable. Defaults to the console version of Godot 4.4 stable.
Use the _console.exe version of godot otherwise the script won't wait while godot is running.
@jasonswearingen
jasonswearingen / json5-deserialize.cs
Last active October 9, 2024 03:34
snippet to deserialize json5 using system.text.json
//this is a snippet from my framework. you'll have to make some tiny syntax adjustments to use this.
//for details on json5, see https://json5.org/
/// <summary>
/// Preprocess a JSON5 string to convert it to valid JSON for Microsoft's System.Text.Json deserializer.
/// </summary>
/// <param name="json5String">The JSON5 string to preprocess.</param>
/// <returns>A valid JSON string.</returns>
private static string PreprocessJson5ToJson(string json5String)
{
@jasonswearingen
jasonswearingen / ImGui.NET.xml
Last active October 16, 2024 17:22
I made an intellisense xml file for imgui.net. paste it into the same dir as the nuget dll, overwrite existing. ex: `C:\Users\jason\.nuget\packages\imgui.net\1.91.0.1\lib\net8.0`
<?xml version="1.0" encoding="UTF-8"?>
<doc xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assembly>
<name>ImGui.NET</name>
</assembly>
<members>
<member name="T:ImGuiNET.ImGuiWindowFlags">
<summary>
Flags for ImGui window creation.
</summary>
@jasonswearingen
jasonswearingen / PhotoBooth.cs
Last active October 5, 2024 15:07
PhotoBooth: Render Images of 3D objects in-game.
//This code utilizes some of my private godot c# scafolding, so unfortunately you can't just copy/paste it.
// but the workflow is general to godot 4.3, so just follow the _Setup() workflow and then the workflow to use it is
// - AddToStage()
// - TakePicture()
// - ClearStage()
/// <summary>
/// PhotoBooth class represents a virtual photo booth for capturing images of 3D scenes.
/// It uses a separate scene with a Viewport to render the content, allowing snapshots to be taken with different configurations.
/// </summary>
@jasonswearingen
jasonswearingen / zz_Extensions_CustomCollision.cs
Last active August 10, 2024 17:49
Godot CSharp Custom Collision Detection, including depth
//godot physics collison detection does not provide collision depth
//this code performs manual collision detection and geenerats depth also.
//this code has not been optimized, but should be relatively fast as it does all calculations in c# (no crossing to native)
//IF YOU FIND THIS CODE USEFUL AND WOULD LIKE A REPO: leave a comment and I can consider putting my entire (custom csharp) framework up.
using Godot;
public static class zz_Extensions_Shape3D_Collisions
{
private const float EPSILON = 1e-6f;
@jasonswearingen
jasonswearingen / HumanoidAnimation.cs
Created July 25, 2024 15:55
My custom humanoid animation, root motion calculations
using AutoMapper.QueryableExtensions.Impl;
using Godot;
using GodotEx;
namespace NotNot.GodotNet.animation;
/// <summary>
/// convert any humanoid animation to root motion, and be able to save to disk.
/// </summary>
[Tool]
@jasonswearingen
jasonswearingen / Event.cs
Created January 26, 2023 16:27
C# Event abstraction
/// <summary>
/// thread safe event registration and invoking.
/// subscriptions are stored as weakRefs so they can be garbage collected.
/// </summary>
/// <typeparam name="TEventArgs"></typeparam>
public class Event<TEventArgs> where TEventArgs : EventArgs
{
private List<WeakReference<EventHandler<TEventArgs>>> _storage = new();
/// <summary>
@jasonswearingen
jasonswearingen / proxy.ts
Created January 31, 2019 19:47
toy proxy for NodeJs (http+https support)
//from: https://stackoverflow.com/a/49864522/1115220 re question: https://stackoverflow.com/questions/8165570/https-proxy-server-in-node-js
import http = require( 'http' )
const port: number = Number.parseInt( process.env.PORT ) || 9191;
import net = require( 'net' )
import url = require( 'url' )
import xlib = require( "xlib" );
@jasonswearingen
jasonswearingen / gcloud.d.ts
Last active September 29, 2022 08:28
typescript definitions for gcloud datastore, v0.27.0 complete, but not yet tested/verified.
export interface IModuleImport {
(authOptions?: IAuthOptions): IGCloud;
}
export interface IAuthOptions {
projectId?: string;
keyFilename?: string;
}
@jasonswearingen
jasonswearingen / redux-simple-router-example.tsx
Last active October 31, 2017 19:37
A simplified example of redux + redux-simple-router using Typescript
/**
WHAT: A very simple example of redux + redux-simple-router using Typescript.
WHY: The official example found here: https://github.com/rackt/redux-simple-router/tree/1.0.2/examples/basic has problems:
1) it is spread over many files making it very hard to "skim"
2) it is organized by function, not by feature. (Example: learning "how to manipulate redux state" is spread over 5 files in 4 folders)
3) there are no comments explaining what's going on/why.
WHO: by [email protected]