Results for “New-Item”
Small, practical examples. Search by task or narrow things down below.
Correct the latest unpublished commit message
Git: Amend replaces the current commit while preserving its tree when no new changes are staged.
Git✓ Tested
Count lines in a file
Count newline characters in a text file, printing only the count without the filename.
lines✓ Tested
Count words with GroupBy
Group repeated C# words and print ordered counts.
C#✓ Tested
Create a file only when it does not exist
C#: FileMode.CreateNew prevents accidental replacement of existing content.
C#✓ Tested
Create and switch to a branch
Start an isolated feature branch from the current commit.
switch✓ Tested
Create nested directories
Create a directory tree using the .NET Directory API.
C#✓ Tested
Delegate iteration to another iterable
JavaScript: yield-star forwards items from another iterable while retaining generator composition.
JavaScript✓ Tested
Delegate iteration to another iterable
TypeScript: yield-star forwards items from another iterable while retaining generator composition.
TypeScript✓ Tested
Delete one known scratch file
C++: filesystem::remove reports whether an item was removed and also supports empty directories.
C++✓ Tested
Distinguish a file from a directory
PowerShell: Test-Path can constrain the kind of item that is accepted.
PowerShell✓ Tested
Filter a list with a condition
Build a new list containing only the values that satisfy a condition using a list comprehension.
list✓ Tested
Filter and transform an array
Keep active objects and extract their names.
filter✓ Tested