Skip to content

Instantly share code, notes, and snippets.

@yagopv
yagopv / spalinks.js
Created May 9, 2012 15:09
jquery widget for creating Single Page Applications (http://mvcspaapplication.apphb.com)
@yagopv
yagopv / gist:2880359
Last active October 5, 2015 21:37
Serialize form to JSON
(function( $ ){
$.fn.serializeObject=function() {
var json = {};
jQuery.map($(this).serializeArray(), function(n, i){
json[n['name']] = n['value'];
});
return json;
};
})( jQuery );
@yagopv
yagopv / modulo_multi.js
Created November 13, 2012 19:42
Javascript patterns. Revealing Module multi-instance
//Modulo multi
function Cuenta(numerocuenta, saldo) {
this.numerocuenta = numerocuenta;
this.saldo = saldo;
};
var Contabilidad = function () {
var _cuentas,
_saldototal,
@yagopv
yagopv / gist:4067920
Created November 13, 2012 19:43
Javascript patterns. Revealing Module Singleton
//Modulo
function Cuenta(numerocuenta, saldo) {
this.numerocuenta = numerocuenta;
this.saldo = saldo;
};
var Contabilidad = function () {
var _cuentas,
_saldototal,
@yagopv
yagopv / prototype.js
Created November 13, 2012 19:43
Javascript patterns. Revealing Prototype
//Prototype
function Cuenta(numerocuenta, saldo) {
this.numerocuenta = numerocuenta;
this.saldo = saldo;
};
var Contabilidad = function(cuentas) {
//Propiedades públicas
this.Cuentas = cuentas || new Array();
@yagopv
yagopv / gist:4077405
Created November 15, 2012 08:33
Javascript patterns. Module
(function(MyApp) {
// private vars and methods
var myprivatevar = true
_myprivatemethod = function() {};
// public methods
MyApp.mypublicmethod = _myprivatemethod();
})(window.MyApp = window.MyApp || { });
@yagopv
yagopv / gist:4451663
Created January 4, 2013 10:59
DDD. Include multiple Related Entities using eager loading
public static IQueryable<T> IncludeMultiple<T>(this IQueryable<T> query, params Expression<Func<T, object>>[] includes)
where T : class
{
if (includes != null)
{
query = includes.Aggregate(query,
(current, include) => current.Include(include));
}
return query;
@yagopv
yagopv / gist:5082782
Last active December 14, 2015 11:58
Get outer HTML from jquery object
$element = $("<div><p>Hola</p></div><div><p>Hola</p></div><div><p>Hola</p></div>");
$('<div>').append($element.clone()).html();
@yagopv
yagopv / gist:5169147
Created March 15, 2013 11:17
Close bootstrap nav on link click
$(".nav-collapse .nav li a").on("click", function() { $(".nav-collapse").collapse("hide"); });
@yagopv
yagopv / gist:5566634
Created May 13, 2013 07:13
Value Object
/// <summary>
/// Address
/// For this Domain-Model, the Address is a Value-Object
/// </summary>
public class Address
{
/// For this Domain-Model, the Address is a Value-Object
/// 'sets' are private as Value-Objects must be immutable,
/// so the only way to set properties is using the constructor