Skip to content

Instantly share code, notes, and snippets.

View johnnyreilly's full-sized avatar

John Reilly johnnyreilly

View GitHub Profile
@johnnyreilly
johnnyreilly / comparers.js
Last active September 2, 2015 14:53
Helper functions for sorting arrays by multiple criteria
function composeComparers(...comparers) {
return comparers.reduce((prev, curr) => (a, b) => prev(a, b) || curr(a, b));
}
function stringComparer(propLambda) {
return (obj1, obj2) => {
const obj1Val = propLambda(obj1) || '';
const obj2Val = propLambda(obj2) || '';
return obj1Val.localeCompare(obj2Val);
};
<!DOCTYPE html>
<!-- saved from url=(0094)http://johnnyreilly.github.io/jQuery.Validation.Unobtrusive.Native/AdvancedDemo/Globalize.html -->
<html lang="en" class=" js flexbox flexboxlegacy canvas canvastext webgl no-touch geolocation postmessage websqldatabase indexeddb hashchange history draganddrop websockets rgba hsla multiplebgs backgroundsize borderimage borderradius boxshadow textshadow opacity cssanimations csscolumns cssgradients cssreflections csstransforms csstransforms3d csstransitions fontface generatedcontent video audio localstorage sessionstorage webworkers applicationcache svg inlinesvg smil svgclippaths"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Globalize - jQuery Validation Unobtrusive Native</title>
<link href="https://johnnyreilly.github.io/jQuery.Validation.Unobtrusive.Native/Content/
@johnnyreilly
johnnyreilly / PartialExtensions.cs
Created August 24, 2012 11:31
HTML Helper for rendering attribute encoded PartialViews
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Html;
namespace My.Helpers
{
/// <summary>
/// MVC HtmlHelper extension methods - html element extensions
/// </summary>
public static class PartialExtensions
@johnnyreilly
johnnyreilly / GlobalizeUrls.cs
Last active October 10, 2015 06:58
A monkey patch for jquery.validate.js that allows validation to be internationalised
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Hosting;
using System.IO;
using System.Globalization;
namespace My.Helpers
{
@johnnyreilly
johnnyreilly / Crm.svc.cs
Created September 22, 2012 05:50
A class which when added to a web application exposes the provides an OData service on top of CRM / xRM
using System;
using System.Collections.Generic;
using System.Data.Services;
using System.Data.Services.Common;
using System.Linq;
using System.Web;
using System.ServiceModel.Web;
using Microsoft.Xrm.Client;
using log4net;
@johnnyreilly
johnnyreilly / BundleConfig.cs
Created October 5, 2012 12:15
Using Web Optimization with MVC 3
using System.Web;
using System.Web.Optimization;
namespace WebOptimizationWithMvc3.App_Start
{
public class BundleConfig
{
// For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725
public static void RegisterBundles(BundleCollection bundles)
{
@johnnyreilly
johnnyreilly / HomeController.cs
Created October 22, 2012 14:34
Documenting a JsonValueProviderFactory Gotcha (MVC 3 meet Dictionary)
//...
[HttpPost]
public ActionResult PostDictionary(Dictionary<string, string> myDictionary)
{
return Json(myDictionary);
}
//...
@johnnyreilly
johnnyreilly / Contact.cs
Created November 2, 2012 11:21
Demo of how to easily serialize and deserialize objects to and from XML
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.239
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
@johnnyreilly
johnnyreilly / BootstrapBundleConfig.cs
Last active December 11, 2015 02:09
Twitter.Bootstrap.MVC4 meet Bootstrap Datepicker - now with Internationalization
using System;
using System.Web;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Globalization;
using System.IO;
using System.Linq;
namespace BootstrapSupport
{
@johnnyreilly
johnnyreilly / FieldValidationAfter.cs
Last active December 13, 2015 16:59
Showing how to use expressions with constructors to drive strongly typed validation.
public class FieldValidation
{
public FieldValidation(string fieldName, string message)
{
FieldName = fieldName;
Message = message;
}
public string FieldName { get; set; }
public string Message { get; set; }