Skip to content

Instantly share code, notes, and snippets.

View Zonciu's full-sized avatar
💭
I may be slow to respond.

Zonciu Liang Zonciu

💭
I may be slow to respond.
View GitHub Profile
@Zonciu
Zonciu / GrainPrimaryKeyExtensions
Created October 30, 2020 08:20
Get Grain PrimaryKey
public static class GrainExtensions
{
/// <summary>
/// Get string Id
/// </summary>
/// <param name="grain"></param>
/// <returns></returns>
public static string GetId(this IGrainWithStringKey grain) => grain.GetPrimaryKeyString();
/// <summary>
@Zonciu
Zonciu / FixedArray8
Created April 28, 2019 14:33
Fixed length array, available for unmanaged type
[StructLayout(LayoutKind.Sequential)]
public struct FixedArray8<T>
where T : unmanaged
{
public T Value0;
public T Value1;
public T Value2;
@Zonciu
Zonciu / GetSVGPoint
Created March 15, 2019 08:47
Calculate point's real position after svg transforming.
/**
*
*
* @param {SVGSVGElement} svg: root svg element
* @param {number} x
* @param {number} y
* @param {SVGMatrix} ctm: element.getScreemCTM()
* @returns {SVGPoint} real position in container
*/
@Zonciu
Zonciu / netcore3-wpf-designer
Created March 3, 2019 06:44
WPF designer project configuration in net core 3
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net472' ">
<Reference Include="System" />
<Reference Include="System.Data" />
@Zonciu
Zonciu / netcore3-winform-designer
Last active November 14, 2019 08:45
WinForm designer in net core 3, no need to create another .net framework project and link files
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks>
<UseWindowsForms>true</UseWindowsForms>
<LangVersion>7.3</LangVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net472' ">
<Reference Include="System" />
@Zonciu
Zonciu / RowVersionUpdate.cs
Created January 8, 2019 15:10
EFCore update row version field manually
void Update(Entity entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
db.Entry(entity).State = EntityState.Detached;
var old = db.Entities.Find(entity.Id);
var oldEntry = db.Entry(old);
public class CameraDragMove : MonoBehaviour
{
private Vector3 ResetCamera;
private Vector3 Origin;
private Vector3 Diference;
private bool Drag = false;
@Zonciu
Zonciu / introrx.md
Created September 12, 2018 03:12 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@Zonciu
Zonciu / usersecrets.ps1
Last active December 27, 2020 15:10
Manage User Secrets for .NET Core console application
<#
.NOTES
How to use: Open Visual Studio, go to Tools – External Tools to bring up the External Tools dialog, add a new tools menu with the following configuration:
Title: Manage User Secrets (Or whatever you want)
Command: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe (Path to powershell.exe)
Arguments: Path-to-this-script(e.g. D:\VisualStudioTools\usersecrets.ps1)
Initial Directory: $(ProjectDir)
.PARAMETER ProjectFilePath
The csproj file's path, or keep it empty to search *.csproj file in initial directory
@Zonciu
Zonciu / WindowsDefenderExclusionForServiceFabric.ps1
Last active December 27, 2017 14:28
Add Service Fabric exclusion file and path to Windows Defender
param (
[Parameter(Mandatory = $true)]
[string] $FabricDataRoot,
[Parameter(Mandatory = $true)]
[string] $FabricLogRoot
)
$Preferences = Get-MpPreference
$ExclusionList = "$env:ProgramFiles\Microsoft Service Fabric",
$FabricDataRoot,