Skip to content

Instantly share code, notes, and snippets.

View xgalaxy's full-sized avatar

Robert D. Blanchet Jr. xgalaxy

View GitHub Profile
@xgalaxy
xgalaxy / gist:a446591dd5da82998799c1c534eae1ba
Created December 8, 2019 23:49
C# w/ C++ dependency properly
>
>
> You can try this one, it worked for me both from command line and VS
> (msbuild 15.7.177.53362):
> **ProjectReference in csproj:**
>
> ```
> <ProjectReference Include="..\MyVcx\My.vcxproj">
> <Project>{ProjectGuid}</Project>
> <Name>projectname</Name>
@xgalaxy
xgalaxy / memory_guidelines.md
Created February 3, 2019 19:34 — forked from GrabYourPitchforks/memory_guidelines.md
Memory usage guidelines

Memory<T> usage guidelines

This document describes the relationship between Memory<T> and its related classes (MemoryPool<T>, IMemoryOwner<T>, etc.). It also describes best practices when accepting Memory<T> instances in public API surface. Following these guidelines will help developers write clear, bug-free code.

First, a tour of the basic exchange types

  • Span<T> is the basic exchange type that represents contiguous buffers. These buffers may be backed by managed memory (such as T[] or System.String). They may also be backed by unmanaged memory (such as via stackalloc or a raw void*). The Span<T> type is not heapable, meaning that it cannot appear as a field in classes, and it cannot be used across yield or await boundaries.

  • Memory is a wrapper around an object that can generate a Span. For instance, Memory instances can be backed by T[], System.String (readonly), and even SafeHandle instances. Memory cannot be backed by "transient" unmanaged me

@xgalaxy
xgalaxy / memory_docs_samples.md
Created February 3, 2019 19:33 — forked from GrabYourPitchforks/memory_docs_samples.md
Memory<T> API documentation and samples

Memory<T> API documentation and samples

This document describes the APIs of Memory<T>, IMemoryOwner<T>, and MemoryManager<T> and their relationships to each other.

See also the Memory<T> usage guidelines document for background information.

First, a brief summary of the basic types

  • Memory<T> is the basic type that represents a contiguous buffer. This type is a struct, which means that developers cannot subclass it and override the implementation. The basic implementation of the type is aware of contigious memory buffers backed by T[] and System.String (in the case of ReadOnlyMemory<char>).
@xgalaxy
xgalaxy / Event-stream based GraphQL subscriptions.md
Created January 26, 2019 19:41 — forked from OlegIlyenko/Event-stream based GraphQL subscriptions.md
Event-stream based GraphQL subscriptions for real-time updates

In this gist I would like to describe an idea for GraphQL subscriptions. It was inspired by conversations about subscriptions in the GraphQL slack channel and different GH issues, like #89 and #411.

Conceptual Model

At the moment GraphQL allows 2 types of queries:

  • query
  • mutation

Reference implementation also adds the third type: subscription. It does not have any semantics yet, so here I would like to propose one possible semantics interpretation and the reasoning behind it.

@xgalaxy
xgalaxy / gist:d42e5e6ed01552f2dc1ed78c4539aff0
Created March 21, 2018 03:31
ScopeStack example from DICE
// Simplified scope stack implementation
// http://www.dice.se/wp-content/uploads/2014/12/scopestacks_public.pdf
#include <new>
#include <cstdio>
#include <cassert>
typedef unsigned char u8;
class LinearAllocator {
@xgalaxy
xgalaxy / .clang-format
Last active November 27, 2017 00:41
My clang format file
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-
Language : Cpp
BasedOnStyle : Google
Standard : Cpp11
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-
AccessModifierOffset : -4
BreakBeforeBraces : Stroustrup
ColumnLimit : 160
IndentWidth : 4
IndentPPDirectives : AfterHash
@xgalaxy
xgalaxy / easy.h
Created April 24, 2017 00:34
Easy preprocessor defines
// From: http://www.codersnotes.com/notes/easy-preprocessor-defines/
#define ON +
#define OFF -
#define USING(x) ((1 x 1) == 2)
// Example usage:
#define BIG_ENDIAN ON
#if USING(BIG_ENDIAN)
// do whatever
@xgalaxy
xgalaxy / gist:6743756
Last active April 24, 2019 08:40
Example of working with anonymous types in Unity3d
using System;
using System.Collections;
using UnityEngine;
public class Testing : MonoBehaviour
{
void Start()
{
// In C#, this is an 'Anonymous Type'
// A new System.Type is generated for it at compile type