Skip to content

Instantly share code, notes, and snippets.

public class FSharpOptionObjectMapper : IObjectMapper
{
public object Map(ResolutionContext context, IMappingEngineRunner mapper)
{
var sourceValue = ((dynamic) context.SourceValue);
return (sourceValue == null || OptionModule.IsNone(sourceValue)) ? null : sourceValue.Value;
}
public bool IsMatch(ResolutionContext context)

Keybase proof

I hereby claim:

  • I am NickJosevski on github.
  • I am nickjosevski (https://keybase.io/nickjosevski) on keybase.
  • I have a public key whose fingerprint is 10C1 1301 4FA9 EAD5 7752 A6A2 E52B 0ADD 1554 99B8

To claim this, I am signing this object:

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
@NickJosevski
NickJosevski / NSubIssueTests.cs
Created October 19, 2011 01:29
Mocking extension methods
//I saw this and thought there was a simple way around subbing extension methods
//http://blogs.clariusconsulting.net/kzu/how-to-mock-extension-methods/
//My choice of solution was to just refactor the IRepo interface
namespace NSubIssueTests
{
[TestFixture]
public class ExtensionOnInterfaceTests
{
@NickJosevski
NickJosevski / gist:1559695
Created January 4, 2012 11:42
Playing with Routes
routes.MapRoute("Shortcuts",
"{whereToGo}",
new
{
controller = "TheRouter",
action = "TryRoute"
});
@NickJosevski
NickJosevski / NJ-QUnitTestBasics.js
Created January 5, 2012 10:14
Some QUnit basics as part of a blog post
/// more info: http://blog.nick.josevski.com/2012/01/05/unit-testing-javascript-methods-that-contain-jquery-ajax-calls
test("check if methodUnderTest completes successfully (mockJax way)", function () {
// Arrange
var jsonText = '{"id": "123","fieldName": "mj-fbs", "data": "fbs-text"}',
fieldBeingSaved = $('<input name="mj-fbs" Text="fbs-text"></input>'),
busyImg = $('<img id="mj-fbs-loading" alt="should-get-replaced-by-success-method"></img>');
$.mockjax({
@NickJosevski
NickJosevski / linq2xmlNameSpaceDemo.cs
Created January 14, 2012 11:55
linq to xml handing of namespaces on node selection
void Main()
{
//demonstrating linq to xml handing of namespaces, using the feedburner style on Scott Hanselman's blog.
var request = (System.Net.HttpWebRequest) System.Net.WebRequest.Create(@"http://feeds.feedburner.com/ScottHanselman");
using (var response = request.GetResponse())
{
var xmlDoc = XDocument.Load(response.GetResponseStream());
@NickJosevski
NickJosevski / feedreadingissue.cs
Created January 15, 2012 07:25
Doesn't work for funnelweb blogs, but works fine on feedburner feed and Wordpress feed.
//just paste this code in LinqPad (having selected Language: C# Program) and try and fix it ;)
void Main()
{
//demonstrating linq to xml handing of namespaces, using the feedburner style on Scott Hanselman's blog.
var request = (System.Net.HttpWebRequest) System.Net.WebRequest.Create(@"http://feeds.feedburner.com/ScottHanselman");
//this works:
using (var response = request.GetResponse())
{
@NickJosevski
NickJosevski / jquery.load.example.js
Created February 9, 2012 22:13
Load() callback
$("#core").load(href, function () {
setupClicks();
});
function setupClicks() {
$("a").unbind("click", clickHandler);
$("a").on("click", clickHandler);
};
/* --- vs --- */
@NickJosevski
NickJosevski / myview.js.coffee
Created March 8, 2012 00:36 — forked from tarnacious/myview.js.coffee
backbone example - serialize form + update on change
window.MyView = Backbone.View.extend({
initialize: ->
_.bindAll(this,'render')
this.template = window.JST["MyView"]
this.model.bind('change', this.render)
render: ->
$(this.el).html(this.template(this.model.toJSON()))
events: {