Skip to content

Instantly share code, notes, and snippets.

View james-world's full-sized avatar

James World james-world

View GitHub Profile
@james-world
james-world / Timeout.cs
Created October 8, 2014 08:43
How to watch a bad task and not fall into the cancellation token trap!
using System;
using System.Reactive.Linq;
using System.Reactive.Threading.Tasks;
using System.Threading;
using System.Threading.Tasks;
namespace AsyncEvil
{
class Program
{
@james-world
james-world / Implementation.cs
Last active August 29, 2015 14:07
This is an answer to a StackOver question on Rx - see the link in the comments. It deals with detecting from a stream of item status updates when one item has been stuck in a particular state for too long.
using System;
using System.Reactive.Concurrency;
using System.Reactive.Linq;
using Microsoft.Reactive.Testing;
using NUnit.Framework;
namespace SOStuck
{
public class StuckDetectorTests : ReactiveTest
{
@james-world
james-world / Rx Recovering from an error
Last active August 29, 2015 14:07
Rx example demonstrating recovering from a stream error
We couldn’t find that file to show.
/* Name of Gist */
@james-world
james-world / LeakyGenerate.cs
Last active December 20, 2016 03:14
Demonstrate leakiness of Generate and recursive Schedule
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Concurrency;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Reactive.Threading.Tasks;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
@james-world
james-world / Auth0-angular Popup Login Hang Repro
Created October 31, 2014 11:57
Repro for auth0-angular login dialog not closing
Auth0-angular Popup Login Hang Repro
@james-world
james-world / decorators.cs
Created April 2, 2017 12:47
Demostrates unexpected decorator behaviour in Auto 4.4.0
// Suitable for LINQPad with the Autofac nuget package
void Main()
{
ExpectedBehaviour();
UnexpectedBehaviour();
}
public void ExpectedBehaviour()
{
@james-world
james-world / Get-GitIgnore.ps1
Created October 20, 2018 14:55
Powershell command to create a .gitignore file from .gitignore.io
function Get-GitIgnore {
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[string[]]
$Targets,
[string]
$OutputDirectory = "$PWD",
[string]
$Filename = ".gitignore",
@james-world
james-world / RollingReplaySubject
Last active December 1, 2019 16:21
RollingReplaySubject - Works like ReplaySubject but has buffer cleared on a TimeInterval or based on an input stream.
namespace RxExtensions
{
using System;
using System.Reactive;
using System.Reactive.Concurrency;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Reactive.Subjects;
public class RollingReplaySubject
@james-world
james-world / FSharpTalk.md
Last active December 6, 2019 17:04
Notes from a talk on FSharp