Skip to content

Instantly share code, notes, and snippets.

@zhangz
zhangz / README.md
Created August 8, 2016 08:39 — forked from hofmannsven/README.md
My simply Git Cheatsheet

#RxJS 5 Operators By Example A (soon to be) complete list of RxJS 5 operators with easy to understand explanations and runnable examples.

(I will be adding one operator per day until all are included.)

Chinese Version by: @DrakeLeung

Table of Contents

class TaskToObservable<T> : IObservable<T>
{
Func<CancellationToken, Task<T>> taskFactory;
public TaskToObservable(Func<CancellationToken, Task<T>> taskFactory)
{
this.taskFactory = taskFactory;
}
public IDisposable Subscribe(IObserver<T> observer)
using System;
using System.Reactive.Concurrency;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using System.Threading;
namespace Nito.AsyncEx
{
/// <summary>
/// An <see cref="IProgress{T}"/> that is disposable.
@zhangz
zhangz / HasMoreThan.cs
Created March 13, 2015 11:20
HasMoreThan
//http://blog.slaks.net/2015-01-12/linq-count-considered-occasionally-harmful/
public static bool HasMoreThan<T>(this IEnumerable<T> sequence, int count) {
if (count < 0) return true;
int? staticCount = (sequence as ICollection<T>)?.Count
?? (sequence as ICollection)?.Count
?? (sequence as IReadOnlyCollection<T>)?.Count;
if (staticCount != null)
return staticCount > count;
using (var enumerator = sequence.GetEnumerator())
for (int i = 0; i < count + 1; i++)
// <copyright file="LeastRecentlyUsedCache.cs" company="http://www.sinbadsoft.com">
// Copyright (c) Chaker Nakhli 2013
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
// License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
// applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
// governing permissions and limitations under the License.
// </copyright>
// <author>Chaker Nakhli</author>
// <email>Chaker.Nakhli@sinbadsoft.com</email>
@zhangz
zhangz / BattlestationSetup.md
Last active August 29, 2015 14:06
Battlestation Setup for .NET developer
public interface IBufferState
{
void Commit();
}
public interface IBuffer
{
IBufferState CaptureState();
}
public struct MyKey : IEquatable<MyKey>
{
private int value;
public MyKey(int value)
{
this.value = value;
}
public override int GetHashCode()