Skip to content

Instantly share code, notes, and snippets.

@samandmoore
samandmoore / baseRouteUsage.js
Last active August 29, 2015 14:15
beforeRender
var PortfolioRoute = BaseRoute.extend({
prepare: function() {
this.promise = …;
return this.promise;
},
render: function() { … },
error: function() { … }
});
require 'html2textile'
first_block = <<END
<div class="column span-3">
<h3 class="storytitle entry-title" id="post-312">
<a href="http://jystewart.net/process/2007/11/converting-html-to-textile-with-ruby/" rel="bookmark">Converting HTML to Textile with Ruby</a>
</h3>
<p>
<span>23 November 2007</span>
@samandmoore
samandmoore / Content.cshtml
Created June 18, 2011 18:38
script helper in app_code
@using System.Web.Mvc;
@helper Script(string scriptName, UrlHelper url) {
<script type="text/javascript" src="@url.Content("~/Scripts/" + scriptName)"></script>
}
example extracted from:
http://www.pluralsight-training.net/microsoft/players/PSODPlayer.aspx?author=scott-allen&name=mvc3-building-ajax&mode=live&clip=0&course=aspdotnet-mvc3-intro
@samandmoore
samandmoore / MacroParamValueOrDefault.cshmtl
Created January 31, 2012 14:02
Umbraco v5 MacroParameters default value
@functions {
object MacroParamValueOrDefault(dynamic paramValue, object defaultValue = null)
{
if(string.IsNullOrEmpty(paramValue)) {
return defaultValue;
} else {
return paramValue;
}
}
}
@samandmoore
samandmoore / UmbracoMacroHelpers.cs
Created March 20, 2012 00:20
Render Macros in Umbraco UserControl
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using System.Web.UI;
using umbraco;
namespace samandmoore
{
@if (DynamicModel.AncestorsOrSelf.Where("metaNoegleord != @0", "null").Any()) {
<meta name="Keywords" content="@DynamicModel.AncestorsOrSelf.Where("metaNoegleord != @0", "null").First().metaNoegleord" />
}
private static void SetupAdminUsers(IKernel kernel)
{
var repository = kernel.Get<IJabbrRepository>();
var chatService = kernel.Get<IChatService>();
if (!repository.Users.Any(u => u.IsAdmin))
{
string defaultAdminUserName = System.Configuration.ConfigurationManager.AppSettings["defaultAdminUserName"];
string defaultAdminPassword = System.Configuration.ConfigurationManager.AppSettings["defaultAdminPassword"];
@samandmoore
samandmoore / render.js
Created May 31, 2012 01:19 — forked from mxriverlynn/render.js
Help me clean this up
// This is the render method in the `ItemView` in my Backbone.Marionette plugin.
// It's a giant method - far too much happening in this one method, and poor
// use of memory with all of the methods that get re-defined on every use.
//
// It desperately needs to be cleaned up. But I can't do something quite as
// simple as just move the inner functions on to the ItemView itself. There
// are too many methods on the ItemView already.
//
// Suggestions? What are some good patterns to clean this up?
//
@samandmoore
samandmoore / SortLinkExtensions.cs
Created June 20, 2012 01:12
Html Helper for creating a link that enables sorting for the column
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Helpers;
using System.Collections.Specialized;
namespace cflat
{
public static DefaultSort GetDefaultSort<TModel, TProperty>(Expression<Func<TModel, TProperty>> expression, SortDirection direction)
{
return new DefaultSort(EvaluateExpression(expression), direction);
}
private static string EvaluateExpression(LambdaExpression expression)
{
var memberExpression = expression.Body as MemberExpression;
return memberExpression == null ? null : memberExpression.Member.Name;
}