Skip to content

Instantly share code, notes, and snippets.

View idea-lei's full-sized avatar

Lei idea-lei

View GitHub Profile
@idea-lei
idea-lei / AsyncFuncExtensions.cs
Created March 11, 2025 17:16
AsyncFuncExtensions
public static class AsyncFuncExtensions
{
private static async Task RunTasksAsync(IEnumerable<Task> tasks, bool throwOnFirstException = false)
{
var taskList = tasks.ToList();
if (taskList.Count == 0) return;
if (throwOnFirstException)
{
while (taskList.Count > 0)
@idea-lei
idea-lei / ShortId.cs
Last active July 9, 2025 10:16
High performance Short Id
/// <summary>
/// ShortId in string format, preferred when a GUID is overkill.
/// </summary>
public static class ShortId
{
/// <summary>
/// 32 chars (2^5). removed some chars for better readablity (i,l,o,u)
/// </summary>
private const string _chars = "0123456789abcdefghjkmnpqrstvwxyz";