Skip to content

Instantly share code, notes, and snippets.

@taylorc
taylorc / HomeController.cs
Created July 23, 2013 11:14
Dapper.Net glimpse
DbProviderFactory factory = DbProviderFactories.GetFactory("System.Data.SqlClient");
using (DbConnection conn = factory.CreateConnection()) {
conn.ConnectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString();
conn.Open();
var list = conn.Query<Category>("select * from categories").ToList();
}
@taylorc
taylorc / OnLoad.cs
Created May 12, 2013 11:43
Debug form onload event
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
XmlConfigurator.Configure();
serviceRun.Start();
appender = new CustomMemoryAppender();
//Get the logger repository hierarchy.
var logRepository = (Hierarchy)LogManager.GetRepository();
@taylorc
taylorc / ServiceTest.cs
Created May 12, 2013 11:40
Custom AppenderSkeleton
public class CustomMemoryAppender : AppenderSkeleton
{
private readonly StringBuilder logBuffer;
readonly StringWriter stringWriter;
private readonly object lockObject = new object();
public CustomMemoryAppender()
{
logBuffer = new StringBuilder();
stringWriter = new StringWriter(logBuffer);
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main(string[] args)
{
CommandArgumentCollection argumentCollection = new CommandArgumentCollection(args);
if (argumentCollection.GetFirstArgument("console") != null)
@taylorc
taylorc / gist:5241772
Created March 25, 2013 23:15
Steps to install gift flow on windows
# clone git flow to appropriate directory
> git clone --recursive git://github.com/nvie/gitflow.git
# change directory to gitflow
> cd gitflow
# Run the msysgit-install script with the location as a parameter.
> contrib\msysgit-install.cmd "C:\Users\USER_NAME\AppData\Local\GitHub\PortableGit_8810fd5c2c79c73adcc73fd0825f3b32fdb816e7"
# Note: Replace PortableGit_8810fd5c2c79c73adcc73fd0825f3b32fdb816e7 with the name of your directory; you do not need the \bin at the end.
@taylorc
taylorc / gist:5236315
Created March 25, 2013 10:45
Install Git and Git Flow
cinst msysgit
cinst git
cinst poshgit
cinst git-flow-dependencies
@taylorc
taylorc / gist:5236289
Created March 25, 2013 10:39
Set Up Chocolatey at the Command Prompt
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('http://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin
public static class ResourceType
{
public const string Css = "css";
public const string Js = "js";
}
//for style sheets
@Html.Resource(@<link href="@Url.Content("~/Content/productSummary.css")" rel="stylesheet" />, ResourceType.Css)
//for script files
@Html.Resource(@<script src="@Url.Content("~/js/productSummary.js")" type="text/javascript" ></script>, ResourceType.Js)
//at the top of _Layout.cshtml
@RenderSection("Styles",false)
@Html.RenderResources(ResourceType.Css)
//at the bottom of _Layout.cshtml
@RenderSection("Scripts",false)
@Html.RenderResources(ResourceType.Js)