Skip to content

Instantly share code, notes, and snippets.

Pete Smith beyond-code-github

View GitHub Profile
@beyond-code-github
beyond-code-github / changetrackedarray.js
Last active Aug 29, 2015
Skeleton change tracked array extender for knockout.kj
View changetrackedarray.js
ko.extenders.trackArrayChange = function (target, track) {
if (track) {
target.isDirty = ko.observable(false);
target.added = ko.observableArray([]);
target.removed = ko.observableArray([]);
var addItem = function (item) {
//...
};
@beyond-code-github
beyond-code-github / example.js
Last active Aug 29, 2015
Example usage of change tracking in a complex view model, including a primitive array
View example.js
var viewModel = {
Name: ko.observable("Pete"),
Age: ko.observable(29),
Skills: ko.observableArray([
"TDD", "Knockout", "WebForms"
}),
Occupation: ko.observable("Developer")
};
applyChangeTracking(viewModel);
@beyond-code-github
beyond-code-github / arraysubscriptions.js
Last active Aug 29, 2015
Suscribing to array changes using the new arraychange subscriptions in knockout 3.0
View arraysubscriptions.js
//....
//....
target.getChanges = function () {
var result = {
added: target.added(),
removed: target.removed()
};
return result;
@beyond-code-github
beyond-code-github / applychangetrackingmodified.js
Last active Aug 29, 2015
Modified version of apply change tracking to observable that properly track arrays
View applychangetrackingmodified.js
//....
//....
var applyChangeTrackingToObservable = function (observable) {
// Only apply to basic writeable observables
if (observable && !observable.nodeType && !observable.refresh && ko.isObservable(observable)) {
if (observable.isObservableArray) {
observable.extend({ trackArrayChange: true });
}
else {
@beyond-code-github
beyond-code-github / applychangetracking.cs
Created Jan 31, 2014
Original code for applying change tracking to observables from Part 1
View applychangetracking.cs
....
....
var applyChangeTrackingToObservable = function (observable) {
// Only apply to basic writeable observables
if (observable && !observable.nodeType && !observable.refresh && ko.isObservable(observable)) {
if (!observable.isDirty) observable.extend({ trackChange: true });
}
};
@beyond-code-github
beyond-code-github / addremoveexample.js
Last active Aug 29, 2015
Tracking array adds and removes is not quite as simple as it first appears...
View addremoveexample.js
// Initialise array with some data and track changes
var trackedArray = ko.observableArray([1,2,3]).extend({trackArrayChanges: true});
trackedArray.getChanges();
// -> { } No changes yet
trackedArray.push(4);
trackedArray.pop();
trackedArray.getChanges();
@beyond-code-github
beyond-code-github / changetracking.js
Last active Aug 29, 2015
Change tracking implementation including support for primitive arrays
View changetracking.js
var getObjProperties = function (obj) {
var objProperties = [];
var val = ko.utils.unwrapObservable(obj);
if (val !== null && typeof val === 'object') {
for (var i in val) {
if (val.hasOwnProperty(i)) objProperties.push({ "name": i, "value": val[i] });
}
}
@beyond-code-github
beyond-code-github / test.markdown
Created Mar 18, 2014
Hello world requests/second
View test.markdown

#Plain text, 10,000 req, 8 concurrent

  • Nancy - Nowin - 2642,2938,3435,2942,3216,4006 = 3204
  • Superscribe - Nowin - 4111,3767,3716,3350,3306,3742 = 3665
  • Nancy - System.Web - 3766,4042,3680,3944,4129,4065 = 3937
  • Superscribe - System.Web - 5724,5790,5506,4355,4293,5783 = 5241
  • Nancy - Helios - 5681,5817,5896,4407,4253,5854 = 5318
  • Superscribe - Helios - 6161,6788,6583,5685,4278,6872 = 6061
View domaindrivedilemmas.markdown

Domain Driven Dilemmas

I'm fairly new to domain driven design and I've been scratching my head for a while over this issue.

Here are my domain rules

  • A Record entity has a document of key value pairs
  • We can update the document for a record by providing the updated key value pairs
  • When we update a document we must calculate some values according to some parsed expressions.
View Stackoverflow_24762539
using Autofac;
using Xunit;
namespace LifetimeScope
{
public class Stackoverflow24762539
{
[Fact]
public void Repro()
You can’t perform that action at this time.