Skip to content

Instantly share code, notes, and snippets.

View airbreather's full-sized avatar
💭
Wondering why there's a "Set status" button.

Joe Amenta airbreather

💭
Wondering why there's a "Set status" button.
  • Urban Science Applications, Inc.
  • Sterling Heights, Michigan, USA
View GitHub Profile
class A
{
public event EventHandler Foo;
public void RaiseFoo() => this.Foo?.Invoke(this, EventArgs.Empty);
}
class B
{
public int Val;
public void Subscribe(A a) => a.Foo += this.Handler;
using System;
using System.Globalization;
using System.Linq;
using System.Xml.Linq;
namespace GpxCore
{
public sealed class Gpx
{
public const string GpxNamespace = "http://www.topografix.com/GPX/1/1";
using System;
using NetTopologySuite.Features;
using NetTopologySuite.IO;
using Newtonsoft.Json.Linq;
namespace Sample
{
internal static class Program
using System;
using System.Xml;
using System.Xml.Serialization;
namespace NetTopologySuite.IO
{
public static class GpxSerialization
{
private static readonly XmlSerializer GpxSerializer = new XmlSerializer(typeof(gpxType));
using System.Runtime.InteropServices;
namespace WeirdStuff
{
[StructLayout(LayoutKind.Auto)]
public struct NullableDictKey<T> where T : struct
{
private T? value;
public NullableDictKey(T? value) => this.value = value;
/*
* Licensed to SharpSoftware under one or more contributor
* license agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* SharpSoftware licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
1>------ Build started: Project: Reminiscence, Configuration: Debug Any CPU ------
1>Build started 3/29/2017 8:51:38 AM.
1>Building with tools version "15.0".
1>Project file contains ToolsVersion="". This toolset may be unknown or missing, in which case you may be able to resolve this by installing the appropriate version of MSBuild, or the build may have been forced to a particular ToolsVersion for policy reasons. Treating the project as if it had ToolsVersion="15.0". For more information, please see http://go.microsoft.com/fwlink/?LinkId=293424.
1>Target _SetBuildInnerTarget:
1> Set Property: InnerTargets=Build
1>Target DispatchToInnerBuilds:
1> Added Item(s):
1> _TargetFramework=
1> portable40-net403+sl5+win8+wp8
@airbreather
airbreather / Program.cs
Last active February 28, 2017 12:46
volatile doesn't help you here
using System;
using System.Threading;
namespace ConsoleApp
{
internal static class Program
{
internal static readonly object lockObject = new object();
internal static volatile object obj;
@airbreather
airbreather / MemoryMappedFileEx.cs
Created January 29, 2017 12:54
Basic adapter for System.IO.MemoryMappedFiles
using System;
using System.Buffers;
using System.IO;
using System.IO.MemoryMappedFiles;
namespace AirBreather.IO
{
public static class MemoryMappedFileEx
{
public static unsafe OwnedMemory<byte> CreateFromFile(string filePath, FileMode mode, string mapName, long offset, long totalCapacity, MemoryMappedFileAccess access)
using System.Collections.Concurrent;
using System.IO.MemoryMappedFiles;
using BlockingCollection<string> coll = new();
var threads = new Thread[100];
foreach (ref var thread in threads.AsSpan())
{
thread = new Thread(RunThread) { IsBackground = true };
thread.Start(coll);