Skip to content

Instantly share code, notes, and snippets.

View pavel-agarkov's full-sized avatar

Paweł Agarków pavel-agarkov

  • Sopot
View GitHub Profile
@pavel-agarkov
pavel-agarkov / kubedbg.ps1
Last active March 11, 2018 11:56
Debugging ASP.NET Core app running in Kubernetes Minikube from Visual Studio 2017 on Windows
param(
# the selector from your yml file
# selector:
# matchLabels:
# app: myweb
# -Selector app=myweb
[Parameter(Mandatory=$true)][string]$Selector
)
Write-Host '1. searching pod by selector:' $Selector '...';
@pavel-agarkov
pavel-agarkov / kubedbg.xml
Created October 1, 2017 15:32
Debugging ASP.NET Core app running in Kubernetes Minikube from Visual Studio 2017 on Windows
<PipeLaunchOptions xmlns="http://schemas.microsoft.com/vstudio/MDDDebuggerOptions/2014"
PipePath="powershell" TargetArchitecture="x64" MIMode="clrdbg"
PipeArguments="
-ExecutionPolicy Bypass
-File C:\kube\kubedbg.ps1
-Selector app=mywebapp">
<LaunchCompleteCommand>None</LaunchCompleteCommand>
</PipeLaunchOptions>
@pavel-agarkov
pavel-agarkov / marble-scheduler-injector.ts
Last active March 9, 2018 20:41
Injects TestScheduler from jasmine-marbles into time-dependent Observable operations
import "rxjs/add/operator/debounceTime";
import "rxjs/add/operator/throttleTime";
import { TestScheduler } from "jasmine-marbles/src/scheduler";
import { Observable } from "rxjs/Observable";
export class MarbleSchedulerInjector
{
static inject(scheduler: TestScheduler, ...methods: (keyof Observable<any> | "all")[])
{
methods = methods || ["all"];
@pavel-agarkov
pavel-agarkov / WebApp.csproj
Created February 1, 2018 15:12
Conditional package references
...
<Choose>
<When Condition=" '$(Configuration)'=='Test' ">
<ItemGroup>
<PackageReference Include="Moq" Version="4.8.1" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>
</When>
@pavel-agarkov
pavel-agarkov / WebApp.csproj
Created February 1, 2018 16:20
Conditional test files exclusion
...
<Choose>
<When Condition=" '$(Configuration)'!='Test' ">
<ItemGroup>
<Compile Remove="**/*.Spec.cs" />
<Compile Remove="**/*.Stub.cs" />
<Compile Remove="**/*.Stubs.cs" />
<Compile Remove="**/*.Test.cs" />
<Compile Remove="**/*.Tests.cs" />
</ItemGroup>
@pavel-agarkov
pavel-agarkov / ValuesController.Spec.cs
Created February 1, 2018 16:37
Example controller and its tests
using System.Collections.Generic;
using Xunit;
namespace WebApp.Controllers
{
public class ValuesControllerSpec : IClassFixture<ValuesController>
{
private readonly ValuesController controller;
public ValuesControllerSpec(ValuesController controller)
@pavel-agarkov
pavel-agarkov / Pipe.cs
Last active February 3, 2018 18:24
Naive C# Pipe implementation
using System;
using System.Collections.Generic;
using System.Linq;
public static class Test
{
static Test()
{
1d.Pipe(TimeSpan.FromDays, AddHours(3), ToString, ToLower);
@pavel-agarkov
pavel-agarkov / command-actions-generator.ts
Last active July 4, 2018 17:28
Example of ngrx actions generation
export interface CommandErrorPayload {
readonly errorMessage: string;
readonly originalError?: any;
}
export class StandardAction<TActionType extends string, TActionPayload> {
type: TActionType;
constructor(readonly payload: TActionPayload) { }
}
@pavel-agarkov
pavel-agarkov / kube-debug.sh
Last active February 7, 2021 12:15
Shell script to attach vsdbg to container running in kubernetes
#!/bin/bash
set -e
# echo "processing params"
while [ "$1" != "" ]; do
case $1 in
-n | --namespace)
NAMESPACE=$2
shift 2
;;
-s | --selector)
@pavel-agarkov
pavel-agarkov / launch.json
Last active September 29, 2018 21:10
VS code launch.json with configuration to attach to dotnet process running in Kubernetes
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Kubernetes",
"type": "coreclr",
"request": "attach", // we are going to attach to the existing pod
"processName": "dotnet",
"sourceFileMap": {
// mapping of source code inside a container to the source code on a host machine