Skip to content

Instantly share code, notes, and snippets.

View actaneon's full-sized avatar

Josh King actaneon

  • Get Satisfaction
  • San Francisco, CA
View GitHub Profile
@actaneon
actaneon / TextBoxFor.cs
Created March 2, 2010 15:17
Sample implementation of TextBoxFor using an expression
using System;
using System.Linq.Expressions;
using System.Text;
namespace CSTest.TextBoxExpression
{
public class TextBoxTest
{
public void Test()
{
@actaneon
actaneon / LinqXMLMapping.vb
Created February 12, 2010 16:53
Linq XML Mapping
Imports System.Data.Linq
Imports System.Data.Linq.Mapping
Imports System.Linq.Expressions
Imports System.Reflection
Imports System.IO
Public Class LinqMappingRepository(Of T As Class)
Private _db As DataContext
Public Sub New(ByVal connectionString As String)
@actaneon
actaneon / DebuggerWriter.cs
Created February 11, 2010 17:55
TextWriter implementation that writes Debug info to the VS output window
//Kris Vandermotten
//http://www.u2u.info/Blogs/Kris/Lists/Posts/Post.aspx?ID=11
//Writes Debug info to Output window when running in debug mode
//Usage: _dataContext.Log = New Vandermotten.Diagnostics.DebuggerWriter()
using System;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Text;
Shell:
"C:\Program Files\Git\bin\sh.exe" --login -i
Startup Dir:
%HOMEDRIVE%%HOMEPATH%
@actaneon
actaneon / ListExtensions.cs
Created January 28, 2010 07:02
List extensions useful for MVC
using System;
using System.Collections.Generic;
using System.Web.Mvc;
public static class ListExtensions
{
public static IEnumerable<T> ForEach<T>(this IEnumerable<T> collection, Action<T> action)
{
foreach (var item in collection) action(item);
return collection;
@actaneon
actaneon / FactoryWithClosure.cs
Created January 26, 2010 17:57
Factory Using Closure to Configure at Startup
using StructureMap;
public class Order
{
}
interface IOrderShipper
{
void Ship(Order order);
}
public class BaseReportPage<TModel> : BaseViewPage<TModel>, IViewBase where TModel : class
{
// ...
protected override void OnPreInit(EventArgs e)
{
if (ShowAsPdf)
{
string path = _configuration.GetPrincePath();
var prince = new Prince(path);
@actaneon
actaneon / AddInterfaceVSMacro.vb
Created January 15, 2010 21:43
Add Interface Visual Studio Macro
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Public Module Main
Sub AddInterface()
Dim interfaceName As String = Microsoft.VisualBasic.Interaction.InputBox("Name", "Add Interface")
@actaneon
actaneon / signPowershell.ps1
Created January 3, 2010 20:43
Sign Powershell Script
#Enable Signed Scripts
#Set-ExecutionPolicy AllSigned
#Create Trusted Root CA
#makecert -n "CN=PowerShell Local Certificate Root" -a sha1 -eku 1.3.6.1.5.5.7.3.3 -r -sv root.pvk root.cer -ss Root -sr localMachine
#Create Personal Cert
#makecert -pe -n "CN=PowerShell User" -ss MY -a sha1 -eku 1.3.6.1.5.5.7.3.3 -iv root.pvk -ic root.cer
@actaneon
actaneon / AddInterface.vb
Created December 31, 2009 20:13
VS2008 Add Interface Macro
Sub AddInterface()
Dim interfaceName As String = Microsoft.VisualBasic.Interaction.InputBox("Name", "Add Interface")
If Not String.IsNullOrEmpty(interfaceName) Then
If Not interfaceName.ToLower.EndsWith(".vb") Then
interfaceName &= ".vb"
End If
DTE.ItemOperations.AddNewItem("Code\Interface", interfaceName)
End If