Skip to content

Instantly share code, notes, and snippets.

View jamiehowarth0's full-sized avatar

Jamie Howarth jamiehowarth0

View GitHub Profile
@jamiehowarth0
jamiehowarth0 / gist:5829160
Last active December 18, 2015 18:58
MSBuild action to exclude files of a certain type. Put this in your .csproj file (open with Notepad++, or "Unload Project" in Visual Studio then "Edit Project File").
<Target Name="AfterBuild">
<ItemGroup>
<FilesToCopy Include="App_Plugins\**\*.*" Exclude="App_Plugins\**\*.cs;App_Plugins\*.cs" />
</ItemGroup>
<Copy SourceFiles="@(FilesToCopy)" DestinationFiles="@(FilesToCopy->'<destination directory>\%(RecursiveDir)\%(Filename)%(Extension)')" />
</Target>
@jamiehowarth0
jamiehowarth0 / cleanaspnettempfiles.bat
Created January 29, 2014 11:09
Clean your .NET temp files
set "NET232=Framework\v2.0.50727"
set "NET264=Framework64\v2.0.50727"
set "NET432=Framework\v4.0.30319"
set "NET464=Framework64\v4.0.30319"
cd "\WINDOWS\Microsoft.NET\%NET232%\Temporary ASP.NET Files"
del *.* /S /Q
cd "\WINDOWS\Microsoft.NET\%NET264%\Temporary ASP.NET Files"
del *.* /S /Q
cd "\WINDOWS\Microsoft.NET\%NET432%\Temporary ASP.NET Files"
@jamiehowarth0
jamiehowarth0 / SamplePluginController.cs
Created February 14, 2014 14:48
Sample Umbraco PluginApiController
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Umbraco.Web.Mvc;
namespace MyWebsite {
[PluginController("MyCustomApi")]
public class SamplePluginController : Umbraco.Web.WebApi.UmbracoApiController {
@jamiehowarth0
jamiehowarth0 / ApplicationStartupHandler.cs
Last active August 29, 2015 14:01
How to use uMapper to return strong POCO types in Umbraco MVC mode
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Umbraco.Core;
using Umbraco.Web.Mvc;
using UmbracoStrongTypeViews.Controllers;
namespace UmbracoStrongTypeViews.App_Start {
public class ApplicationStartupHandler : IApplicationEventHandler {
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" ng-app>
<head>
<title></title>
</head>
<body>
<div data-ng-controller="TestController">
<h2>{{ text }}</h2>
</div>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js"></script>
public static class HtmlHelperExtensions
{
private static readonly char Separator = '/';
private static readonly string TemplateFolder = HttpContext.Current.Server.MapPath("~/App/templates");
private static readonly IViewEngine ViewEngine = new HandlebarsRazorViewEngine();
public static MvcHtmlString RenderEmber(this HtmlHelper helper, string path = "", bool noTemplateName = false)
{
if (HttpRuntime.Cache[path] == null)
{
@jamiehowarth0
jamiehowarth0 / ForAllOtherMembers.cs
Created October 8, 2014 11:34
Selective operand extension to map unmapped members.
public static class MappingExtensions {
public static void ForAllOtherMembers<TSource, TDestination>(this IMappingExpression<TSource, TDestination> expression, Action<IMemberConfigurationExpression<TSource>> memberOptions) {
var sourceTypeMap = Mapper.GetAllTypeMaps().FirstOrDefault(t => t.SourceType.IsEquivalentTo(typeof(TSource)) && t.DestinationType.IsEquivalentTo(typeof(TDestination)));
if (sourceTypeMap == null) throw new ArgumentNullException();
var typeInfo = new TypeInfo(sourceTypeMap.DestinationType);
typeInfo.GetPublicWriteAccessors().Each(acc => {
public static class IMediaServiceExtensions {
private const string UmbFile = "umbracoFile";
public static IMedia Copy(this IMediaService mediaService, IMedia media, IMedia newLocation, string newName = "") {
var properNewName = string.IsNullOrEmpty(newName) ? media.Name : newName;
var newMedia = (newLocation == null) ? mediaService.CreateMedia(properNewName, -1, media.ContentType.Alias)
: mediaService.CreateMedia(properNewName, newLocation, media.ContentType.Alias);
if (media.HasProperty(UmbFile)) {
@jamiehowarth0
jamiehowarth0 / Sitemap-crawler.jmx
Created March 12, 2016 04:59
JMeter test plan
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="2.6" jmeter="2.11 r1554548">
<hashTree>
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
<stringProp name="TestPlan.comments"></stringProp>
<boolProp name="TestPlan.functional_mode">false</boolProp>
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
@jamiehowarth0
jamiehowarth0 / Find-RazorFilesWithAllJSFiles.ps1
Created August 16, 2018 02:49
Finds all the JS files in your ASP.NET project ready to then bundle them up using a tool like Webpack.
gci -Include "*.cshtml" -recurse | select -expand FullName | where { -not [string]::IsNullOrEmpty($_) } | foreach { Select-String -Path $_ -Pattern '~(.*\.js)' -AllMatches } | foreach {$_.Matches.Groups[1].Value} | Sort-Object | Get-Unique -AsString > .\alljs.txt