Skip to content

Instantly share code, notes, and snippets.

View timoxley's full-sized avatar

Tim Kevin Oxley timoxley

View GitHub Profile
@timoxley
timoxley / GetValidComponentByClass.h
Last active November 7, 2024 07:02
Quick GetValidComponentByClass for Blueprint, with exec pins based on validity
UCLASS()
class MY_API UMyUtils : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(
BlueprintCallable,
meta = (
ComponentClass = "/Script/Engine.ActorComponent",
@timoxley
timoxley / CreateWidgetTask.cpp
Last active November 7, 2024 05:03
Create Widget Task - Unreal Engine State Tree Task with static SendStateTreeEvent function for sending events from widgets
// inspired by https://unrealist.org/dev-log-03-statetree-isnt-just-for-ai/
#include "CreateWidgetTask.h"
#include "StateTreeExecutionContext.h"
#include "Blueprint/UserWidget.h"
#include UE_INLINE_GENERATED_CPP_BY_NAME(CreateWidgetTask)
TMap<UUserWidget*, FOnStateTreeEvent> UStateTreeWidgetTask::WidgetEventDelegateMap;
@timoxley
timoxley / MyGameEditorModule.cpp
Created January 24, 2024 17:11
Auto-generate custom sections for your game + use emoji in custom section name
static const FName PropertyEditor("PropertyEditor");
void FMyGameEditorModule::InitCategories()
{
FPropertyEditorModule& PropertyModule = FModuleManager::GetModuleChecked<FPropertyEditorModule>(PropertyEditor);
for (const auto* const Class : TObjectRange<UClass>())
{
if (!Class->GetClassPathName().ToString().StartsWith("/Script/MyGame")) { continue; }
@timoxley
timoxley / ideavim.vimrc
Last active October 14, 2024 04:17
Fix annoyances with ideavim e.g. bells, clipboard
" .ideavimrc
set noerrorbells visualbell t_vb= " Disable annoying bells.
filetype plugin indent on " Enable automatic filetype detection, filetype-specific plugins/indentation
set encoding=utf8 " Set encoding to UTF-8 to show glyphs
scriptencoding utf8
set nocompatible " Don't need to keep compatibility with Vi
set nocp " Don't need to keep compatibility with Vi
set hidden " Allow hiding buffers with unsaved changes
set listchars=trail:·,precedes:«,extends:»,tab:▸\ " Change the invisible characters, no eol
@timoxley
timoxley / error.log
Created March 22, 2022 14:06
"!UberGraphFramePointerProperty == !UberGraphFunction"
022-03-22 09:53:27.364952-0400 UnrealEditor[90322:4884359] [UE] Ensure condition failed: !UberGraphFramePointerProperty == !UberGraphFunction [File:/Users/timoxley/Projects/libs/UnrealEngine5/Engine/Source/Runtime/Engine/Private/BlueprintGeneratedClass.cpp] [Line: 1357]
2022-03-22 09:53:27.365339-0400 UnrealEditor[90322:4884364] [UE] [2022.03.22-13.53.27:364][417]LogOutputDevice: Warning:
Script Stack (0 frames):
2022-03-22 09:53:27.378940-0400 UnrealEditor[90322:4884364] [UE] [2022.03.22-13.53.27:378][417]LogStats: FPlatformStackWalk::StackWalkAndDump - 0.013 s
2022-03-22 09:53:27.379471-0400 UnrealEditor[90322:4884359] [UE] [2022.03.22-13.53.27:379][417]LogOutputDevice: Error: === Handled ensure: ===
2022-03-22 09:53:27.379828-0400 UnrealEditor[90322:4884359] [UE] [2022.03.22-13.53.27:379][417]LogOutputDevice: Error:
2022-03-22 09:53:27.380201-0400 UnrealEditor[90322:4884359] [UE] [2022.03.22-13.53.27:379][417]LogOutputDevice: Error: Ensure condition failed: !UberGraphFramePointerProperty == !UberGraphFu
@timoxley
timoxley / WebStreamToNodeStream.ts
Created November 16, 2021 18:33
Convert browser ReadableStream to Node stream.Readable.
import { PassThrough, Readable, once, TransformOptions } from 'stream'
/**
* Write to stream.
* Block until drained or aborted
*/
async function write(stream: PassThrough, data: any, ac: AbortController) {
if (stream.write(data)) { return }
await once(stream, 'drain', ac)
}
@timoxley
timoxley / generator-return-deadlock.js
Last active July 14, 2021 18:10
generator return deadlock
const assert = require('assert')
class Generators {
items = new Map()
add(id) {
const gen = generate(this, id)
this.items.set(id, gen)
return gen
}
@timoxley
timoxley / promise-unhandled-why.js
Last active July 13, 2021 17:03 — forked from mafintosh/promise-unhandled-why.js
promise-unhandled-why.js
start()
async function start () {
const promises = [
new Promise((resolve, reject) => setTimeout(() => reject(0), 1000)),
Promise.reject(1),
Promise.reject(2)
]
promises.forEach(p => p.catch(() => {})) // prevent unhandled
const Emitter = require('events')
const emitter = new Emitter()
// Currently, (Node v14.12.0) this just prints 'iterating', waits a moment, then silently exits 0.
// But adding at least one event triggers the full flow of: iterating, caught, finally, rejected
// thinking maybe throw() should call errorHandler?
;(async () => {
const it = Emitter.on(emitter, 'test')
setTimeout(() => {
// emitter.emit('test') // uncomment to trigger full error flow
@timoxley
timoxley / todoMachine.js
Last active July 20, 2022 19:39
XState list processing machine
export function todoMachine ({ contextKey, task, ...opts }) {
return {
...opts,
initial: 'run',
states: {
run: {
invoke: {
src: (ctx, event) => (fn) => {
const itemDone = (key) => (data) => {
fn({ type: 'itemDone', data: { key, data } })