Skip to content

Instantly share code, notes, and snippets.

@ToJans
ToJans / 0.Specs.cs
Created February 16, 2011 16:19
An a attempt for a message-less CQRS setup (the idea is messages being generated by the proxy) (CQRS gen2)
using System;
namespace CG2.ExamplePOC
{
public class WithDrawCashContext : WithDrawCashHandler
{
protected Guid CardId = Guid.NewGuid();
protected Guid AccountId = Guid.NewGuid();
protected Guid AtmId = Guid.NewGuid();
}
@ToJans
ToJans / 0.Specs.cs
Created March 3, 2011 09:22 — forked from thecodejunkie/ConNegModule.cs
The current implementation is a bit ugly, but this could become an easy to use content provider for the NancyFx framework
using System;
using System.Collections;
namespace CG2.FluentContent
{
// note that I currnelty do not have any testing libs or Nancy available
public class ContentProviderSpecs
{
public void A_content_provider_should_respond_to_available_content_types()
{
@ToJans
ToJans / UtopiaNerdBeerModule.cs
Created March 4, 2011 22:27
How my perfect NancyFx/Simple.Data setup would probably look - I do not know if it is possible to achieve
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Simple.Data;
using Nancy;
using Org.NerdBeers.Web.Models;
namespace Org.NerdBeers.Web.Modules
{
@ToJans
ToJans / ExampleConvention.cs
Created March 7, 2011 15:32
An example convention for nancy
public string ResolveViewPath(string appviewpath, string viewname,string modulename,string[] allowedextensions)
{
// find all possible extensions for this viewname
var possibleExtensions = new List<string>();
var ext = Path.GetExtension(viewname);
if (string.IsNullOrEmpty(ext))
possibleExtensions.AddRange(allowedextensions);
else
possibleExtensions.Add(ext);
// get the filename without an extension
@ToJans
ToJans / YSOD in inerdbeers.txt
Created March 8, 2011 08:27
I get this YSOD from time to time in http://nerdbeers.apphb.com
Server Error in '/' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
@using System.Web
@using System.Web.Security
<style type="text/css">
p,label {color:black;}
</style>
@{
// just refactored things a bit
var flashmessage = Request["flash"];
public class BrowserFixture
{
private readonly Browser browser;
public BrowserFixture()
{
var bootstrapper =
new FakeDefaultNancyBootstrapper();
this.browser = new Browser(bootstrapper);
@ToJans
ToJans / Index.spark.html
Created March 23, 2011 01:53
let's hope I manage to get this working as well both online and offline:-)
<content name="script">
<script type="text/coffeescript">
$().ready ->
$("*[data-uri]").each (el) ->
rendertemplate = Tempo.prepare(el);
uri = el.attribute "data-uri"
refresh = el.attribute "data-refresh"
$.retrieveJSON uri , {}, (data) ->
rendertemplate.render data
@ToJans
ToJans / CQRS.cs
Created May 5, 2011 08:49
Simple concept code to show how CQRS works
//---><8--------------------------- UI loads viewmodels and generates commands ----
UI.Viewmodel = ViewModelStore.Query(UI.SomeParameters);
UI.HandleInput = GeneratedCommand => CommandStore.Add(GeneratedCommand);
//---><8--------------------------- Commands to events -----------------------------------------
// This uses an iterator because a command should only be handled once
while(CommandStore.HasCommands)
@ToJans
ToJans / gist:1014127
Created June 8, 2011 09:53 — forked from kristofclaes/gist:1008780
Retrieving next and previous records with Simple.Data
// Checked blog at http://blog.markrendle.net/2011/05/23/simple-data-0-6-5/
// and code at https://github.com/markrendle/Simple.Data/blob/master/Simple.Data/SimpleQuery.cs
int? previousPhotoId = DB.Photos.Query()
.Select(DB.Photos.Id)
.Where(DB.Photos.Published == true && DB.Photos.DatePublished < currentPhoto.DatePublished.Value)
.OrderByDatePublishedDescending()
.ToScalarOrDefault<int?>();
int? nextPhotoId = DB.Photos.Query()