Skip to content

Instantly share code, notes, and snippets.

View JeremySkinner's full-sized avatar

Jeremy Skinner JeremySkinner

View GitHub Profile
//Yuck...
IEnumerable<Func<object, object>> funcs = GetFuncs();
var convertedFuncs = funcs.Select(func => new Func<T, object>(x => func(x))).ToList();
//Using autofac
[Test]
public void Creates_dependencies() {
var builder = new ContainerBuilder();
builder.RegisterModule(new AppModule());
var container = builder.Build();
var types = from type in typeof(HomeController).Assembly.GetExportedTypes()
where typeof(Controller).IsAssignableFrom(type) && !type.IsAbstract
select type;
public class Customer {
public int Id { get; set; } //assumes public property named "Id" is PK
public string Name { get; set; } //all public read/write properties auto-mapped to db cols
}
//config:
ActiveRecordConfiguration.Configure(cfg => {
cfg.ConnectToSqlServer("(local)", "mydb", "user", "pass");
cfg.MapTypesFromAssemblyContaining<Customer>();
//lots of other options...
<%= Html.ScriptInclude("foo") %>
<% if(false) { %>
<script type="text/javascript" src="/path/to/foo.js"></script>
<% } %>
@JeremySkinner
JeremySkinner / download-latest-nhprof.ps1
Created January 27, 2010 16:13
Download latest NHProf usng Powershell
# Script to download the latest NHprof build
# Note that this script requires the 7zip command line (http://www.7-zip.org/)
#configuration
$installDir = "C:\Projects\tools\nhprof"
$downloadDir = "C:\Temp\Nhprof"
$7zipexe = "C:\Program Files\7-Zip\7z.exe"
$url = "http://builds.hibernatingrhinos.com/downloadLatest/nhprof"
$file = "$downloadDir\NHProf.zip"
//Query is marked as cacheable, but the query cache is never used.
var rooms = session.CreateQuery("from Room order by Name")
.SetCacheable(true)
.List<Room>();
$files = dir -recurse | where { $_.PSIsContainer -eq $false -and (get-content($_.FullName)).Length -gt 1000 }
$count = $files.Count
This is in my %userprofile%/.gitconfig
[alias]
cia = !git add -A && git commit
<Database Name="Test" xmlns="http://schemas.microsoft.com/linqtosql/mapping/2007">
<Function Name="CustomersAndOrders" Method="CustomersAndOrders">
<ElementType Name="FluentLinqToSql.DatabaseTests.Entities.Customer" />
<ElementType Name="FluentLinqToSql.DatabaseTests.Entities.Order" />
</Function>
</Database>
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<% int count = 0; %>
<% for (int i = 0; i < ((ICollection)Model).Count; i++) { %>
<input type="hidden" name="<%= ViewData.TemplateInfo.GetFullHtmlFieldName("") %>[<%= i %>]" />
<% } %>