Skip to content

Instantly share code, notes, and snippets.

// Copyright 2016 People Gotta Play. All rights reserved.
#include "ProjectMK.h"
#include "UMGExtensionLibrary.h"
UTextureRenderTarget2D * UUMGExtensionLibrary::RenderWidgetToTexture(bool UseGamma, TextureFilter Filter, UUserWidget * WidgetToRender, FVector2D DrawSize, float DeltaTime)
{
if (!WidgetToRender) return nullptr;
if (DrawSize == FVector2D(0, 0)) return nullptr;
@JonCole
JonCole / Redis-BestPractices-General.md
Last active December 2, 2025 10:45
Redis Best Practices

Some of the Redis best practices content has moved

This content from this markdown file has moved a new, happier home where it can serve more people. Please check it out : https://docs.microsoft.com/azure/azure-cache-for-redis/cache-best-practices.

NOTE: Client specific guidance listed below is still valid and should still be considered. I will update this document once all content has been moved.

@derrickturk
derrickturk / Guard.cs
Created July 8, 2016 15:29
A (kind of cruddy) scope guard for C#. The T: class constraint can be dropped at the expense of the null check.
class Guard<T> : IDisposable where T : class {
public Guard(T obj, Action<T> dispose)
{
obj_ = obj;
dispose_ = dispose;
disposed_ = false;
}
public void Dispose()
1000 iterations, 10000 samples
BitFields Style Pack: 00:00:00.0919455
BitFields Style Unpack: 00:00:00.3154235
BitConverter Pack: 00:00:00.0764927
BitConverter Unpack: 00:00:00.2149990
Direct Packing: 00:00:00.0325352
Direct Unpacking: 00:00:00.2034563
Direct Unpacking Unsafe:00:00:00.2150088
Access and Cast: 00:00:00.0308669
Access and Cast Back: 00:00:00.2004328
@zhiguangwang
zhiguangwang / README.md
Last active September 3, 2024 07:23
Building Unreal Engine Game Client and Dedicated Server on Linux.

Building Unreal Engine Game Client and Dedicated Server on Linux

Because the build tools of UE4 works across platforms (Windows, Mac OS, Linux), steps in this article can be applied to Mac OS and Windows as well.

On Windows, You need to replace RunUAT.sh with RunUAT.bat though.

Prerequisites

First, get Unreal Engine 4 sourcecode and export the following environment variables:

@grisevg
grisevg / AnimatedImage.cpp
Last active August 30, 2023 02:49
UMG Animated Image.
#include "AnimatedImage.h"
void UAnimatedImage::SetCurrentFrame(int32 Frame)
{
CurrentFrame = Frame;
if (CurrentFrame < 0) CurrentFrame = 0;
if (CurrentFrame > TotalFrames - 1) CurrentFrame = TotalFrames - 1;
SynchronizeProperties();
}
@jchildren
jchildren / LevelManager.cpp
Created December 6, 2015 21:52
Unreal engine instanced static mesh manager for floors and walls
// Fill out your copyright notice in the Description page of Project Settings.
#include "LevelGeneration.h"
#include "LevelManager.h"
// Sets default values
ALevelManager::ALevelManager() :
MaxX(10),
@mfuerstenau
mfuerstenau / zigzag-encoding.README
Last active September 1, 2025 13:16
ZigZag encoding/decoding explained
ZigZag-Encoding
---------------
Maps negative values to positive values while going back and
forth (0 = 0, -1 = 1, 1 = 2, -2 = 3, 2 = 4, -3 = 5, 3 = 6 ...)
(i >> bitlength-1) ^ (i << 1)
with "i" being the number to be encoded, "^" being
XOR-operation and ">>" would be arithemtic shifting-operation
@JonCole
JonCole / ThreadPool.md
Last active May 10, 2025 15:44
Intro to CLR ThreadPool Growth

ThreadPool Growth: Some Important Details

The CLR ThreadPool has two types of threads - "Worker" and "I/O Completion Port" (aka IOCP) threads.

  • Worker threads are used when for things like processing Task.Run(…) or ThreadPool.QueueUserWorkItem(…) methods. These threads are also used by various components in the CLR when work needs to happen on a background thread.
  • IOCP threads are used when asynchronous IO happens (e.g. reading from the network).

The thread pool provides new worker threads or I/O completion threads on demand (without any throttling) until it reaches the "Minimum" setting for each type of thread. By default, the minimum number of threads is set to the number of processors on a system.

Once the number of existing (busy) threads hits the "minimum" number of threads, the ThreadPool will throttle the rate at which is injects new threads to one thread per 500 milliseconds. This means that if your system gets a burst of work needing an IOCP thread, it will proces

@versusvoid
versusvoid / PhysInstancedStaticMeshComponent.cpp
Created April 17, 2015 10:28
InstancedStaticMeshComponent with physics support
#include "Test1.h"
#include "PhysInstancedStaticMeshComponent.h"
#include "PhysXIncludes.h"
#include "PhysicsPublic.h"
#include "Private/PhysicsEngine/PhysXSupport.h"
UPhysInstancedStaticMeshComponent::UPhysInstancedStaticMeshComponent(const FObjectInitializer& initializer)
: Super(initializer)
{