Skip to content

Instantly share code, notes, and snippets.

View lucamilan's full-sized avatar
:bowtie:
I may be slow to respond.

Luca Milan lucamilan

:bowtie:
I may be slow to respond.
View GitHub Profile
@nathansmith
nathansmith / module_pattern_init.js
Created January 11, 2010 17:08
Init + Module Pattern JS
// JS Module Pattern:
// http://j.mp/module-pattern
// Redefine: $, window, document, undefined.
var APP = (function($, window, document, undefined) {
// Automatically calls all functions in APP.init
$(document).ready(function() {
APP.go();
});
public class PocoInvoker : ControllerActionInvoker {
protected override ActionResult CreateActionResult (ControllerContext controllerContext, ActionDescriptor actionDescriptor, object actionReturnValue) {
if (!(actionReturnValue is ActionResult)) {
controllerContext.Controller.ViewData.Model = actionReturnValue;
return new PocoResult (actionReturnValue);
}
return base.CreateActionResult (controllerContext, actionDescriptor, actionReturnValue);
}
}
@ntotten
ntotten / AccountController.cs
Created March 21, 2011 18:31
ASP.NET MVC 3 Simple Authorization
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Facebook;
using MyFacebookSite3434.Models;
using System.Web.Security;
namespace MyFacebookSite3434.Controllers
@kamranayub
kamranayub / gist:935461
Created April 21, 2011 21:00
This ProxyConverter can be used with AutoMapper to help when converting Entity Framework proxied objects (i.e. DynamicProxy_xxxxxxx). Room for improvement. See: http://stackoverflow.com/questions/3441916/automapper-mapping-issue-with-inheritance-and-abstr
// See: http://stackoverflow.com/questions/3441916/automapper-mapping-issue-with-inheritance-and-abstract-base-class-on-collection/5749579#5749579
//
// For use with AutoMapper
public class ProxyConverter<TSource, TDestination> : ITypeConverter<TSource, TDestination>
where TSource : class
where TDestination : class
{
public TDestination Convert(ResolutionContext context)
{
// Get dynamic proxy base type
@Scooletz
Scooletz / ActionInvoker.cs
Created May 24, 2011 21:25
ActionProviders
using System.Web.Mvc;
namespace ActionProviders
{
/// <summary>
/// The extended controller actions invoker, using other than controllers action providers.
/// </summary>
public class ActionInvoker : ControllerActionInvoker
{
private readonly IActionProvider[] _actionProviders;
@gnarf
gnarf / jQuery.ajaxQueue.min.js
Created June 21, 2011 23:52
jQuery.ajaxQueue - A queue for ajax requests
/*
* jQuery.ajaxQueue - A queue for ajax requests
*
* (c) 2011 Corey Frang
* Dual licensed under the MIT and GPL licenses.
*
* Requires jQuery 1.5+
*/
(function(a){var b=a({});a.ajaxQueue=function(c){function g(b){d=a.ajax(c).done(e.resolve).fail(e.reject).then(b,b)}var d,e=a.Deferred(),f=e.promise();b.queue(g),f.abort=function(h){if(d)return d.abort(h);var i=b.queue(),j=a.inArray(g,i);j>-1&&i.splice(j,1),e.rejectWith(c.context||c,[f,h,""]);return f};return f}})(jQuery)
@gamlerhart
gamlerhart / BachLoad.cs
Created June 29, 2011 20:18
RavenDB-Documents
var order = session.Query<Order>()
.Customize(x => x.Include<Order>(o=>o.CustomerId)) // Load also the costumer
.First();
var customer = session.Load<Customer>(order.CustomerId);
anonymous
anonymous / customviewengine.cs
Created July 12, 2011 05:20
CustomViewEngine
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace demo2
{
/// <summary>
/// From Scott Hanselman
@leniency
leniency / IQueryableExtensions.cs
Created August 1, 2011 22:31
Modifications to allow CamelCase.NestedProperties
/// <summary>
/// Provides projection mapping from an IQueryable sourceto a target type.
///
/// This allows from strongly-typed mapping and querying only necessary fields from the database.
/// It takes the place of Domain -> ViewModel mapping as it allows the ViewModel to stay as
/// IQueryable. AutoMapper works on in-memory objects and will pull all full records to perform
/// a collection mapping. Use AutoMapper for Input -> Domain scenarios, but not DAL.
///
/// Reference: http://devtrends.co.uk/blog/stop-using-automapper-in-your-data-access-code
/// </summary>
@lucamilan
lucamilan / gist:1195328
Created September 5, 2011 15:58
Empty VS2010 Solution
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal