Skip to content

Instantly share code, notes, and snippets.

/*
To address trouble with...
myList.ForEach( async x => ...do async work... )
where control returns before async operations are complete,
consider...
*/
namespace Example
{
public static async Task ForEachAsync<T>( this IEnumerable<T> list, Func<T, Task> func )
@zaqmor
zaqmor / Yield_Versus_Linq_Tests.cs
Last active December 29, 2016 20:46
Yield_Versus_Linq_Tests.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using NUnit.Framework;
[TestFixture]
public class Yield_Versus_Linq_Tests
{
[Test]
@zaqmor
zaqmor / GIT--log--filtered-by-author--pretty-print-w-author-date-message.txt
Last active October 1, 2018 21:34
GIT log, filtered by author, pretty printed with author, date, message
git log --author=name@domain.com --pretty=format:"%h%x09%an%x09%ad%x09%s"
@zaqmor
zaqmor / GIT--revert-select-files.txt
Created October 1, 2018 21:30
GIT revert select files
git checkout [commit-sha]~1 -- \path\to\file1.txt \path\to\file2.txt \path\to\file3.txt
@zaqmor
zaqmor / powershell-reverse-text-file-lines.txt
Last active March 23, 2021 09:37
Powershell: Reverse text file lines
$x = Get-Content -Path .\the\path.txt; Set-Content -Path .\the\path.txt -Value ($x[($x.Length-1)..0])
@zaqmor
zaqmor / git-log-print-to-changelog-format.txt
Created October 2, 2018 17:50
GIT Pretty Print commit history for changelog
git log --pretty=format:"%ad %s" --date=short --topo-order
@zaqmor
zaqmor / git-amend-author-name.txt
Last active October 19, 2018 02:12
Git amend author name
git commit --amend --no-edit --author="username-or-first-last <*****@*****.com>"
@zaqmor
zaqmor / git-amend-timestamp.txt
Created October 18, 2018 16:25
Git amend timestamp
git commit --amend --no-edit --date "2018-01-01 00:00:00"
@zaqmor
zaqmor / git-generate-squashed-patch-to-file-for-diffing.txt
Created October 19, 2018 17:45
Git: Generate squashed patch to file for diffing
git reset ***SHA***
git diff > c:\full\path\to\patch-file.txt
@zaqmor
zaqmor / git-get-sha-of-file-in-index.txt
Created October 22, 2018 18:59
Git: Get SHA of file in index
git ls-files -s /relative/path/to/file/in/repo.ext
# SEE https://stackoverflow.com/questions/460297/git-finding-the-sha1-of-an-individual-file-in-the-index