Skip to content

Instantly share code, notes, and snippets.

Bernhard Schelling schellingb

Block or report user

Report or block schellingb

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@schellingb
schellingb / my default.vcxproj
Last active Jun 16, 2019
A short and readable single .vcxproj file that opens and builds in Visual Studio 2012, 2013, 2015, 2017 and 2019 with good default settings.
View my default.vcxproj
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.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>
View Bit flag array check if all bits in a range are set.cs
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));
}
View StretchyBuf.c
#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)
You can’t perform that action at this time.