Skip to content

Instantly share code, notes, and snippets.

View philcockfield's full-sized avatar
🐵
!this; !that; !both; !neither;

Phil Cockfield philcockfield

🐵
!this; !that; !both; !neither;
View GitHub Profile
@philcockfield
philcockfield / gist:1233928
Created September 22, 2011 03:10
Spying into an anonymous method (Jasmine)
describe 'spying stuff', ->
models = null
resource = null
beforeEach ->
# Fakes - just for writing the sample test.
# You'd use the real methods under test of course.
models =
Item:
findRoot: () -> console.log 'findRoot Called', err, item
using System;
using MonoTouch.UIKit;
using System.Drawing;
namespace Core.Controls
{
public class DatePicker
{
#region Head
@philcockfield
philcockfield / gist:3082446
Created July 10, 2012 10:04
Deriving from Element
public class FooCell : UITableViewCell
{
public const string KEY = "FooKey";
public event EventHandler<EventArgs> Tapped;
public FooCell() : base(UITableViewCellStyle.Subtitle, KEY)
{
}
public override void TouchesEnded(NSSet touches, UIEvent evt)
@philcockfield
philcockfield / gist:3146438
Created July 19, 2012 20:08
Full implementation of IDisposable
using System;
using MonoTouch.Foundation;
namespace Core
{
public class Foo : NSObject, IDisposable
{
public Foo()
{
}
@philcockfield
philcockfield / gist:3284433
Created August 7, 2012 10:40
EnsureInvokedOnMainThread
private void EnsureInvokedOnMainThread(Action action)
{
if (IsMainThread())
{
action();
return;
}
this.BeginInvokeOnMainThread(() => action());
}
/*
Copyright 2012, Mu.
MIT License.
http://www.opensource.org/licenses/mit-license.php/
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the 'Software'), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@philcockfield
philcockfield / auto_prop.cs
Created August 9, 2012 07:21
auto_prop.cs
/*
Copyright 2012, Mu.
MIT License.
http://www.opensource.org/licenses/mit-license.php/
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the 'Software'), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@philcockfield
philcockfield / gist:3331798
Created August 12, 2012 13:26
WebRequest Premature call to Server (Node).
// Prepare the data.
var dataText = data.ToString();
var byteArray = dataText.ToByteArray();
// Setup the web-request.
var req = WebRequest.Create(url);
req.Method = "PUT";
req.ContentType = "Content-Type: application/json; charset=utf-8";
req.ContentLength = byteArray.Length;
@philcockfield
philcockfield / gist:3780833
Created September 25, 2012 09:27
MT.Dialog - RadioElement Problem
using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using MonoTouch.Dialog;
using System.Threading.Tasks;
namespace RadioButtonSample
@philcockfield
philcockfield / gist:3780834
Created September 25, 2012 09:27
MT.Dialog - RadioElement Problem
using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using MonoTouch.Dialog;
using System.Threading.Tasks;
namespace RadioButtonSample