Skip to content

Instantly share code, notes, and snippets.

@qbit86
qbit86 / Amalgam.csproj
Created June 13, 2018 23:06
Amalgamation
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<!-- https://stackoverflow.com/questions/15858710/how-concatenate-files-in-msbuild-and-preserve-tabs-and-spaces -->
<Target Name="ConcatenateScripts" AfterTargets="Build">
<ItemGroup>
<ConcatFiles Include="@(Compile)" />
<ConcatFiles Remove="obj/**/*.cs" />
@qbit86
qbit86 / type-inference.cpp
Last active December 15, 2016 20:44
Type Inference in C++11
int original = 42;
decltype(original) copy = original;
decltype((original)) reference = original;
original = 1729;
std::cout << copy << std::endl; // 42
std::cout << reference << std::endl; // 1729
namespace Machinery
{
abstract class StateBase<TInput>
{
public event EventHandler<TInput> InputRequested;
public virtual void Enter(StateBase<TInput> oldState, TInput input) { }
public virtual void Exit(StateBase<TInput> newState, TInput input) { }
public abstract ReactionBase<TInput> React(TInput input);
}
{
{
{
{
Tabs are amazing.
}
}
}
}
@qbit86
qbit86 / Promise
Created June 24, 2015 21:57
Promise
using System;
namespace Squisqula
{
public sealed class Promise<T>
{
public void SetResult(T result)
{
_result = new T[] { result };
var handler = Completed;
@qbit86
qbit86 / Disposable
Created June 24, 2015 20:51
Disposable Pattern
public /*non-sealed*/ class Foo : IDisposable
{
public /*implicitly sealed*/ void Dispose()
{
Console.WriteLine("Disposing Foo managed resources.");
DisposeFooCore();
}
protected virtual void DisposeFooCore() { }
@qbit86
qbit86 / Future
Last active August 29, 2015 14:23
Future
using System;
namespace Squisqula
{
public class Future<T>
{
public bool IsCompleted { get { return _isCompleted; } }
public T Result
{