Skip to content

Instantly share code, notes, and snippets.

View patroza's full-sized avatar

Patrick Roza patroza

View GitHub Profile
#!/bin/bash
command=`basename "$0"`
run-windows-command "$command" "$@"
public static IObservable<TResult> FromTdf<T, TResult>(this IObservable<T> source,
Func<IPropagatorBlock<T, TResult>> blockFactory) => Observable.Create<TResult>(observer => {
var block = blockFactory();
var dsp1 = block.AsObservable().Subscribe(observer.OnNext);
var dsp2 = source.Subscribe(block.AsObserver());
return new CompositeDisposable {dsp2, dsp1};
});
public static IObservable<TResult> FromTdf<T, TResult>(this IObservable<T> source,
IPropagatorBlock<T, TResult> block) => source.FromTdf(() => block);
@patroza
patroza / SpecsFor.cs
Created January 25, 2016 09:07
A slightly improved SpecsFor class
/// <summary>
/// A more closed version of the official SpecsFor class,
/// with some additional helpers
/// </summary>
/// <typeparam name="T"></typeparam>
public abstract class SpecsFor<T> : SpecsFor.SpecsFor<T>, IAnd<T> where T : class
{
protected abstract override void Given();
protected abstract override void When();
public sealed override void TearDown() => base.TearDown();
readonly ICollection<Action> _transactionCallbacks = new Collection<Action>();
public override int SaveChanges() {
int r;
try {
ExecuteDomainEvents();
r = base.SaveChanges();
} catch (Exception) {
_transactionCallbacks.Clear();
throw;
public class TestViewModel : ReactiveObject
{
const int _intVal = 1;
public int IntVal { get { return _intVal; } }
ObservableAsPropertyHelper<int> _MyReactiveVal;
public int MyReactiveVal
{
get { return _MyReactiveVal.Value; }
}
@patroza
patroza / gist:4031046
Created November 7, 2012 11:48
Initialize First RXUI Object on UI Thread
// Workaround for RXUi, first object initialization must be on UI Thread
private class DummyModel : BindableBase
{
private ObservableAsPropertyHelper<string> _propertyHelper;
public string PropertyHelper
{
get { return _propertyHelper.Value; }
}
private string _Name;
Type: System.Exception
Message: An OnError occurred on an object (usually ObservableAsPropertyHelper) that would break a binding or command. To prevent this, Subscribe to the ThrownExceptions property of your objects
Source: ReactiveUI
TargetSite: Void <.cctor>b__2()
Data: System.Collections.ListDictionaryInternal
RubyMessage: An OnError occurred on an object (usually ObservableAsPropertyHelper) that would break a binding or command. To prevent this, Subscribe to the ThrownExceptions property of your objects
Inner Exception:
Type: System.NullReferenceException
Message: Object reference not set to an instance of an object.
Source: System
@patroza
patroza / MainWindow.xaml
Created November 3, 2012 16:07
ReactiveUI ReactiveCollection AddRange/ItemsAdded repro
<Window x:Class="WpfApplication3.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<StackPanel Orientation="Horizontal">
<StackPanel Margin="5">
<StackPanel Orientation="Horizontal">
<TextBlock Text="Original Count" />
<TextBlock Margin="5,0,0,0" Text="{Binding Col.Count}" />
// this script checks if there arent too many magazines or respawns according to available slots
_count = count (configFile >> "CfgVehicles");
_prefix = "t1o_";
_vehicleName = "";
_singleError = false;
// Remove this
_msg = format["_count: %1", _count];
diag_log [diag_frameNo, diag_tickTime, time, _msg];
@patroza
patroza / plugin_to_gem.rb
Created February 15, 2012 19:55 — forked from edavis10/plugin_to_gem.rb
Script to convert a Rails/Redmine plugin to a RubyGem
#!/usr/bin/env ruby
# Usage:
# ruby plugin_to_gem.rb my_plugin_directory
require 'fileutils'
@plugin_dir = ARGV[0]
@plugin_name = File.basename ARGV[0]
def rakefile_content
description = 'TODO'