Skip to content

Instantly share code, notes, and snippets.

View timoxley's full-sized avatar

Tim Kevin Oxley timoxley

View GitHub Profile
@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 January 6, 2024 19:26
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 } })
@timoxley
timoxley / index.js
Created July 27, 2018 09:45
Using Freedrum.rocks Sensors in Chrome
// Requires:
// JAZZ Plugin: https://jazz-soft.net/download/Jazz-Plugin/
// JAZZ-Midi Chrome Extension: https://chrome.google.com/webstore/detail/jazz-midi/jhdoobfdaejmldnpihidjemjcbpfmbkm
// Paste this into the Javascript console on *any* https website (sites using http won't work).
// Only works in Chrome
document.body.innerHTML = ''
async function addController () {
const serviceUuid = '03b80e5a-ede8-4b33-a751-6ce34ec4c700'
@timoxley
timoxley / .babelrc
Created May 8, 2018 11:20
Simple way to override & remove async/await regenerator transform nonsense from `babel-preset-react-app`.
{
"presets": [
"./config/babel-preset-myapp"
],
"plugins": [
"transform-class-properties"
]
}