Skip to content

Instantly share code, notes, and snippets.

// zero-copy BinaryData creation from MemoryStream
var stream = new MemoryStream();
stream.Write([1, 2, 3]); // some data is written to the memory stream
stream.Flush();
// this requires a memory copy
var dataViaStreamCopy = BinaryData.FromStream(stream);
// this does not require a memory copy
@skolima
skolima / hosts
Created November 25, 2024 20:01
Block Reddit host file
0.0.0.0 reddit.com
0.0.0.0 www.reddit.com
Write-Output "Pulling in latest changes for all repositories..."
# Find all git repositories and update it to the master latest revision
Get-ChildItem -Directory -Recurse -Force -Filter ".git" | ForEach-Object {
Write-Output "Checking " $_.FullName
Push-Location -Path $_
# We have to go to the .git parent directory to call the pull command
Set-Location ..
@skolima
skolima / Directory.Build.props
Created May 4, 2020 09:47
Publishing valid SourceLink via GitHub Actions: best practices Directory.Build.props
<Project>
<PropertyGroup>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<!-- SourceLink starts here -->
<PropertyGroup>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
#!/usr/bin/env bash
# Fast-forward every git repo immediately under $PWD on its default branch.
# Skips repos with uncommitted changes, no `origin` remote, or a `.git` file
# (i.e. worktrees — only the host repo gets updated).
yellow=$'\e[33m' red=$'\e[31m' green=$'\e[32m' reset=$'\e[0m'
shopt -s nullglob
for repo in */.git/; do
dir=${repo%/.git/}
using System;
using System.Collections.Generic;
using NodaTime;
using NodaTime.Extensions;
using Xunit;
namespace DaylightSavingTimeTests
{
public class DstCalculationsTests
{
using System;
using System.Collections.Generic;
using Xunit;
namespace DaylightSavingTimeTests
{
public class DstCalculationsTests
{
[Theory]
[MemberData(nameof(DstTestCases))]
@skolima
skolima / dotnet-test-and-publish.yml
Last active March 20, 2020 16:12
Run dotnet test; if on branch master, also build and publish NuGet package to GitHub Package Registry
name: Run .NET Core tests
on: [push]
jobs:
build:
name: Build and test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-dotnet@v1
- run: dotnet test
@skolima
skolima / dotnet-publish-nuget.yml
Last active March 20, 2020 16:11
Build and publish NuGet package to GitHub Package Registry
name: Build and publish NuGet package to GPR
on: [push]
jobs:
nuget-publish:
name: Publish package to GPR
runs-on: ubuntu-latest
steps:
- uses: einaregilsson/build-number@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
@skolima
skolima / dotnet-tests.yml
Last active March 20, 2020 16:08
Build and run tests for .NET Core project using GitHub Actions
name: Run .NET Core tests
on: [push]
jobs:
build:
name: Build and test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-dotnet@v1
- run: dotnet test