View ModelMapperWithNamingConventions.cs
// NHibernate mapping-by-code naming convention resembling Fluent's | |
// See the blog post: http://notherdev.blogspot.com/2012/01/mapping-by-code-naming-convention.html | |
public class ModelMapperWithNamingConventions : ConventionModelMapper | |
{ | |
public const string ForeignKeyColumnPostfix = "_id"; | |
public const string ManyToManyIntermediateTableInfix = "To"; | |
public const char ElementColumnTrimmedPluralPostfix = 's'; | |
private readonly List<MemberInfo> _ignoredMembers = new List<MemberInfo>(); |
View LoquaciousXml.cs
internal class NodeBuilder | |
{ | |
private readonly XmlDocument _doc; | |
private readonly XmlNode _node; | |
public NodeBuilder(XmlDocument doc, XmlNode node) | |
{ | |
_doc = doc; | |
_node = node; | |
} |
View gist:1902873
// see http://notherdev.blogspot.com/2012/02/on-loquacious-interfaces-again.html | |
public class Program | |
{ | |
static void Main(string[] args) | |
{ | |
// the Building instance created "manually" | |
var classicBuilding = new Building() | |
{ | |
Address = "1 Example Street", |
View gist:2274614
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] | |
public class LinkWithinAreaAttribute : Attribute | |
{ | |
public string AreaName { get; private set; } | |
public string OrSwitchTo { get; set; } | |
public LinkWithinAreaAttribute(string areaName) | |
{ | |
AreaName = areaName; | |
} |
View ControllerActionInvokerWithDefaultJsonResult.cs
// ASP.NET MVC: Replacing the default ActionInvoker to do something useful with non-ActionResult return types | |
// See more: http://notherdev.blogspot.com/2012/09/non-actionresult-return-type-aspnet-mvc.html | |
public class MyControllerFactory : DefaultControllerFactory | |
{ | |
public override IController CreateController(RequestContext context, string controllerName) | |
{ | |
var controller = base.CreateController(context, controllerName); | |
return ReplaceActionInvoker(controller); | |
} |
View OrderAndRankBy.cs
// Extension method for ordering an IEnumerable<T> with custom ranking. | |
// http://notherdev.blogspot.com/2013/02/extension-for-ordering-enumerable-with-ranking.html | |
public class Ranked<T> | |
{ | |
public Ranked(T item, int rank) | |
{ | |
Item = item; | |
Rank = rank; | |
} |
View server.coffee
# based on https://github.com/share/ShareJS/blob/master/examples/ws.coffee | |
# see http://notherdev.blogspot.com/2014/10/sharejs-073-working-example.html | |
{Duplex} = require 'stream' | |
http = require 'http'; | |
connect = require 'connect' | |
morgan = require 'morgan' | |
serveStatic = require 'serve-static' | |
argv = require('optimist').argv | |
livedb = require 'livedb' |
View client.html
<!-- see http://notherdev.blogspot.com/2014/10/sharejs-073-working-example.html --> | |
<!DOCTYPE html> | |
<html> | |
<head lang="en"> | |
<meta charset="UTF-8"> | |
</head> | |
<body> | |
<textarea id="pad"></textarea> |
View attachSelect.js
// code that allows attaching ShareJS to HTML <select> fields | |
sharejs.Doc.prototype.attachSelect = function (innerElem, ctx) { | |
var i; | |
var rawValue = innerElem.value; | |
var elem = { | |
get value () { | |
return rawValue; | |
}, |
View binary.js
/* | |
* Binary Ajax 0.1.7 | |
* Copyright (c) 2008 Jacob Seidelin, cupboy@gmail.com, http://blog.nihilogic.dk/ | |
* Licensed under the MPL License [http://www.nihilogic.dk/licenses/mpl-license.txt] | |
*/ | |
var BinaryFile = function(strData, iDataOffset, iDataLength) { | |
var data = strData; | |
var dataOffset = iDataOffset || 0; |
OlderNewer