Skip to content

Instantly share code, notes, and snippets.

@nohwnd
nohwnd / .NET meetup 2024.md
Last active November 14, 2024 12:08
.NET Meetup 2024
@nohwnd
nohwnd / try.ps1
Created June 11, 2024 07:24
Avoid unapproved verb warning
Get-Module unapproved-verb, warning | Remove-Module
# this won't warn, we mutated the approved verbs list
Import-Module $PSScriptRoot\unapproved-verb.psm1
# we clean up after ourselves in few seconds
Write-Host waiting...
Start-Sleep -Seconds
# this will warn again

Getting to the conference

Prague has amazing public transport system, it is clean, convenient, and cheap way to get from point A to B, including from airport to city center. Prague public transport includes buses, trams, subway (metro), and some trains, boats, and also a funicular.

Tickets for Prague public transport can be bought in yellow machines, directly in trams and some busses, and more conveniently via PID Litacka app available for both iPhone and Android: https://app.pidlitacka.cz/

In the application you want to select Tickets > Buy a ticket > Prague

Tickets start at 30 CZK per single 30 minute ride for adult, but we recommend 330 CZK (14 EUR) 72 hour ticket, or 120 CZK (5 EUR) 24 hour ticket, if you plan to explore Prague a little bit.

@nohwnd
nohwnd / UnitTest1.cs
Last active April 8, 2022 05:57
MSTest parallel output demo
using System.Diagnostics;
using Microsoft.VisualStudio.TestTools.UnitTesting;
[assembly: Parallelize(Workers = 0, Scope = ExecutionScope.MethodLevel)]
namespace mstest;
[TestClass]
public class UnitTest1
{
@nohwnd
nohwnd / Internal.cs
Created August 6, 2021 10:09
Find internal classes
using System;
using System.Linq;
using System.Reflection;
namespace ConsoleApp28
{
class Program
{
static void Main(string[] args)
{
@nohwnd
nohwnd / script-block-local.ps1
Created July 2, 2021 07:49
scriptblock local storage
# create a scriptblock that has scriptblock local data attached (data common to all invocation of the scriptblock)
# but is still bound to the same session state, this is differnt from closure, because closures are their own modules
$sb = {
$location
$self = $MyInvocation.MyCommand.ScriptBlock
($self.___data.Count++)
}
$sb.PSObject.Properties.Add([System.Management.Automation.PSNoteProperty]::new("___data", @{ Count = 1}))
@nohwnd
nohwnd / get-testparents.ps1
Last active June 21, 2021 10:38
Get-TestParents
function Get-TestParents {
<#
.SYNOPSIS
Returns any parents not already known, top-down first, so that a hierarchy can be created in a streaming manner
#>
param (
#Test to fetch parents of. For maximum efficiency this should be done one test at a time and then stack processed
[Parameter(Mandatory,ValueFromPipeline)][Pester.Test[]]$Test,
[HashSet[Pester.Block]]$KnownParents = [HashSet[Pester.Block]]::new()
@nohwnd
nohwnd / run.ps1
Last active May 16, 2021 14:01
Compare CC in Pester
$c = New-PesterConfiguration
# your Path
$c.Run.Path = "."
$c.Run.PassThru = $true
# detailed prints the CC report, but that is very verbose
# use only for tiny codebases
# $c.Output.Verbosity = "Detailed"
@nohwnd
nohwnd / .gitignore
Last active October 29, 2021 12:39
Use Pester code coverage with CoverageGutters in VSCode
coverage.xml
# ModuleName defines in which session state the mock will be effective, not in which module the function was defined.
# This is important when mocking functions exported from a module either when calling them from a script, or when calling
# them from a different module. In that case you want to define the mock in the place where the function is called from,
# not in the module where the function is defined.
# The only time you want to define the mock in the module where the function is defined is when you are testing an internal
# functions of the module (not shown here).
Invoke-Pester -Container (
New-PesterContainer -ScriptBlock {
BeforeAll {
Get-Module m, n, o | Remove-Module