Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@distantcam
distantcam / Attachment.cs
Created August 10, 2012 08:55
Attachments
abstract class Attachment<T> : IAttachment
{
protected T viewModel;
protected abstract void OnAttach();
void IAttachment.AttachTo(object obj)
{
viewModel = (T)obj;
OnAttach();
@distantcam
distantcam / AfterWeaving.cs
Created September 30, 2012 04:34
INPC Weaver example
public class SomeViewModel : INotifyPropertyChanged
{
private string <URL>k__BackingField;
public event PropertyChangedEventHandler PropertyChanged;
public string URL
{
[CompilerGenerated]
get
@distantcam
distantcam / xkcd.fx
Created October 9, 2012 09:45
xkcd Shader
sampler2D input : register(s0);
/// <summary>The second input texture.</summary>
/// <defaultValue>c:\examplefolder\examplefile.jpg</defaultValue>
sampler2D RandomTexture : register(s1);
/// <summary>The radius of the Poisson disk (in pixels).</summary>
/// <minValue>1</minValue>
/// <maxValue>10</maxValue>
/// <defaultValue>5</defaultValue>
@distantcam
distantcam / ShellNew-sln2012
Created December 13, 2012 02:43
ShellNew registry key for .sln files.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.sln\ShellNew]
"Data"=hex:EF,BB,BF,0D,0A,4D,69,63,72,6F,73,6F,66,74,20,56,69,73,75,61,6C,20,53,74,75,64,69,6F,20,53,6F,6C,75,74,69,6F,6E,20,46,69,6C,65,2C,20,46,6F,72,6D,61,74,20,56,65,72,73,69,6F,6E,20,31,32,2E,30,30,0D,0A,23,20,56,69,73,75,61,6C,20,53,74,75,64,69,6F,20,32,30,31,32,0D,0A,47,6C,6F,62,61,6C,0D,0A,09,47,6C,6F,62,61,6C,53,65,63,74,69,6F,6E,28,53,6F,6C,75,74,69,6F,6E,50,72,6F,70,65,72,74,69,65,73,29,20,3D,20,70,72,65,53,6F,6C,75,74,69,6F,6E,0D,0A,09,09,48,69,64,65,53,6F,6C,75,74,69,6F,6E,4E,6F,64,65,20,3D,20,46,41,4C,53,45,0D,0A,09,45,6E,64,47,6C,6F,62,61,6C,53,65,63,74,69,6F,6E,0D,0A,45,6E,64,47,6C,6F,62,61,6C,0D,0A
@distantcam
distantcam / RxCommand.cs
Created February 19, 2013 02:42
RxUI Light
using System;
using System.Reactive;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using System.Windows.Input;
public class RxCommand : ICommand, IObservable<object>, IDisposable
{
private readonly ISubject<bool> canExecuteSubject;
private readonly ISubject<object> executeSubject;
@distantcam
distantcam / drawarc.c
Created April 28, 2013 15:30
Pebble helper functions
/*
Copyright 2013 Cameron MacFarland
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
@distantcam
distantcam / CecilExtensions.cs
Created August 21, 2013 03:09
Mono.Cecil Extension Methods
public static class CecilExtensions
{
/// <summary>
/// Finds a type within the references of an assembly.
/// </summary>
/// <param name="module">The module to search the references of.</param>
/// <param name="type">The type to look for.</param>
/// <returns>The found type definition, or null if the type is not found.</returns>
/// <example>To find <see cref="System.Object"/> within a module.
/// <code>module.Find(typeof(System.Object));</code>
@distantcam
distantcam / DictionaryExtensions.cs
Created November 27, 2013 08:07
Dictionary Extensions
using System;
using System.Linq;
namespace System.Collections.Generic
{
public static class DictionaryExtensions
{
public static TValue GetOrAdd<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, Func<TKey, TValue> valueFactory)
{
TValue v;

Keybase proof

I hereby claim:

  • I am distantcam on github.
  • I am distantcam (https://keybase.io/distantcam) on keybase.
  • I have a public key whose fingerprint is F6C6 9E11 DC61 9DA7 B310 8417 875C C3D7 5421 5F94

To claim this, I am signing this object:

public static class AkavacheExtensions
{
public static IObservable<string> GetOrFetchWithETag(this IBlobCache cache, string url)
{
var result =
// Get from cache
cache.GetObject<string>(url)
// Cached values are true
.Select(x => Tuple.Create(x, true))