Skip to content

Instantly share code, notes, and snippets.

View MatthewBarker's full-sized avatar

Matt Barker MatthewBarker

  • Cheadle, Cheshire, England
View GitHub Profile
@MatthewBarker
MatthewBarker / jsonp.js
Created February 18, 2015 14:07
JSONP request function
/*jslint browser: true*/
/*global define, exports, module*/
/**
A module that makes jsonp requests.
@module jsonp
@author Matt Barker
*/
(function (factory) {
'use strict';
@MatthewBarker
MatthewBarker / wikipedia-jsonp.js
Created February 18, 2015 14:14
Make JSONP requests to the Wikipedia API
/*jslint browser: true*/
/*global define, exports, require, module, jsonp*/
/**
A module for Jsonp requests to the Wikipedia API.
@module wikipedia-jsonp
@author Matt Barker
@requires jsonp
*/
(function (factory) {
@MatthewBarker
MatthewBarker / DataService.cs
Created February 18, 2015 15:54
Server side sorting, paging & filtering from DataTable to Kendo UI Grid
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using Newtonsoft.Json;
/// <summary>
/// Represents the data service.
/// </summary>
public class DataService
@MatthewBarker
MatthewBarker / array-spec.js
Created February 24, 2015 15:43
Jasmine 2.2.0 + Require.js: How to use Jasmine's boot file
/*global describe , it, expect*/
describe('Array', function () {
'use strict';
describe('.push()', function () {
it('should append a value', function () {
var arr = [];
arr.push('foo');
@MatthewBarker
MatthewBarker / AutomapServiceBehavior.cs
Created February 25, 2015 11:55
AutomapServiceBehavior: This avoids multi threading issues with Automapper in a class library used by WCF. A static MapperConfig class is called by the service behaviour.
namespace ServiceLayer
{
using System;
using System.Collections.ObjectModel;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using LAI.Data.Controllers.Mappers;
/// <summary>
@MatthewBarker
MatthewBarker / bdd-feature.js
Created February 26, 2015 15:38
Provides simplified Gherkin style syntax for Mocha tests by extending the functions in the standard 'BDD' interface.
/*global define, Mocha*/
/**
Provides simplified Gherkin style syntax for Mocha tests by extending the functions in the standard 'BDD' interface.
** See {@link http://mochajs.org/#bdd-interface} for Mocha documentation.
** Feature and Scenario act as a wrapper for 'describe'
** Given, When, Then, But & And act as a wrapper for 'it'
** Feature, Scenario, Given, When, Then, But & And functions are capitalised as otherwise some of them would conflict with CoffeeScript keywords.
@module bdd-feature
@author Matt Barker
@MatthewBarker
MatthewBarker / repeat.js
Created March 24, 2015 10:17
Repeat polyfill - taken from MDN for use in JSfiddle
if (!String.prototype.repeat) {
String.prototype.repeat = function(count) {
'use strict';
if (this == null) {
throw new TypeError('can\'t convert ' + this + ' to object');
}
var str = '' + this;
count = +count;
if (count != count) {
count = 0;
@MatthewBarker
MatthewBarker / filter.js
Created March 24, 2015 10:18
Filter polyfill - taken from MDN for use in JSfiddle
if (!Array.prototype.filter) {
Array.prototype.filter = function(fun/*, thisArg*/) {
'use strict';
if (this === void 0 || this === null) {
throw new TypeError();
}
var t = Object(this);
var len = t.length >>> 0;
@MatthewBarker
MatthewBarker / kendoSparkline.js
Created March 24, 2015 10:20
Knockout-Kendo sparkline custom binding
ko.kendo.bindingFactory.createBinding({
name: 'kendoSparkline',
bindingName: 'kendoSparkline',
watch: {
data: function(value) {
ko.kendo.setDataSource(this, value);
}
}
});
@MatthewBarker
MatthewBarker / kendoChart.js
Created March 24, 2015 10:22
Knockout-Kendo custom chart binding override to watch the graph options
ko.kendo.bindingFactory.createBinding({
name: 'kendoChart',
watch: {
data: function (value) {
ko.kendo.setDataSource(this, value);
},
options: function (value) {
//unwrap observables from the options object
var jsonOptions = ko.toJSON(value);
//convert the unwrapped json to a plain object