Empty string is falsy, non-empty string is truthy.
# prints "b" only.
if "":
print("a")
if "x":
using System.Reflection; | |
namespace BindingRedirectHelper; | |
// I am a .NET 8+ console app. | |
internal class Program | |
{ | |
static void Main(string[] args) | |
{ | |
if (args.Length != 1) |
ng new project-name-goes-here
This will create a new folder and set up an empty project there.
ng serve --open
Will serve the application and open the default web browser to it.
This is null safe for Items
in this example. 40x Faster than using ?.Any()
in a microbenchmark when Items is not null but could be empty. In cases where the list will typically be null, ?.Any()
measured about 10x faster, but these are all sub-nanosecond measurements and neither has any allocations.
public class Foo
{
public List<int>? Items { get; set; }
This repo contains some code snippets that I've found useful related to Ruby and Rails
These are the Homebrew packages I have used:
brew install --cask visual-studio-code
brew install --cask github
brew install --cask firefox
brew install gh
brew install docker
param ( | |
[Parameter(Mandatory=$true)][string]$sourceFile, | |
[string]$outputFile="" | |
) | |
$MAX_LINE_LENGTH = 16000000; | |
if ($outputFile -eq "") { | |
$outputFile = '{0}.ps1' -f ($sourceFile) | |
} |
using ProtobufExample.Protos; | |
using System; | |
namespace ProtobufExample | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var product = new Product { Id = 2, Description = "Fun product" }; |
using Autofac; | |
using Microsoft.Extensions.Configuration; | |
using Microsoft.Extensions.Primitives; | |
using System; | |
using System.Collections.Generic; | |
using System.Threading; | |
// You must add the `Autofac` and `Microsoft.Extensions.Configuration` NuGet packages for this to work | |
namespace AutofacDemo |