Skip to content

Instantly share code, notes, and snippets.

View richlander's full-sized avatar

Rich Lander richlander

View GitHub Profile
@richlander
richlander / RyuJIT-Install-Instuctions.md
Created August 18, 2014 17:26
Instructions to Install and Use RyuJIT

Try RyuJIT -- Your code runs faster on X64 Windows

How to enable RyuJIT

Download and install RyuJIT now.

RyuJIT only works on 64-bit editions of Windows Vista and Windows Server 2008 and later.

After installation, there are two ways to turn on RyuJIT. If you just want to enable RyuJIT for one application, set an environment variable:

@richlander
richlander / rlander-bio.md
Last active September 4, 2020 20:50
Richard Lander Bio

Richard Lander Bio

Richard Lander is a Principal Program Manager on the .NET team at Microsoft. He works on making .NET work great in the cloud, in memory-limited Docker containers, and on ARM hardware like the Raspberry Pi. He is part of the design team that defines new .NET runtime capabilities and features. Richard also focuses on making the .NET open source project a safe inclusive place for people to learn, do interesting projects and develop their skills. He also writes extensively for the .NET blog. Richard reported for work at Microsoft in 2000, having just graduated from the University of Waterloo (Canada) with an Honours English degree, with intensive study areas in Computer Science and SGML/XML Markup Languages. In his spare time, he swims, bikes and runs and enjoys using power tools. He grew up in Canada and New Zealand.

More info on .NET

@richlander
richlander / dotnetcore-contributor-model.md
Last active July 20, 2021 16:51
.NET Core Contributor Model

.NET Core Contributor Model

The .NET Core project has three levels of contributors.

  • All GitHub users: Read access to code and issues. Can participate in pull request code reviews, comment on issues, create new issues, and submit pull requests for review.
  • "Project contributor" - Can be assigned issues and @referenced. Part of the dotnet-community team. Provided based on frequent contributions or upon request1.
  • "Project committer" - Has repo committer access. Can merge PRs, assign people on issues, create branches, .... Currently only MSFT people, but will likely include other folks in the future.

1Requires that a .NET Foundation CLA has been signed.

@richlander
richlander / AppContextUsage.cs
Created April 29, 2015 22:33
App Context Usage
bool shouldThrow;
if (!AppContext.TryGetSwitch(“Switch.AmazingLib.ThrowOnException”, out shouldThrow))
{
// The switch value was not set by the application.
// As a result, the value is 'false'. A false value implies the latest behavior.
// The library can declare a default value for a switch based on a condition
// Example: https://github.com/dotnet/coreclr/blob/master/src/mscorlib/src/System/AppContext/AppContextDefaultValues.Defaults.cs
}
@richlander
richlander / list.cs
Last active August 29, 2015 14:23
Code sample with documented output
using System;
using System.Collections.Generic;
public class Program
{
public static void Main()
{
// Demonstrates common uses of List<T>.
// Doc: https://msdn.microsoft.com/library/6sh2ey19.aspx
@richlander
richlander / AsyncLocal.cs
Created July 17, 2015 20:57
AsyncLocal<T> sample
using System;
using System.Threading;
using System.Threading.Tasks;
class AsyncLocal
{
static AsyncLocal<string> _asyncLocalString = new AsyncLocal<string>();
static ThreadLocal<string> _threadLocalString = new ThreadLocal<string>();
static async Task AsyncMethodA()
@richlander
richlander / ComputeSumsWithSIMD.cs
Created July 20, 2015 05:16
Compute the sums of the values in two arrays of integers, with Vector<T>
// Task: Compute the sums of the values in two arrays of integers, A and B.
// Traditional approach:
for (int i = 0; i < size; i++)
{
C[i] = A[i] + B[i];
}
// With Vector<int> you can instead do this:
@richlander
richlander / dotnet-crypto-46.cs
Last active June 4, 2022 18:45
.NET Cryptography Updates for the .NET Framework 4.6
// Example 1: Signing a byte[] using PKCS#1 v1.5 padding and a SHA-256 hash
// 4.5:
public static byte[] SignDataPkcs1Sha256(X509Certificate2 cert, byte[] data)
{
// X509Certificate2.PrivateKey returns the same object across multiple calls,
// so it shouldn't be Disposed independent of the X509Certificate2 object.
//
// The RSA base class doesn't expose any signature-based methods.
// The PrivateKey property returns AsymmetricAlgorithm, so really this call should be
@richlander
richlander / constructors.fs
Created July 20, 2015 17:23
Constructors as first-class function values
// old approach
let makeStrings chars lens =
List.zip chars lens
|> List.map (fun (char, len) -> new System.String(char, len))
// new approach
let makeStrings' chars lens =
List.zip chars lens
|> List.map System.String // use ctor as function
@richlander
richlander / simplified-mutable-values.fs
Created July 20, 2015 17:24
Simplified mutable values
// old approach - need a `ref` value
let sumSquares n =
let total = ref 0
{ 1 .. n } |> Seq.iter (fun i ->
total := !total + i*i
)
!total
// new approach - `mutable` just works
let sumSquares' n =