Skip to content

Instantly share code, notes, and snippets.

@HaloFour
HaloFour / BenchmarkVTPattern.cs
Created May 14, 2019 01:10
BenchmarkVTPattern
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System;
namespace BenchmarkVTPattern
{
[CoreJob]
[MemoryDiagnoser]
public class Benchmark
{
@HaloFour
HaloFour / MethodTracer.scala
Last active February 22, 2019 18:36
Async Money Tracing
/*
* Copyright 2012 Comcast Cable Communications Management, LLC
*
* Licensed 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
*
* Unless required by applicable law or agreed to in writing, software
@HaloFour
HaloFour / ReferenceOps.cs
Created February 11, 2019 18:23
Reference Operators Crude Benchmark
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System;
/*
BenchmarkDotNet=v0.11.3, OS=Windows 10.0.17763.55 (1809/October2018Update/Redstone5)
Intel Xeon CPU E5405 2.00GHz, 1 CPU, 4 logical and 4 physical cores
.NET Core SDK=2.1.500
[Host] : .NET Core 2.1.6 (CoreCLR 4.6.27019.06, CoreFX 4.6.27019.05), 64bit RyuJIT
Core : .NET Core 2.1.6 (CoreCLR 4.6.27019.06, CoreFX 4.6.27019.05), 64bit RyuJIT
@HaloFour
HaloFour / JMoney.java
Created January 15, 2019 01:19
Money Java Async API
public class JMoney {
public static <T, S extends CompletionStage<T>, E extends Exception> S traceAsync(String spanName, CheckedCallable<S, E> callable) throws E {
Tracer tracer = tracer();
tracer.startSpan(spanName);
S stage;
try {
stage = callable.call();
} catch (Exception exception) {
@HaloFour
HaloFour / JMoneyTracer.java
Last active January 14, 2019 15:54
Java Money API
package com.comcast.money.japi;
import com.comcast.money.core.Money$;
import com.comcast.money.core.Note;
import com.comcast.money.core.Result;
import com.comcast.money.core.StringNote;
import com.comcast.money.core.Tracer;
public class JMoneyTracer {
private static Tracer tracer() {
@HaloFour
HaloFour / proposal.md
Created July 12, 2018 19:29
C# Language Proposal Template
  1. What kind of problem are you trying to solve?
    • How often do you find yourself running into this problem?
  2. Is this a problem that you can work around today with existing language features?
    • If so, can you write up a snippet? (link to GitHub code fencing documentation)
  3. Can you describe the new language feature and how it addresses this problem?
  4. Can you include some sample syntax for what this new language feature might look like?
  • If possible, use comments or pseudocode to explain the behavior of the feature
@HaloFour
HaloFour / LoginResource.cs
Created June 29, 2018 20:38
Data Classes, Builder with Assignment Validation
public class LoginResource {
public struct Builder {
private byte _assigned;
private string _username;
private string _password;
public string Username {
get => _username;
set {
@HaloFour
HaloFour / LoginResource.cs
Last active June 28, 2018 10:36
Data Classes with Primary Constructor
using System;
using System.Collections.Generic;
/*
* public data class LoginResource(string Username, string Password)
* {
* public bool RememberMe { get; } = true;
* }
*/
public sealed class LoginResource : IEquatable<LoginResource> {
@HaloFour
HaloFour / LoginResource.cs
Last active June 28, 2018 11:41
Data Classes
using System;
using System.Collections.Generic;
/*
* public data class LoginResource
* {
* public string Username { get; }
* public string Password { get; }
* public bool RememberMe { get; } = true;
* }
@HaloFour
HaloFour / Decomposition.cs
Last active March 7, 2016 15:19
Decomposition Microbenchmark
using System;
using System.Diagnostics;
public struct ValueTuple<T1, T2> {
public T1 Item1;
public T2 Item2;
public ValueTuple(T1 item1, T2 item2) {
this.Item1 = item1;
this.Item2 = item2;