Skip to content

Instantly share code, notes, and snippets.

@rauhryan
rauhryan / gist:735063
Created December 9, 2010 17:58
output of select box
<select>
<option> Select ... </option>
<option value='__ko.bindingHandlers.options.optionValueDomData__'>Hi</option>
</select>
(function () {
// Normally, SELECT elements and their OPTIONs can only take value of type 'string' (because the values
// are stored on DOM attributes). ko.selectExtensions provides a way for SELECTs/OPTIONs to have values
// that are arbitrary objects. This is very convenient when implementing things like cascading dropdowns.
ko.selectExtensions = {
readValue : function(element) {
if (element.tagName == 'OPTION') {
var valueAttributeValue = element.getAttribute("value");
if (valueAttributeValue !== ko.bindingHandlers.options.optionValueDomDataKey)
return valueAttributeValue;
@rauhryan
rauhryan / gist:756357
Created December 27, 2010 17:54
use of func hash in fubu...
public override string CreateTemplate(object input, Func<object, object>[] hash)
{
string url = Pattern;
_routeInputs.Where(x => x.CanTemplate(input))
.Each(r => url = r.Substitute((T)input, url));
if (hash != null)
hash.Each(func =>
{
public class NavigationPolicy : IConfigurationAction
{
public void Configure(BehaviorGraph graph)
{
var visitor = new NavigationVisitor(graph.Observer);
graph.VisitBehaviors(visitor);
visitor.Register((type, def) => graph.Services.AddService(def));
}
}
{% model Model:SweetVids.Web.Models.TestModel %}
<html>
<head>
<title>{% block title %}Django View Engine Demo{% endblock title %}</title>
</head>
<body>
<h1>Hello {{ Model.FirstName }}</h1>
</body>
</html>
using System;
namespace NDjango
{
public class NDjangoAttribute : Attribute
{
public string View { get; set; }
public NDjangoAttribute(string view)
{
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using FieldBook.Core.Domain;
using FieldBook.Core.Navigation;
using FieldBook.Core.Persistence;
using FieldBook.Interface.Actions.Permissions;
using FieldBook.Interface.Dtos;
using FubuMVC.Core;
define(["./views/appView" ,"./collections/jobList","./models/job"],
function(app, Jobs, Job) {
var mainView = {
toggleButtons : function (){
if(this.employee && this.task && this.equipment){
$('#create-job').removeAttr('disabled').focus();
@rauhryan
rauhryan / gist:893261
Created March 29, 2011 20:54
Guice vs StructureMap
public class BillingModule extends AbstractModule {
@Override
protected void configure() {
bind(TransactionLog.class).to(DatabaseTransactionLog.class);
bind(CreditCardProcessor.class).to(PaypalCreditCardProcessor.class);
bind(BillingService.class).to(RealBillingService.class);
}
}
@rauhryan
rauhryan / gist:908017
Created April 7, 2011 15:34
ObjectDef example
public class NavigationVisitor : IBehaviorVisitor
{
private readonly IConfigurationObserver _observer;
private readonly ListDependency _policies = new ListDependency(typeof(IEnumerable<IMenuPolicy>));
public NavigationVisitor(IConfigurationObserver observer)
{
_observer = observer;
}