Skip to content

Instantly share code, notes, and snippets.

View davidwhitney's full-sized avatar
🍸
You're all wonderful. That's what's happening.

David Whitney davidwhitney

🍸
You're all wonderful. That's what's happening.
View GitHub Profile
@davidwhitney
davidwhitney / WebForms view engine with device detection
Created October 6, 2010 13:57
MVC2 view engine that detects devices
using System.Collections.Generic;
using System.Web.Mvc;
using System;
using System.Globalization;
using System.Linq;
// Resolving view engine is reflected out from the default WebFormsViewEngine
// with extra hooks for a resolver
// device detection makes use of http://mdbf.codeplex.com/ and query string magic
@davidwhitney
davidwhitney / HtmlHelperExtensions.cs
Created November 15, 2010 15:15
Html Helper extension for pluralization
using System;
using System.Globalization;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Web.Mvc;
namespace Extensions
{
public static class HtmlHelperExtensions
@davidwhitney
davidwhitney / HelloJustGivingPHPSdk.php
Created November 22, 2010 17:27
PHP example of a "Hello world" app for account creation, page creation, page retrieval
<?php
include_once 'JustGivingClient.php';
include_once 'ApiClients/Model/CreateAccountRequest.php';
function WriteLine($string)
{
echo $string . "<br/>";
}
$ApiLocation = "https://api.staging.justgiving.com/";
@davidwhitney
davidwhitney / Feature set concept
Created December 23, 2010 10:39
Feature set concept
namespace featuerset
{
public class SomeConsumingClass
{
public void RenderEndUserAccountView()
{
var configService = new ServiceThatBringsBackFeatures();
var featureConfig = configService.GetFeatures("RaceForLife");
if(!featureConfig.Features.EndUserAccount.EmailTool.Enabled)
@davidwhitney
davidwhitney / JustGivingUsingNodeJs
Created January 6, 2011 22:16
A quick Node.js example for accessing the JustGiving API
var sys = require('sys'), http = require('http');
http.createServer(function (req, res) {
var user = 'david+publicexample@justgiving.com';
var password = 'password';
var auth = new Buffer(user + ':' + password).toString('base64');
var client = http.createClient(80, 'api.staging.justgiving.com', true);
var request = client.request('GET', '/decbf1d2/v1/fundraising/pages/nodejs-example/donations', {
@davidwhitney
davidwhitney / JustGivingAjaxSearchExample.html
Created January 25, 2011 18:39
Example of using the JustGiving API to do a quick and dirty charity search
<html>
<head>
<title>My Kickass JustGiving search</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
</head>
<body>
JustGiving AJAX Search Quick Example
<br/><br/>
@davidwhitney
davidwhitney / CouchDb quickstart example
Created March 14, 2011 22:53
CouchDb quickstart example
using System;
using System.Web.Mvc;
using Divan;
using Newtonsoft.Json;
namespace CouchTest.Controllers
{
[HandleError]
public class HomeController : Controller
{
@davidwhitney
davidwhitney / Puzzle
Created April 4, 2011 17:09
Give me a cup of T, of T, of T, of T, of T
class Program
{
static void Main(string[] args)
{
var animal = new Chicken {Property = "a guid! " + Guid.NewGuid()};
var myself = animal.Something(animal);
Console.WriteLine(myself.Property);
myself.Action(chick => Console.WriteLine(chick.Property));
@davidwhitney
davidwhitney / Type registry
Created April 5, 2011 14:58
Type registry example for command processing
class Program
{
private static TypeRegistry _registry;
static void Main(string[] args)
{
_registry = new TypeRegistry();
_registry.RegisterHandlerFor<MyRequest, MyRequestProcessor>();
SomeActionMethod(new MyRequest {Id = 1000});
@davidwhitney
davidwhitney / gist:1027181
Created June 15, 2011 14:08
Rss feed formatter ActionResult for ASP.NET MVC
using System;
using System.IO;
using System.Linq;
using System.ServiceModel.Syndication;
using System.Text;
using System.Web.Mvc;
using System.Xml;
using System.Xml.Linq;