This is intended as a quick reference and showcase. For more complete info, see John Gruber's original spec and the Github-flavored Markdown info page. This cheatsheet is modified from Joshua Pekera'a cheat sheet for "Markdown Here", but this page is just GitHub Flavored Markdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal static class HttpClientExtensions | |
{ | |
internal static async Task GetAsync( | |
this HttpClient client, | |
string requestUri, | |
Stream destination, | |
IProgress<float> progress, | |
CancellationToken cancellationToken = default) | |
{ | |
using HttpResponseMessage response = await client.GetAsync( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IDistributedCache | |
{ | |
T? GetOrCreate(string key, Func<DistributedCacheEntryOptions, T> factory) | |
{ | |
var bytes = Get(key); | |
if (bytes is { Length: > 0 }) | |
{ | |
var payload = Encoding.UTF8.GetString(bytes); | |
return JsonSerializer.Deserialize<T>(payload); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Requests the navigator.mediaDevices for video input. | |
*/ | |
export async function requestVideoDevices() { | |
try { | |
// Ask the first time to prime the underlying device list. | |
let devices = await navigator.mediaDevices.enumerateDevices(); | |
if (devices && | |
(devices.length === 0 || devices.every(d => d.deviceId === ""))) { | |
await navigator.mediaDevices.getUserMedia({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// GitHub: 👨🏽💻 https://github.com/ievangelist | |
// Twitter: 🤓 https://twitter.com/davidpine7 | |
// SDK: 🛠️ https://github.com/IEvangelist/azure-cosmos-dotnet-repository | |
using System.ComponentModel.DataAnnotations; | |
using Microsoft.Azure.CosmosRepository; | |
var builder = WebApplication.CreateBuilder(args); | |
builder.Services.AddCosmosRepository(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#nullable enable | |
using System; | |
using System.Net.Http; | |
using System.Net.Http.Json; | |
using System.Text.Json; | |
JsonSerializerOptions _options = new() | |
{ | |
PropertyNameCaseInsensitive = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Extensions.DependencyInjection; | |
using Microsoft.Extensions.Hosting; | |
using Example.App; | |
using IHost host = Host.CreateDefaultBuilder(args) | |
.ConfigureServices(services => services.AddHostedService<Worker>()) | |
.Build(); | |
await host.RunAsync(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
static IEnumerable<int> Fibonacci(int max) | |
{ | |
int current = 1, next = 1; | |
while (current < max) | |
{ | |
yield return current; | |
next = current + (current = next); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.AspNetCore.Hosting; | |
using Microsoft.Extensions.Hosting; | |
using Company.WebApplication1; | |
await Host.CreateDefaultBuilder(args) | |
.ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup<Startup>()) | |
.Build() | |
.RunAsync(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public readonly struct EnumerableRange : IEnumerable<int> | |
{ | |
readonly Range _range; | |
public EnumerableRange(Range range) | |
{ | |
if (range.Start.IsFromEnd || range.End.IsFromEnd) | |
{ | |
throw new ArgumentException(nameof(range)); | |
} |
NewerOlder