Skip to content

Instantly share code, notes, and snippets.

using Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation;
using Microsoft.Practices.EnterpriseLibrary.Logging;
using Microsoft.Practices.EnterpriseLibrary.Logging.Instrumentation;
using System.Diagnostics;
using System.Management.Instrumentation;
namespace Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners
{
/// <summary>
public class Cookies : ICookies
{
private readonly Lazy<HttpCookieCollection> _requestCookies = new Lazy<HttpCookieCollection>(
() => HttpContext.Current != null ? HttpContext.Current.Request.Cookies : null);
private readonly Lazy<HttpCookieCollection> _responseCookies = new Lazy<HttpCookieCollection>(
() => HttpContext.Current != null ? HttpContext.Current.Response.Cookies : null);
public void Add(string name, string value, bool secure = false, bool httpOnly = false)
{
using System;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using NUnit.Framework;
namespace StringReplace
{
public static class Program
define [..., 'mustache', 'text!dashboard-template.html'], (..., Mustache, dashboardTemplate) ->
class Router extends Backbone.Router
...
routes:
'': 'dashboard'
'about': 'about'
dashboard: ->
$.get 'dashboard', (data) => @render(Mustache.render(dashboardTemplate, data))
...
@mikeobrien
mikeobrien / DownloadDataBehavior.cs
Created April 20, 2012 17:09
Download data convention
public class DownloadDataModel
{
public string Data { get; set; }
public string Filename { get; set; }
public string MimeType { get; set; }
}
public class DownloadDataBehavior : BasicBehavior
{
private readonly IFubuRequest _request;
@mikeobrien
mikeobrien / bootstrap.validate.js
Created April 19, 2012 04:21
Simple validation for bootstrap horizontal forms
(function() {
var plugin = function($) {
$.fn.validate = function (selectors, predicate, message) {
if (!$.isArray(selectors)) selectors = [selectors];
var controlGroups = [];
var values = [];
for (index in selectors) {
var input = this.find(selectors[index]);
if (input.length == 0) throw 'Selector invalid: ' + selectors[index];
input = $(input[0]);
@mikeobrien
mikeobrien / backbone.lazy.js
Created April 18, 2012 04:41
Lazy plugin for Backbone
(function() {
var plugin = function(Backbone) {
LazyCollection = Backbone.Collection.extend();
LazyCollection.prototype.indexQuerystring = 'index';
LazyCollection.prototype.index = 0;
LazyCollection.prototype.lastLength = -1;
LazyCollection.prototype.fetch = function(options) {
(function() {
var plugin = function($) {
$.dialog = function (option) {
var content = '<div class="modal hide ' + option.css + '">';
content += '<div class="modal-header">';
content += '<a class="close" data-dismiss="modal">&times;</a><h3>' + option.title + '</h3>';
content += '</div>';
content += '<div class="modal-body">' + option.body + '</div>';
content += '<div class="modal-footer">';
content += '<a class="btn btn-primary ok">' + option.button + '</a>';
<html>
<title><use content="title" /></title>
<head>
<!--
These url's are all relative to the master layout but will
not be valid for views that exist in different folders.
I'm hoping to keep the url's relative but I'm not sure if
there is a way to accomplish that in a master layout.
window.error = (message) ->
console.log message
phantom.exit 1
#window.onerror = (message) ->
# console.log message
# phantom.exit 1
Date.prototype.elapsed = -> (new Date() - @) / 1000;