Skip to content

Instantly share code, notes, and snippets.

// Calling a WCF Data Service with jQuery
//
// This will generate a URL like this...
// http://example.com/Products.svc/Customers(1234)/Orders?$skip=10&top=10
// ... and pass the JSON data result to your callback function
$.fromServiceUrl("http://example.com/Products.svc")
.queryTable("Customers", 1234)
.withRelation("Orders")
.skip(10)
// Example 1
var query = from item _dataContext.PublishedItems
select item;
// When enumerated (i.e. looped) over, "query" will go to the DB, and get all items
// Jasmine
// http://pivotal.github.com/jasmine/
describe("Calculator", function() {
it("should add two numbers correctly", function() {
var result = add(3, 4);
expect(result).toEqual(7);
});
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace RefactoringNeeded
{
#region Alert filter
public static class AlertFilter
{
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace RefactoringNeeded
{
#region Alert filter
public static class AlertFilter
{
@alexyork
alexyork / Ugly!
Created September 21, 2010 11:34
Ugly.cs
// Unformatted / unindented
new Nullable<decimal>().GetValueOrDefault().GetType().GetMethod("Parse", BindingFlags.Static | BindingFlags.Public, null, new Type[] { typeof(string) }, null).Invoke(null, new object[] { "123,45" })
// Formatted / indented
new Nullable<decimal>().GetValueOrDefault()
.GetType()
.GetMethod("Parse",
BindingFlags.Static | BindingFlags.Public,
null,
new Type[] { typeof(string) },
@alexyork
alexyork / ASP.NET MVC Blog Tests
Created October 25, 2010 18:44
ASP.NET MVC Blog Tests
using System;
using NUnit.Framework;
namespace MvcBlogEngine.Tests.Controllers
{
public partial class WidgetControllerSpec
{
[TestFixture]
public partial class TagCloud : BDDTest
{
prepareSnacks({
'biscuits': "Hobnobs",
'crisps': "Quavers",
'peanuts': "Lots and lots!",
'olives': "The ones with feta cheese inside",
// etc etc
});
@alexyork
alexyork / HTTP handler
Created May 19, 2011 19:34
A very simple HTTP handler in .NET that returns JSON
using System;
using System.Web;
public class MyJsonHttpHandler : IHttpHandler
{
public bool IsReusable
{
get { return false; }
}
@alexyork
alexyork / TableCellFactory.cs
Created July 19, 2011 06:12
Custom UITableViewCell's with a TableCellFactory in MonoTouch
using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using MonoTouch.ObjCRuntime;
namespace CustomTableCellApp
{
public class TableCellFactory<T> where T : UITableViewCell