Skip to content

Instantly share code, notes, and snippets.

@atifaziz
atifaziz / StaTask.cs
Created March 24, 2024 09:51
STA thread as an awaitable task
// Author: Atif Aziz
// License: This code is released by "Author" into the public domain.
using System;
using System.Threading;
using System.Threading.Tasks;
static partial class StaTask
{
public static Task RunAsync(Action action) =>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>

MoreLINQ Signatures

Legend:

x y
type Type
() void
obj object
bool bool
@atifaziz
atifaziz / ZebraPuzzleLinq.cs
Created April 16, 2023 15:42
Zebra Puzzle solution using LINQ
#nullable enable
/* Zebra Puzzle: https://en.wikipedia.org/wiki/Zebra_Puzzle
*
> The following version of the puzzle appeared in Life International in 1962:
>
> 1. There are five houses.
> 2. The Englishman lives in the red house.
> 3. The Spaniard owns the dog.
> 4. Coffee is drunk in the green house.
@atifaziz
atifaziz / Extensions.cs
Created March 1, 2023 18:40
Extension to run tasks concurrently and return an array of results when all have completed successfully
#region Copyright (c) Microsoft. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
8 REM MINNESOTA EDUCATIONAL COMPUTING CONSORTIUM STAFF
9 REM PROGRAMMING REVISIONS BY DON RAWITSCH - 1975
11 REM CURRENT VERSION - 3/27/75
15 REM **FOR THE MEANING OF THE VARIABLES USED, LIST LINES 4900-4960**
25 PRINT "DO YOU NEED INSTRUCTIONS (YES/NO)";
30 DIM C$[5]
35 INPUT C$
40 IF C$="NO" THEN 400
45 PRINT LIN(2)
59 REM ***INSTRUCTIONS***
@atifaziz
atifaziz / lorem.txt
Created October 26, 2022 19:08
50 paragraphs of Lorem Ipsum text
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris eu nibh
ultrices, commodo metus placerat, lobortis magna. Vivamus hendrerit aliquam
cursus. Nulla tempus neque tellus. Etiam euismod elit vitae odio accumsan
bibendum nec et elit. Etiam sed tincidunt nisi. Maecenas ullamcorper placerat
nulla, quis fringilla purus pharetra vel. Praesent consequat et metus quis
commodo. Maecenas fringilla consequat hendrerit. Sed imperdiet cursus nunc at
auctor. Donec ac massa orci.
Sed eget gravida lacus. Pellentesque at nibh venenatis, feugiat sapien a,
tempor augue. Nullam consequat leo et mauris dictum, et interdum erat gravida.
@atifaziz
atifaziz / ProgramArguments.cs
Created June 18, 2022 17:02
Code generated by docopt.net for grpc-curl's usage; see https://github.com/xoofx/grpc-curl
#nullable enable annotations
using System.Collections;
using System.Collections.Generic;
using DocoptNet;
using DocoptNet.Internals;
using Leaves = DocoptNet.Internals.ReadOnlyList<DocoptNet.Internals.LeafPattern>;
namespace GrpcCurl
{
@atifaziz
atifaziz / Vipr.Bootstrapper-Arguments.cs
Last active April 4, 2022 17:26
Code generated by docopt.net for Vipr's usage; see https://github.com/microsoft/Vipr
#nullable enable annotations
using System.Collections;
using System.Collections.Generic;
using DocoptNet;
using DocoptNet.Internals;
using Leaves = DocoptNet.Internals.ReadOnlyList<DocoptNet.Internals.LeafPattern>;
namespace Vipr
{