Skip to content

Instantly share code, notes, and snippets.

View alistair's full-sized avatar

Alistair Bush alistair

  • Auckland, New Zealand
View GitHub Profile
@alistair
alistair / gist:9517525
Created March 12, 2014 22:08
ravendb action behaviour
public class RavenDbBehavior : IActionBehavior
{
private readonly IDocumentSession _session;
public IActionBehavior InsideBehavior { get; set; }
public RavenDbBehavior(IDocumentSession session)
{
_session = session;
}
public class FeatureViewLocationRazorViewEngine : RazorViewEngine
{
public FeatureViewLocationRazorViewEngine()
{
ViewLocationFormats = new[]
{
"~/Features/{1}/{0}.cshtml",
"~/Features/{1}/{0}.vbhtml",
"~/Features/Shared/{0}.cshtml",
"~/Features/Shared/{0}.vbhtml",
======================================================
======================================================
//File toggle.js
// All the logic for getting toggle information
exports = function FeatureToggle(toggleName, offFunc, onFunc) {
return function() {
if (toggleOn(toggleName))
public interface IAmAFeature {
public void Blah();
}
public interface WelcomeEmailFeature {
public void Blah() {
// Send email with no jobs.
}
}
===========================
===========================
// file1.js
var a = function() {
}
exports.b = function() {
var a = function() {
#haskell
foldr (.) id [inc, inc, inc] $ 0
data Event
= AccountCreated Email
| AccountLoggedIn
| Start
case class State(emailAddress: String, loginCount: Int, failedLoginCount: Int, locked: Boolean) {
/* Login to go here */
}
abstract class Event() {
def apply(s: State): State
}
case class AccountCreated(emailAddress: String) extends Event {
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.Http.Controllers;
using System.Web.Http.Filters;
@alistair
alistair / QuestionByConvention.js
Created May 18, 2015 21:53
Backbone post update convention
// http_conventions.js
var Backbone = require('Backbone');
var postOnUpdate = function(method, model, options) {
return Backbone.sync('create', model, options);
}
var postOnGet = // whatever here
export.postOnUpdate = postOnUpdate;
export.postOnGet = postOnGet;
class Program
{
public HttpResponse BuildDeleteRequest(Action<HttpRequest> action)
{
var @object = new HttpRequest()
{
Method = "GET"
};
action(@object);
return @object.Execute();