Skip to content

Instantly share code, notes, and snippets.

View ptupitsyn's full-sized avatar

Pavel Tupitsyn ptupitsyn

View GitHub Profile
@ptupitsyn
ptupitsyn / BambooDirectoryParser.csproj
Last active September 28, 2023 10:58
Bamboo directory parser
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
@ptupitsyn
ptupitsyn / Program.cs
Created August 24, 2023 14:19
.NET attach to Docker container and execute commands
using Docker.DotNet;
using Docker.DotNet.Models;
var client = new DockerClientConfiguration(new Uri("unix:///var/run/docker.sock")).CreateClient();
await client.System.PingAsync();
var imagesCreateParameters = new ImagesCreateParameters
{
FromImage = "alpine/git",
Tag = "v2.36.3"
@ptupitsyn
ptupitsyn / CheckedCastVsConvert.csproj
Last active July 13, 2023 13:55
C# checked cast vs Convert
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
@ptupitsyn
ptupitsyn / Dockerfile
Created June 15, 2023 13:05
Working .NET multi-arch Docker build (ARM + Intel)
# See https://devblogs.microsoft.com/dotnet/improving-multiplatform-container-support/
# 8.0-preview-alpine works too
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-preview AS build
ARG TARGETARCH
WORKDIR /source
# copy csproj and restore as distinct layers
COPY *.csproj .
RUN dotnet restore -a $TARGETARCH
@ptupitsyn
ptupitsyn / Dockerfile
Created June 15, 2023 06:15
.NET 8 ARM Docker build
FROM mcr.microsoft.com/dotnet/runtime:8.0-preview AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/sdk:8.0-preview AS build
WORKDIR /src
COPY dotnet-arm.csproj .
RUN dotnet restore
COPY . .
RUN dotnet build -c Release -o /app/build
@ptupitsyn
ptupitsyn / IgniteNetRestApi.csproj
Last active May 3, 2023 05:32
Ignite.NET REST API module usage
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
@ptupitsyn
ptupitsyn / Main.java
Created January 10, 2023 17:30
Apache Ignite JTA example
package org.example;
import org.apache.ignite.Ignite;
import org.apache.ignite.Ignition;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.TransactionConfiguration;
import org.apache.ignite.transactions.Transaction;
import org.apache.ignite.transactions.TransactionState;
@ptupitsyn
ptupitsyn / IgniteLinqDynamicExpr.csproj
Created November 18, 2022 05:45
Apache Ignite.NET Dynamic LINQ Expression Query
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
@ptupitsyn
ptupitsyn / Program.cs
Last active October 3, 2022 18:27
Apache Ignite.NET SQL indexes: compound, individual, parts of key and value
using Apache.Ignite.Core;
using Apache.Ignite.Core.Cache.Configuration;
using Apache.Ignite.Core.Cache.Query;
using var ignite = Ignition.Start();
var cacheCfg = new CacheConfiguration("people")
{
QueryEntities = new[]
{
@ptupitsyn
ptupitsyn / EntryProcessorComputeTask.java
Created September 14, 2022 12:24
Ignite.NET mixed cluster Cache.Invoke
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteException;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.compute.ComputeJob;
import org.apache.ignite.compute.ComputeJobAdapter;
import org.apache.ignite.compute.ComputeJobResult;
import org.apache.ignite.compute.ComputeTaskAdapter;
import org.apache.ignite.resources.IgniteInstanceResource;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;