Skip to content

Instantly share code, notes, and snippets.

@NOtherDev
NOtherDev / wwcd-talk.md
Last active February 7, 2017 20:37
WWCD links
@NOtherDev
NOtherDev / binary.js
Last active February 9, 2016 06:30 — forked from ntulip/BinaryJS
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;
@NOtherDev
NOtherDev / attachSelect.js
Created November 5, 2014 08:35
ShareJS attachSelect
// 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 / client.html
Last active August 29, 2015 14:08
ShareJS 0.7.3 web client-side code
<!-- 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 / server.coffee
Last active August 29, 2015 14:08
ShareJS 0.7.3 server-side code
# 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 / OrderAndRankBy.cs
Last active December 12, 2015 08:49
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
// 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 / ControllerActionInvokerWithDefaultJsonResult.cs
Created September 22, 2012 17:26
ASP.NET MVC: Replacing the default ActionInvoker to do something useful with non-ActionResult return types
// 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 / gist:2274614
Created April 1, 2012 11:00
Strongly typed and well-controlled links within ASP.NET MVC areas
[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 / gist:1902873
Created February 24, 2012 18:42
Source code for "On loquacious interfaces, again" post
// 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 / LoquaciousXml.cs
Created February 18, 2012 21:32
Loquacious XML builder
internal class NodeBuilder
{
private readonly XmlDocument _doc;
private readonly XmlNode _node;
public NodeBuilder(XmlDocument doc, XmlNode node)
{
_doc = doc;
_node = node;
}