Skip to content

Instantly share code, notes, and snippets.

View schellingb's full-sized avatar

Bernhard Schelling schellingb

View GitHub Profile
#include <ZL_Application.h>
#include <ZL_Display.h>
#include <ZL_Display3D.h>
#include <ZL_Surface.h>
#include <ZL_Input.h>
// Size of the inner screen
enum { WW = 64, WH = 64 };
// 3D Stuff
@schellingb
schellingb / RetroArch-svn-sparse-checkout.bat
Created June 22, 2020 17:39
RetroArch sparse SVN check out of just what is needed for building on Windows
svn checkout --depth files https://github.com/libretro/RetroArch.git/trunk RetroArch.git
svn update --set-depth exclude "RetroArch.git/configure"
svn update --set-depth exclude "RetroArch.git/wiiu-devel.properties.template"
svn update --set-depth exclude "RetroArch.git/Makefile"
svn update --set-depth exclude "RetroArch.git/COPYING"
svn update --set-depth exclude "RetroArch.git/Doxyfile"
svn update --set-depth exclude "RetroArch.git/Makefile.apple"
svn update --set-depth exclude "RetroArch.git/retroarch.cfg"
svn update --set-depth exclude "RetroArch.git/Makefile.classic_sega_mini"
svn update --set-depth exclude "RetroArch.git/Makefile.classic_snesc"
@schellingb
schellingb / RetroArch.vcxproj
Last active September 14, 2020 21:08
Basic RetroArch Visual Studio project file with just minimal features that should build on any Visual Studio version 2012+
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
@schellingb
schellingb / spawn_pool.js
Last active May 4, 2020 13:43
Run a maximum of X processes at the same time in a non-async node script
const fs = require('fs'), child_process = require('child_process');
function RunSync(cmd, args)
{
console.log('Running sync: ' + cmd + ' ' + args.join(' '));
const proc = child_process.spawnSync(cmd, args, {stdio:[0,1,2]});
if (proc.status === null) throw 'Error while starting ' + cmd + '. Executable not found at path or no access.';
if (proc.status !== 0) throw 'Error while running ' + cmd + '. An error should have been printed above.';
}
@schellingb
schellingb / WindowDragging.ahk
Created April 12, 2020 13:39
AutoHotkey - Easy Window Dragging - left button moves window, middle button resizes it
; Easy Window Dragging - left button moves window, middle button resizes it
ScrollLock & LButton::
ScrollLock & MButton::
CoordMode, Mouse ; switch to screen/absolute coordinates
MouseGetPos, EWD_MouseStartX, EWD_MouseStartY, EWD_MouseWin
WinGetPos, EWD_OriginalPosX, EWD_OriginalPosY, EWD_OriginalPosW, EWD_OriginalPosH, ahk_id %EWD_MouseWin%
WinGet, EWD_WinState, MinMax, ahk_id %EWD_MouseWin%
IfNotEqual, EWD_WinState, 0, return ; Do nothing if the window is maximized/minimized
SetTimer, EWD_WatchMouse, 10 ; Track the mouse as the user drags it.
return
@schellingb
schellingb / my default.vcxproj
Last active May 22, 2022 17:32
A short and readable single .vcxproj file that opens and builds in Visual Studio 2012, 2013, 2015, 2017 and 2019 with good default settings.
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" InitialTargets="DisplayText">
<PropertyGroup Label="UserMacros">
<VisualStudioYear Condition="'$(VisualStudioVersion)' == '11.0' Or '$(PlatformToolsetVersion)' == '110' Or '$(MSBuildToolsVersion)' == '4.0'">2012</VisualStudioYear>
<VisualStudioYear Condition="'$(VisualStudioVersion)' == '12.0' Or '$(PlatformToolsetVersion)' == '120' Or '$(MSBuildToolsVersion)' == '12.0'">2013</VisualStudioYear>
<VisualStudioYear Condition="'$(VisualStudioVersion)' == '14.0' Or '$(PlatformToolsetVersion)' == '140' Or '$(MSBuildToolsVersion)' == '14.0'">2015</VisualStudioYear>
<VisualStudioYear Condition="'$(VisualStudioVersion)' == '15.0' Or '$(PlatformToolsetVersion)' == '141' Or '$(MSBuildToolsVersion)' == '15.0'">2017</VisualStudioYear>
<VisualStudioYear Condition="'$(VisualStudioVersion)' == '16.0' Or '$(PlatformToolsetVersion)' == '142' Or '$(MSBuildTo
bool AreAllBitsInRangeSet(int from, int end) //check range from (inclusive) to end (exclusive)
{
int f64 = (from&~63), e64 = (end&~63);
for (int i = f64 + 64; i < e64; i += 64) { if ((ULongBitArray[i>>6]) != ~0UL) return false; }
ulong fMask = (~0UL<<(from-f64)), eMask = ((1UL<<(end-e64))-1);
if (f64 == e64) { fMask = (fMask&eMask); eMask = 0; }
return ((ULongBitArray[f64>>6] & fMask) == fMask && (eMask == 0 || (ULongBitArray[e64>>6] & eMask) != eMask));
}
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#define BufLen(b) ((b) ? _Buf__Hdr(b)->len : 0)
#define BufCap(b) ((b) ? _Buf__Hdr(b)->cap : 0)
#define BufEnd(b) ((b) ? (b)+_Buf__Hdr(b)->len : NULL)
#define BufFree(b) ((b) ? (free(_Buf__Hdr(b)), (void)((b) = NULL)) : (void)0)
#define BufClear(b) ((b) ? _Buf__Hdr(b)->len = 0 : (void)0)