Skip to content

Instantly share code, notes, and snippets.

@loosechainsaw
loosechainsaw / RouteGeneratorMVC.cs
Created January 27, 2012 08:17
Route Generator for MVC
RouteBuilder.CreateRoutesFrom()
.CurrentAssembly()
.WithActionNamesWithUnderscoresAsSeperatedRoutes()
.IgnoreAspNetMvcDefaultRoute("Home","Index")
.AssignRoutes(routes);
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
public class ExplicitRouteAttribute : Attribute
{
template<typename T>
void array_merge(T* first1, T* first2, T* second1, T* second2, T* result){
bool first_longest = (first2 -1 - first1) > (second2 -1 - second1);
while((first1 != first2) && (second1 != second2)){
if(*first1 < *second1)
*result = *first1++;
else
*result = *second1++;
@loosechainsaw
loosechainsaw / C++ Organisation
Created March 11, 2012 11:50
Howto organise classes that have reference to each other
template<typename T>
class array{
public:
array(){
elements_ = new T[10];
size_ = 10;
}
array(int size){
elements_ = new T[size];
@loosechainsaw
loosechainsaw / cppmove.cpp
Created March 25, 2012 11:34
C++ Move Semantics
#include <algorithm>
#include <iostream>
template<typename T>
class Array {
public:
template<typename E>
class ArrayIterator {
public:
ArrayIterator(Array<E>& elements, int index) : position_(index), elements_(elements) {
@loosechainsaw
loosechainsaw / uRest json
Created August 17, 2012 06:45
Sample Json for uRest
{
"DisplayName": "php user",
"Username": "php",
"Email": "[email protected]",
"Password": "xxxxxx",
"MemberTypeAlias": "WebsiteUser",
"Roles": [
"Support"
]
}
@loosechainsaw
loosechainsaw / MemberHandlerUpdate
Created August 17, 2012 07:37
Updated MemberHandler
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Security;
using System.Runtime.InteropServices;
using OpenRasta.Web;
using umbraco.cms.businesslogic.member;
using uREST.Core.Attributes;
using uREST.Core.Handlers;
@loosechainsaw
loosechainsaw / UpdatedHandler.cs
Created August 17, 2012 08:05
Updated Handler
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Security;
using System.Runtime.InteropServices;
using OpenRasta.Web;
using umbraco.cms.businesslogic.member;
using uREST.Core.Attributes;
using uREST.Core.Handlers;
@loosechainsaw
loosechainsaw / auditinginterceptor.cs
Created August 21, 2012 13:55
Auditing Interceptor Example
using System;
using System.Linq;
using System.Reflection;
using Castle.Core;
using Castle.DynamicProxy;
using Castle.MicroKernel.Proxy;
using Castle.MicroKernel.Registration;
using Castle.Windsor;
namespace WindsorExamples
@loosechainsaw
loosechainsaw / dproxy.cs
Created August 28, 2012 13:56
Dynamic Proxy
using System;
using System.Linq;
using System.Reflection;
using Castle.DynamicProxy;
namespace DpWorkshop
{
public class Person
{
@loosechainsaw
loosechainsaw / cwdpf.cs
Created August 28, 2012 14:15
Container with Dynamic Proxy Fruit
using System;
using System.Reflection;
using Castle.Core;
using Castle.DynamicProxy;
using Castle.MicroKernel.Registration;
using Castle.Windsor;
namespace DpWorkshop
{