Skip to content

Instantly share code, notes, and snippets.

Adam Bar NOtherDev

Block or report user

Report or block NOtherDev

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@NOtherDev
NOtherDev / ModelMapperWithNamingConventions.cs
Created Jan 6, 2012
NHibernate mapping-by-code naming convention resembling Fluent's
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>();
@NOtherDev
NOtherDev / LoquaciousXml.cs
Created Feb 18, 2012
Loquacious XML builder
View LoquaciousXml.cs
internal class NodeBuilder
{
private readonly XmlDocument _doc;
private readonly XmlNode _node;
public NodeBuilder(XmlDocument doc, XmlNode node)
{
_doc = doc;
_node = node;
}
@NOtherDev
NOtherDev / gist:1902873
Created Feb 24, 2012
Source code for "On loquacious interfaces, again" post
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",
@NOtherDev
NOtherDev / gist:2274614
Created Apr 1, 2012
Strongly typed and well-controlled links within ASP.NET MVC areas
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;
}
@NOtherDev
NOtherDev / ControllerActionInvokerWithDefaultJsonResult.cs
Created Sep 22, 2012
ASP.NET MVC: Replacing the default ActionInvoker to do something useful with non-ActionResult return types
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);
}
@NOtherDev
NOtherDev / OrderAndRankBy.cs
Last active Dec 12, 2015
Extension method for ordering an IEnumerable<T> with custom ranking. See blog post for description: http://notherdev.blogspot.com/2013/02/extension-for-ordering-enumerable-with-ranking.html
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;
}
@NOtherDev
NOtherDev / server.coffee
Last active Aug 29, 2015
ShareJS 0.7.3 server-side code
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'
@NOtherDev
NOtherDev / client.html
Last active Aug 29, 2015
ShareJS 0.7.3 web client-side code
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>
@NOtherDev
NOtherDev / attachSelect.js
Created Nov 5, 2014
ShareJS attachSelect
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;
},
@NOtherDev
NOtherDev / binary.js
Last active Feb 9, 2016 — forked from ntulip/BinaryJS
Binary JS
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;
You can’t perform that action at this time.