Skip to content

Instantly share code, notes, and snippets.

View wantedfast's full-sized avatar

Geralt Wang(MSFT) wantedfast

View GitHub Profile
@wantedfast
wantedfast / Use of immutable stack
Last active June 2, 2020 02:35
Personal Learning
**Answer 1:**
The idea behind this library of collections is to provide collections, that when changed produce new versions of the same collection, where all old versions of the collections are still valid.
It is similar to how version control system works: You can change code, and commit changes to the server, producing a new version of the source tree. In the meantime you can still checkout any previous revision.
For immutable collections, you keep acces to an old version (essentially an immutable snapshot) by keeping a pointer to the collection that will not change.
You could argue that this scenario is less useful for a stack because you probably use a stack to add and retrieve each item exactly once, and also preserving the order. Usually a stack's use is very much tied to code running on a single thread of execution.
But now that I'm typing, I can think of a specific use case if you have a lazy parser that needs to track some state in a stack. You can then save a pointer to the immutable stack in th
@wantedfast
wantedfast / Thread and Task
Created December 29, 2019 03:47
What's the difference between Thread and Task in C#
## Difference
1. The Thread class is used for creating and manipulating a thread in Windows.
2. A Task represents some asynchronous operation and is part of the Task Parallel Library, a set of APIs for running tasks asynchronously and in parallel.
3. The task can return a result. There is no direct mechanism to return the result from a thread.
4. Task supports cancellation through the use of cancellation tokens. But Thread doesn't.
5. A task can have multiple processes happening at the same time. Threads can only have one task running at a time. We can easily implement Asynchronous using ’async’ and ‘await’ keywords.
6. A new Thread()is not dealing with Thread pool thread, whereas Task does use thread pool thread.
7. A Task is a higher level concept than Thread.
## Async Programming
@wantedfast
wantedfast / Base关键字
Created December 22, 2019 03:11
C#Base关键字
Base关键字和This关键字略像,Base主要是用于:
- 无序列表从子类访问父类重写的函数
- 无序列表调用父类的构造函数
```
Public class House : Asset
{
...
public override int a => base.c + 3;
}
@wantedfast
wantedfast / 引用转换
Last active December 22, 2019 02:48
C#引用转换
## 引用转换
一个对象的引用可以隐式地转换到其父类的引用(UpCast)
转换至子类的引用则为显示转换(DownCast)
有序列表引用转换:创建了一个新的引用,它也能指向该对象
## UpCast
从子类的引用创建父类的引用
```
Stock msft = new Stock();
Asset a = msft; //UpCasts
@wantedfast
wantedfast / Logging File In .NET Core
Last active December 3, 2019 05:01
Provide a workaround to logging file in .NET Core using Log4net.
## Install Log4net via Nuget
Open Nuget package manager then download Log4Net into your project.
## Create log4net.config file
Add a new Application configuration file in your .NET Core project, and named it as 'log4net.config', It will be used later.
Here is a template you can take a reference.
```
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
@wantedfast
wantedfast / C# 常量版本控制问题
Created November 27, 2019 04:26
C# 常量版本控制问题
 internal class Program
    {
        private static void Main(string[] args)
        {
            Console.WriteLine(ConstValue.MaxIntSize);
        }
    }
@wantedfast
wantedfast / Event vs Message Service
Created November 26, 2019 02:47
What the difference between Azure Event and Azure Message Service.
## Difference Between Publish
The publishers of the event has no exception about how the events to be handled. Only the consumer of the events have the decision.
Message is different with that, publishers of message has an exception about how the consumer handle those messages. There have a contract between publisher and consumer. For example, publisher send a mesage with raw data and except the consumer to create a file from that data and send a response when the work is done.
## Comparsion Of Services
|Service|Purpose|Type|When to use|
|-|-|-|-|
|Event Grid|Reactive programming|Event distribution(discrete)|React to status changes|
|Event Hubs|Big data pipeline|Event streaming(series)|Telemetry and distributed data streaming|
|Service bus|High-value enterprise messaging|message|order processing and financial transactions|
@wantedfast
wantedfast / C# Delegate
Created November 17, 2019 03:12
Learning notebook of C# Delegate
## Advantage
Decoupling the method
Code a plugin method
### Code A Plugin Method
public delegate int Transformer(int x);
public static int GetNumber(int[] values, Transformer t){};
static void Main()
@wantedfast
wantedfast / 学习笔记-ApacheSpark
Last active November 3, 2019 06:10
ApacheSpark个人学习笔记
### Spark的优势
- HadLoop的MapReduce最大的问题,会产生大量的I/O操作
- Spark基于内存,速度快于Hadloop 2.x
- Apache Spark™ is a unified analytics engine for large-scale data processing.
- 易用性
- 通用性
- 兼用性 ,兼容Hadloop
- 基于MAPREDUCE的计算引擎会将自己的计算结果输出到磁盘上,进行存储和容错
### Spark体系架构
@wantedfast
wantedfast / 学习笔记-What is Hadloop ?
Last active September 28, 2019 03:13
The instruction of Hadloop
The Hadoop Distributed File System (HDFS) is a distributed file system designed to run on commodity hardware. It has many similarities with existing distributed file systems. However, the differences from other distributed file systems are significant. HDFS is highly fault-tolerant and is designed to be deployed on low-cost hardware. HDFS provides high throughput access to application data and is suitable for applications that have large data sets. HDFS relaxes a few POSIX requirements to enable streaming access to file system data. HDFS was originally built as infrastructure for the Apache Nutch web search engine project. HDFS is part of the Apache Hadoop Core project. The project URL is http://hadoop.apache.org
## 大数据的本质:
- 大数据的存储 :分布式文件系统(分布式存储)- HDFS:Hadloop distributed file system.
- 大数据的计算: 分布式计算
## Hadloop特性
- 冗余度
- HDFS默认冗余度为3
- 效率:水平复制