About mtranter


Cypher.Net – A Neo4j Cypher API

I’ve knocked up a .Net client for the NoSQL Database Neo4j. Specifically, it’s an API the new Cypher Transactional Endpoint.

I’ve put the code over here.

If you haven’t used Neo4j (or any graph Database) you should head over here and check it out. And for a really cool look at graphs in action, check out Rik’s awesome articles on using Neo4j with Beer and IKEA.
Continue reading

Introducing – MVC Tables

As briefly mentioned here I’ve finally finished a workable version of a sortable, pageable, filterable table framework for ASP.Net MVC. I’ve creatively dubbed this project “MVC Tables”.

I’ve put the code over at GitHub and there is a live example running on the Northwind OData service at http://mvctables.azurewebsites.net/
Continue reading

Copying jQuery events from one element to another

I dug around for way too long today trying to figure out how to copy jQuery event handlers from one element to another.

I finally found the solution..

    function copyEvents(source, target) {
        var evs = $._data(source[0], 'events');  
        for (var ev in evs) {
            for (var i = 0; i < evs[ev].length; i++)
                $.fn[ev].apply(target, [evs[ev][i].handler]);

I’ve left a demo here -> http://jsfiddle.net/mtranter/gJXaR/4/

MVC Tables


Update 12-Sep-2013: https://mtranter.com/2013/09/11/mvc-tables/

As part of an MVC portal/admin app we’ve been working on recently, we required HTML Table rendering functionality that supported AJAXy paging/sorting/filtering etc.

We initially tried using the awesome MVC classes for jquery DataTables, but this didn’t quite fit our needs. We didn’t need a lot of in-line editing, but what we did need was the ability to render cells from display/editor templates and partial views etc.

What we came up with was a fluently configurable table framework that used all that MVC goodness to easily generate highly customisable tables. These tables are sortable, pagable and filterable all on the server side via AJAX.
Continue reading

Recursive Linq

I’ve been using Common Table Expressions a lot lately. Particularly when populating SQL Databases with test data. I recommend checking them out if you write slightly more than a modicum of SQL.

Just briefly – if you’re not familiar with CTE’s or their uses – imagine needing to populate a table like this: Months(Id int, MonthNo int, Year int) – with values between say Jan 2000 and Jan 2010. You might do something like this…

    WITH months(id, mnth, yr) 
     AS (SELECT 1, 
         UNION ALL 
         SELECT id + 1, 
                ( mnth % 12 ) + 1, 
                yr + ( mnth / 12 ) 
         FROM   months 
         WHERE  yr < 2010) 
FROM   months 
OPTION(maxrecursion 500)

Now onto the Recursive Linq bit (not to be confused with a Recursive Link.)

Just recently, I was building a Schedule class that required functionality similar to the above SQL. That is, I needed to split some span of time up into N DateTimes based on some function.
Continue reading

WCF Delegation Cheat Sheet

I’ve struggled getting kerberos delegation to work with WCF – say to access a database using Integrated Security via a ‘double hop’ – too often… The below is a (very) quick and dirty cheat sheet I use to get it all up and running..

  1. Choose an appropriate binding – generally wsHttpBinding or netTcpBinding. I believe you can get basicHttpBinding to use delegation, given you use transport level security, but I’ve not tried this myself.
  2. Ensure your service behaviours are configured with the correct impersonateCallerForAllOptions value
       <behavior name="ContourBehavior">
          <serviceAuthorization impersonateCallerForAllOperations="true" />
  3. Continue reading