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>
#!/bin/bash
# store the current dir
CUR_DIR=$(pwd)
# Let the person running the script know what's going on.
echo -e "\n\033[1mPulling in latest changes for all repositories...\033[0m\n"
# Find all git repositories and update it to the master latest revision
for i in $(find . -name ".git" | cut -c 3-); do
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