Skip to content

Instantly share code, notes, and snippets.

View jmarnold's full-sized avatar

Josh Arnold jmarnold

View GitHub Profile
@jmarnold
jmarnold / Clock.spark
Created February 10, 2012 22:26
Spark partial issues
<time datetime="0000-00-00">
<Display property="CurrentTime.DayOfWeek" />
<Display property="CurrentTime.TimeOfDay" />
<Display property="CurrentTime.Date" />
</time>
@jmarnold
jmarnold / IProjectionConvention.cs
Created February 2, 2012 05:15
Conventions and Projections
public interface IProjectionConvention<T>
{
bool Matches(Accessor accessor);
void Modify(Accessor accessor, Projection<T> projection);
}
@jmarnold
jmarnold / FubuMVC.cs
Created January 23, 2012 05:58
Fubu Bootstrapping
public static class AppStartFubuMVC
{
public static void Start()
{
ObjectFactory.Initialize(x =>
{
// Custom container configuration
});
FubuApplication
@jmarnold
jmarnold / backbone.extensions.js
Created January 17, 2012 20:30
Found the newer one
Backbone.Model.prototype.dependentProperty = function (name, origin, evaluator) {
var update = function () {
var value = evaluator.call(this);
var hash = {};
hash[name] = value;
this.set(hash);
};
this.bind('change:' + origin, function () {
update.call(this);
});
@jmarnold
jmarnold / validationPolicy.js
Created January 8, 2012 08:26
fubuvalidation.js integration
$.continuations.applyPolicy({
matches: function (continuation) {
return $('#' + continuation.correlationId).size() != 0;
},
execute: function (continuation) {
if (!continuation.errors) {
continuation.errors = [];
}
$.fubuvalidation.process(continuation);
}
@jmarnold
jmarnold / pluginrunner.cs
Created January 8, 2012 05:23 — forked from schotime/pluginrunner.cs
Plugin Runner
public interface IActivity
{
void Run();
bool Matches(int i);
}
public class PluginActivator
{
private readonly IContainer _container;
@jmarnold
jmarnold / validation-preview.js
Created January 8, 2012 04:35
This one's for Alex
$(document).ready(function() {
var preview = $('#mainForm').data('validation-preview');
$(':input', '#mainForm').change(function() {
$.ajax({
type: 'POST',
data: $('#mainForm').formSerialize(),
url: preview,
beforeSend: function(xhr) {
this.correlationId = 'mainForm';
$.continuations.setupRequest.call(this, xhr);
@jmarnold
jmarnold / RequestCorrelation.cs
Created January 7, 2012 04:13
Correlating requests
public class RequestCorrelation : IConfigurationAction
{
public void Configure(BehaviorGraph graph)
{
graph
.Behaviors
.Each(chain => chain.Prepend(new Wrapper(typeof(SetCorrelationHeaders))));
}
}
@jmarnold
jmarnold / correlationPolicy.js
Created January 6, 2012 23:06
correlation policy for dialogs
var correlationPolicy = {
matches: function (continuation) {
return continuation.correlationId != null && continuation.correlationId != '';
},
execute: function (continuation) {
if (continuation.errors && continuation.errors.length != 0) {
return;
}
var dialog = $('#' + continuation.correlationId).parents('.dialog');
{
success: true/false,
refresh: true/false
message: '',
errors: []
}