Skip to content

Instantly share code, notes, and snippets.

View Itoktsnhc's full-sized avatar
🤡
:)

itoktsnhc Itoktsnhc

🤡
:)
View GitHub Profile
@Itoktsnhc
Itoktsnhc / AsOrder.cs
Created January 4, 2022 06:15
Get Property As Order-Defined
var type = typeof(Person);
var orderAndProp = from property in type.GetProperties()
where Attribute.IsDefined(property, typeof(AsOrderAttribute))
select new
{
((AsOrderAttribute)property
.GetCustomAttributes(typeof(AsOrderAttribute), false)
.Single()).Order,
property.Name
};
@Itoktsnhc
Itoktsnhc / ExtractLineParts.cs
Created November 23, 2021 03:38
ExtractLineParts
public static List<string> ExtractLineParts(string line, char spliter = ' ')
{
var res = new List<string>();
line = line.Trim();
var idx = 0;
var lastIdx = 0;
var quoted = false;
while (idx < line.Length)
{
if (line[idx] == '\"')
@Itoktsnhc
Itoktsnhc / MFTScanner.cs
Last active October 22, 2021 06:43
Master File Table Scanner
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using Microsoft.VisualBasic;
namespace Itok.Search.Core
{
public class MFTScanner
{
@Itoktsnhc
Itoktsnhc / BuildTreeByIndentation.cs
Created July 20, 2021 15:10
BuildTreeByIndentation
private static TreeNode BuildTree(string log)
{
var root = new TreeNode();
var lines = log.Split(Environment.NewLine)
.Where(s => !string.IsNullOrWhiteSpace(s)).ToList();
var i = 0;
while (i < lines.Count) BuildTree(lines, root, ref i);
return root;
}
public class MedianFinder
{
private readonly MinHeap _greaterHalf;
private readonly MaxHeap _lowerHalf;
public MedianFinder()
{
_greaterHalf = new MinHeap();
_lowerHalf = new MaxHeap();
@Itoktsnhc
Itoktsnhc / PartitionedContainer.cs
Created January 5, 2021 07:33
PartitionedContainer_sample
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
namespace Entities
{
public class PartitionedContainer<TPayload> : IDisposable
{
@Itoktsnhc
Itoktsnhc / itok-make-animation.ipynb
Created August 25, 2020 05:49
itok-make-animation.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Orleans;
using Orleans.Hosting;
namespace OrleansTest
{
@Itoktsnhc
Itoktsnhc / nlog.config
Last active April 28, 2018 13:22
sample nlog.config for NLog.Azure
<?xml version="1.0" encoding="utf-8"?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off">
<extensions>
<add assembly="NLog.Azure" />
{"sig":"ec98e8088052896ddd19797e76999314958869b18a772706feb3f461c073056223731e802e9fc5bbce6d08bb851a3d0ebad28b77b2f37f8c7bb6abcd6ea8c3a90","msghash":"0b05253f89a03857d04b430c4279113a2f6cae3efd4c922fb1e00c474d885644"}