Skip to content

Instantly share code, notes, and snippets.

View moswald's full-sized avatar

Matt Oswald moswald

View GitHub Profile
public static class ListMixins
{
public static IEnumerable<T> Forever<T>(this IList<T> This)
{
using (var e = This.GetEnumerator())
{
for (; ; )
{
while (e.MoveNext())
{
@moswald
moswald / gist:91002b54827f7099679b
Created May 30, 2014 21:06
ReactiveUI build error
"C:\projects\reactiveui\ReactiveUI\ReactiveUI_WinRT80.csproj" (Rebuild target) (25) ->
7624 C:\projects\reactiveui\ReactiveUI\ReactiveUI_WinRT80.csproj(134,3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\WindowsXaml\v12.0\Microsoft.Windows.UI.Xaml.CSharp.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
// UpdateCommand waits for the web to return some data
// VisualState is a property that tells the view to switch the VisualStateManager visual state (a "raiseif" property)
UpdateCommand.IsExecuting.Where(x => x).Subscribe(_ => VisualState = "Loading");
UpdateCommand.Subscribe(
data =>
{
// ...
// do stuff with data
// ...
@moswald
moswald / gist:45554c8eb0967f0d5d47
Created August 1, 2014 18:06
How to deal with multiple selections on a ListView control (WinRT) with RxUI
//
// in the View constructor
this.WhenActivated(d =>
{
d(MyListView.Events().SelectionChanged.Subscribe(args =>
{
foreach (var item in args.AddedItems.Cast<MyModelType>())
{
item.IsSelected = true;
}
// holy verbosity, batman, is this (Java):
someObj.getObservable()
.switchMap(new Func1<Void, Observable<Void>>()
{
@Override
public Observable<Void> call(Void _)
{
return someObj.getUserObservable()
.map(new Func1<User, Void>()
@moswald
moswald / gist:c8de49663b8ecc09c79f
Created March 15, 2015 17:46
Stack trace for RxApp.SuspensionHost.CreateNewAppState crash on startup:
Stack trace for RxApp.SuspensionHost.CreateNewAppState crash on startup:
========================================================================
ReactiveUI.DLL!ReactiveUI.PropertyBinderImplementation.bindToDirect.AnonymousMethod__13(TValue x)
System.Reactive.Core.DLL!System.Reactive.AnonymousSafeObserver<T>.OnNext(T value)
System.Reactive.Linq.DLL!System.Reactive.Linq.ObservableImpl.SelectMany<TSource, TResult>._.Iter.OnNext(TResult value)
System.Reactive.Linq.DLL!System.Reactive.Linq.ObservableImpl.Return<TResult>._.Invoke()
System.Reactive.Core.DLL!System.Reactive.Concurrency.Scheduler.Invoke(System.Reactive.Concurrency.IScheduler scheduler, System.Action action)
System.Reactive.Core.DLL!System.Reactive.Concurrency.ImmediateScheduler.Schedule<TState>(TState state, System.Func<System.Reactive.Concurrency.IScheduler, TState, System.IDisposable> action)
System.Reactive.Core.DLL!System.Reactive.Concurrency.Scheduler.Schedule(System.Reactive.Concurrency.IScheduler scheduler, System.Action action)

Keybase proof

I hereby claim:

  • I am moswald on github.
  • I am moswald (https://keybase.io/moswald) on keybase.
  • I have a public key whose fingerprint is 9232 B29F 18F2 BD9C 0AC1 311B 8FFC 27D1 08C7 F317

To claim this, I am signing this object:

<x:Int32 x:Key="HubHeaderCharacterSpacing">-22</x:Int32>
<x:Double x:Key="HubHeaderFontSize">78</x:Double>
<FontFamily x:Key="PhoneFontFamilyNormal">Segoe WP</FontFamily>
<Thickness x:Key="HubHeaderMarginThickness">15,1,0,0</Thickness>
<Style x:Key="HubStyle1" TargetType="Hub">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Hub">
<Grid x:Name="HubRoot">
<Grid.Projection>
public static class AutoRegisterViews
{
public static void RegisterViewsForViewModels(this IMutableDependencyResolver resolver)
{
var assembly = typeof(App).GetTypeInfo().Assembly;
// for each type that implements IViewFor
foreach (var type in assembly.DefinedTypes
.Where(ti => ti.ImplementedInterfaces.Contains(typeof(IViewFor)))
.Where(t => !t.IsAbstract))
@moswald
moswald / Program.cs
Created October 14, 2015 15:49
TakeUntil wasn't working where I originally had it.
namespace TakeUntil
{
using System;
using System.Reactive;
using System.Reactive.Concurrency;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using System.Threading.Tasks;
static class Program