Skip to content

Instantly share code, notes, and snippets.

View PaulStovell's full-sized avatar

Paul Stovell PaulStovell

View GitHub Profile
@PaulStovell
PaulStovell / gist:782423
Created January 17, 2011 02:43
SQL script for a FunnelWebLog migration
--#############################################################################
-- SETUP
--#############################################################################
use master
go
RESTORE DATABASE [PaulStovellBlog]
FROM DISK = N'D:\PaulStovellBlog - 17 Jan 2011 122801.bak'
WITH FILE = 1,
@PaulStovell
PaulStovell / gist:782577
Created January 17, 2011 07:09
MVC HtmlHelper issues in Razor Helpers
@inherits FunnelWeb.Web.App_Code.HelperPage
@using System.Web.Mvc
@using System.Web.Mvc.Html
@helper Paginator(string actionName, int currentPageNumber, int totalPages)
{
@Html.ActionLink("Index", "Home")
}
public class HelperPage : System.Web.WebPages.HelperPage
Delivered-To: foobarbazwizwoz@gmail.com
Received: by 10.229.79.195 with SMTP id q3cs13093qck;
Thu, 3 Feb 2011 00:39:14 -0800 (PST)
Received: by 10.142.148.19 with SMTP id v19mr3328839wfd.26.1296722353792;
Thu, 03 Feb 2011 00:39:13 -0800 (PST)
Return-Path: <Paul.Stovell@readify.net>
Received: from VA3EHSOBE002.bigfish.com (va3ehsobe002.messaging.microsoft.com [216.32.180.12])
by mx.google.com with ESMTPS id e38si1287243wfj.122.2011.02.03.00.39.13
(version=TLSv1/SSLv3 cipher=RC4-MD5);
@PaulStovell
PaulStovell / MainWindow.xaml
Created March 8, 2011 23:43
This is how you can disable paste in TextBoxes in WPF
<Window x:Class="WpfApplication9.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<TextBox Name="MyTextBox" Text="Hello" />
</Grid>
</Window>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect to WWW" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^paulstovell.com$" />
</conditions>
<action type="Redirect" url="http://www.paulstovell.com/{R:0}" redirectType="Permanent" />
</rule>
public static class ComCleanupExtensions
{
public static ComProxy<TResource> WithComCleanup<TResource>(this TResource resource)
where TResource : class
{
return new ComProxy<TResource>(resource);
}
}
public class CsvExportMessageHandler : IHandleMessages<BeginCsvExportMessage>
{
public IExportFileCreator FileCreator { get; set; }
public IExportFormatter Formatter { get; set; }
public IBus Bus { get; set; }
public ILog Log { get; set; }
public void Handle(BeginCsvExportMessage message)
{
Log.Info("Performing CSV Export on: " + message.Assessment.AssessmentReportGuid);
var sessionFactory = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008.ConnectionString(_connectionString))
.Mappings(m => m.FluentMappings.AddFromAssembly(System.Reflection.Assembly.GetExecutingAssembly()))
.BuildSessionFactory();
builder.RegisterType<FileRepository>().As<IFileRepository>().HttpRequestScoped().WithParameter(new NamedParameter("root", WebConfigurationManager.AppSettings["paulpad.configuration.uploadpath"]));
builder.RegisterType<FeedRepository>().As<IFeedRepository>().HttpRequestScoped();
builder.RegisterType<AdminRepository>().As<IAdminRepository>();
builder.RegisterType<EntryRepository>().As<IEntryRepository>().HttpRequestScoped();
builder.RegisterInstance(sessionFactory).As<ISessionFactory>();
@PaulStovell
PaulStovell / CustomerController.cs
Created May 17, 2011 03:33
JavaScript Editing - How would you improve this?
public class CustomerController : Controller
{
public CustomerRepository Repository = new CustomerRepository();
public ActionResult Index()
{
return View();
}
public JsonResult List()
@PaulStovell
PaulStovell / ConfiguredModules.cs
Created September 27, 2011 18:00
Octopus configuration
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using Autofac;
namespace Octopus.Shared.Startup
{
public class ConfiguredModules : Module
{