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 / 0_reuse_code.js
Created December 13, 2016 17:39
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
namespace YourNamespace
{
/// <summary>
/// Uses the Name value of the <see cref="ColumnAttribute"/> specified to determine
/// the association between the name of the column in the query results and the member to
/// which it will be extracted. If no column mapping is present all members are mapped as
/// usual.
/// </summary>
/// <typeparam name="T">The type of the object that this association between the mapper applies to.</typeparam>
public class ColumnAttributeTypeMapper<T> : FallbackTypeMapper
@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,
@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 / 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);
@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 / 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 / SerializationTest.cs
Last active May 6, 2019 01:36
protobuf-net/MessagePack/Json.NET Serialization Test
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using System.Security.Cryptography;
using System.Text;
using Newtonsoft.Json;
@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" />