Skip to content

Instantly share code, notes, and snippets.

View anaisbetts's full-sized avatar

Ani Betts anaisbetts

View GitHub Profile
var foo = new Subject<int> ();
foo.Subscribe(Console.WriteLine)
foo.OnNext(4);
>> 4
foo.OnNext(10);
>> 10
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Net;
using System.Reactive.Linq;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
public static IObservable<RecoveryOptionResult> Throw(UserError error)
{
var handlers = (overriddenRegisteredUserErrorHandlers != null) ?
new[] { overriddenRegisteredUserErrorHandlers } :
registeredUserErrorHandlers.ToArray().Reverse();
// NB: This is a little complicated - here's the idea: we have a
// list of handlers that we're running down *in order*. If we find
// one that doesn't return null, we're going to return this as an
// Observable with one item (the result).
public class Person : ReactiveObject
{
public string FamilyName
{
get { return <FamilyName>k__BackingField;}
set
{
if (!string.Equals(<FamilyName>k__BackingField, value))
{
raisePropertyChanging("FamilyName");
static readonly string[] videoCardBlacklist = {"8086:0116"};
static void DisableHwRenderingForCrapVideoCards()
{
if (!String.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("MY_VIDEO_CARD_REALLY_WORKS")))
{
return;
}
int osVersion = Environment.OSVersion.Version.Major * 100 + Environment.OSVersion.Version.Minor;
if (osVersion < 601)
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ import namespace="System.IO" #>
<#@ output extension=".cs" #>
using System;
using System.Windows;
<#
var pathEntries = System.Environment.GetEnvironmentVariable("PATH").Split(Path.PathSeparator);
FileInfo gitFileInfo = null;
public static IEnumerable<TAcc> Scan<T, TAcc>(this IEnumerable<T> This, TAcc initialValue, Func<TAcc, T, TAcc> accFunc)
{
TAcc acc = initialValue;
foreach (var x in This)
{
acc = accFunc(acc, x);
yield return acc;
}
}
@anaisbetts
anaisbetts / UIKitExportEnv.cs
Created February 9, 2012 00:05 — forked from praeclarum/UIKitExportEnv.cs
Sometimes, exporting images isn't easy
public class UIKitExportEnv : ExportEnv
{
public UIKitExportEnv (string name, Model model)
: base (name, model)
{
}
protected override void WriteTexture (ITexture texture, ExportedFile file)
{
var width = texture.Width;
class Info {
// instance variables
String brandName;
String shirtSize;
String cut;
String date;
PImage musicImg;
class Flannel {
// instance variables
int date;
int primColor;
int secondColor;
int stackOrder = 0;
float x;
float y;