Skip to content

Instantly share code, notes, and snippets.

@NPatch
NPatch / obsidianmd_templater_previousnextfix.txt
Last active December 17, 2023 19:43
[obsidian.md] user script for finding the previous daily note and updating its Next link too.
function ctimeComparer(a, b)
{
if (a.stat.ctime < b.stat.ctime) {
return 1;
} else if (a.stat.ctime > b.stat.ctime) {
return -1;
}
// a must be equal to b
return 0;
}
@NPatch
NPatch / raylib_renderdoc_integration.md
Last active September 29, 2022 17:55
raylib RenderDoc integration

Apart from copying the renderdoc.dll and renderdoc_api.h files from RenderDoc installation path, into the raylib project, we also need to create two files, a cpp and a header. I call them raylib_renderdoc.h and raylib_renderdoc.cpp.

In the header we add:

/**********************************************************************************************
*
*   RenderDoc integration
@NPatch
NPatch / mem_profiler_texture_info_extension.md
Last active March 24, 2022 00:54
MemoryProfiler texture info

Cut/Move the com.unity.memprofiler folder from /Library/PackageCache to /Packages and remove the com.unity.memprofiler entry from the manifest in the same folder. This prevents PackageManager to reset any changes you make and lets you edit the code normally.

Under Packages/com.unity.memprofiler.../Editor/UI, edit SelectedItemDetailsForTypesAndObjects.cs

Add the following usings:

using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering;
@NPatch
NPatch / CustomEditorDrawerPropertySerializationScheme.txt
Last active December 9, 2016 09:55
Custom Editor/Drawer property serialization per instance
At this point, creating custom editor scripts or custom drawers for specific classes and having the ability to keep editor/drawer only properties serialized is to create a helper class or helper fields inside the class we are trying to draw , wrapped with
#if UNITY_EDITOR
#endif
and grabbing it as SerializedProperties inside the custom editor/drawer script and at the end of the process, write back all changes.
If we have lots of classes around and we want to do fancy stuff and have drawers/editors for many of them and having them blend
with eachother to achieve reuse etc, it becomes quite combersome towards the size of the codebase just for editor stuff.
The problem currently is that we can't differentiate between instances of a single type. If we could differentiate we would be
able to pinpoint any such property , eg a foldout in a drawer for X type, by querying some form of database(be it an actual database or an asset or a dictionary in memory) about the properties for that instance and then for the fie
@NPatch
NPatch / 2way_circ_index_trav_without_ifs
Last active September 1, 2016 20:30
TwoWay Circular Index Traversal in Buffers without IF statements
Lets say we have a one dimensional List with objects/primitives/whatever and inside that one dimensional List
,there are several non fixed length one dimensional Lists.
Say we know the starting index and length of each of the sublists and we want to have circular traversal with wraparound
using the same index for all lists and whenever we want, we change the sublist, we can still traverse without ifs and circular.
Finally, we also want to be able to traverse both forwards and backwards.
An example:
SuperList(0,16) => where first param is start_index and second param is length
//MUST have a valid window created to obtain a correct HMONITOR from the window's hWnd. Console windows don't give a correct HMONITOR.
//Neither did it work by calling GetConsoleWindow to get a hWnd for a console application and querying the HMONITOR from the console hWnd.
//Monitor from Window
HMONITOR monitor_handle = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
MONITORINFOEX monitor_info;
monitor_info.cbSize = sizeof(MONITORINFOEX);
GetMonitorInfo(monitor_handle, &monitor_info);