Skip to content

Instantly share code, notes, and snippets.

using System.Collections.Concurrent;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using ConcurrencyToolkit.Pooling;
using Microsoft.Extensions.ObjectPool;
namespace Bench;
[SimpleJob(RuntimeMoniker.Net80)]
[MeanColumn, MemoryDiagnoser]
using namespace System.Management.Automation
using namespace System.Management.Automation.Language
if ($host.Name -eq 'ConsoleHost')
{
Import-Module PSReadLine
}
#Import-Module PSColors
#Import-Module posh-git
Import-Module -Name Terminal-Icons
{
"final_space": true,
"console_title": true,
"console_title_style": "folder",
"blocks": [
{
"type": "prompt",
"alignment": "left",
"horizontal_offset": 0,
"vertical_offset": 0,
@savemysoul382
savemysoul382 / ToggleButtonCheckBox.xaml
Created August 14, 2023 07:36 — forked from Platonenkov/ToggleButtonCheckBox.xaml
Toggle Button CheckBox style
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:p="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="WhiteBrush" Color="White" p:Freeze="True"/>
<!--форма переключателя-->
<ControlTemplate x:Key="ToggleButtonCheckBoxTemplate" TargetType="{x:Type CheckBox}">
<ControlTemplate.Resources>
<SolidColorBrush x:Key="ToggleButton.CheckedBackgroundBrush" p:Freeze="true">DarkBlue</SolidColorBrush>
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:p="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
xmlns:s="clr-namespace:System;assembly=mscorlib">
<DropShadowEffect x:Key="Shadow" p:Freeze="True"/>
<ScaleTransform x:Key="Scale1.1" ScaleX="1.1" ScaleY="1.1" p:Freeze="True"/>
<ScaleTransform x:Key="Scale0.9" ScaleX="0.9" ScaleY="0.9" p:Freeze="True"/>
<ScaleTransform x:Key="Scale0.7" ScaleX="0.7" ScaleY="0.7" p:Freeze="True"/>
<SolidColorBrush x:Key="DarkGrayBrush" Color="DarkGray" p:Freeze="True"/>
@savemysoul382
savemysoul382 / CustomJsonConverterForNullableDateTime.cs
Created August 14, 2023 07:34 — forked from Platonenkov/CustomJsonConverterForNullableDateTime.cs
Приведение строки к времени Parse
private class CustomJsonConverterForNullableDateTime : JsonConverter<DateTime?>
{
#region Overrides of JsonConverter<DateTime?>
public override DateTime? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
var data = reader.GetString();
if (string.IsNullOrWhiteSpace(data))
return null;
@savemysoul382
savemysoul382 / Sample.cs
Created August 14, 2023 07:33 — forked from Platonenkov/Sample.cs
Generic Method generator from reflection
var data = typeof(Program)
.GetMethod(nameof(Method))
.MakeGenericMethod(type)
.Invoke(obj : null, parameters : null);
@savemysoul382
savemysoul382 / git_commands.md
Created August 14, 2023 07:33 — forked from Platonenkov/git_commands.md
Команды GIT

Шпаргалка по консольным командам Git

Общее

Git — система контроля версий (файлов). Что-то вроде возможности сохраняться в компьютерных играх (в Git эквивалент игрового сохранения — коммит). Важно: добавление файлов к «сохранению» двухступенчатое: сначала добавляем файл в индекс (git add), потом «сохраняем» (git commit).

Любой файл в директории существующего репозитория может находиться или не находиться под версионным контролем (отслеживаемые и неотслеживаемые).

Отслеживаемые файлы могут быть в 3-х состояниях: неизменённые, изменённые, проиндексированные (готовые к коммиту).

@savemysoul382
savemysoul382 / TopMouseScrollPriorityBehavior.cs
Created August 14, 2023 07:32 — forked from Platonenkov/TopMouseScrollPriorityBehavior.cs
Mouse scroll in a scroll viewer with a datagrid or listbox and additional UI elements
public class TopMouseScrollPriorityBehavior
{
public static bool GetTopMouseScrollPriority(ScrollViewer obj)
{
return (bool)obj.GetValue(TopMouseScrollPriorityProperty);
}
public static void SetTopMouseScrollPriority(ScrollViewer obj, bool value)
{
obj.SetValue(TopMouseScrollPriorityProperty, value);
@savemysoul382
savemysoul382 / AsyncConverter.cs
Created August 14, 2023 07:31 — forked from Platonenkov/AsyncConverter.cs
Async Converter for wpf
public class AsyncConverter : MarkupExtension, IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
var task = Task.Run(async () =>
{
await Task.Delay(3000);
return "Async operation";
});
return new TaskCompletionNotifier<string>(task);