Skip to content

Instantly share code, notes, and snippets.

Avatar

Simon Harriyott harriyott

View GitHub Profile
@harriyott
harriyott / gist:a6e465337eb42c00ca55
Created Jun 17, 2015
NimbleText php annotation
View gist:a6e465337eb42c00ca55
/**
* @var <% $3.replace("'';",'string').replace('0;','int') %>
* @text('label' => '<% $1.replace("$","").replace('_', ' ').toSentenceCase() %>')
*/
$row
View SourceSafe Enable Leave Button.cs
namespace Harriyott.SourceSafeLeaveEnable
{
public partial class MainForm : Form
{
[DllImport("User32.dll")]
public static extern Int32 FindWindow(String lpClassName, String lpWindowName);
[DllImport("user32.dll", EntryPoint = "SendMessage")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
[DllImport("User32.dll")]
public static extern int FindWindowEx(int hwndParent, int hwndChildAfter, string strClassName, string trWindowName);
@harriyott
harriyott / NInjectControllerTest
Created Oct 24, 2013
Unit test to validate all controllers can bind
View NInjectControllerTest
[TestMethod]
public void Can_create_controllers()
{
var kernel = new StandardKernel();
SiteResolver.RegisterComponents(kernel);
typeof(AccountController)
.Assembly
.GetTypes()
.Where(t => typeof(Controller).IsAssignableFrom(t))
@harriyott
harriyott / DynamicSiteMapProvider.cs
Last active Feb 24, 2017
Dynamic sitemap provider for .NET 2.0
View DynamicSiteMapProvider.cs
/*
* DynamicSiteMapProvider
*
* Created by Simon Harriyott http://harriyott.com
* More details at http://harriyott.com/2007/03/adding-dynamic-nodes-to-aspnet-site
*
* DynamicSiteMapProvider is a class that adds new
* items to a site map at runtime. The filename of
* the existing xml sitemap is set in the Web.Config
* file. This file is loaded, and extra nodes can
View KittenRoutes.cs
public static class RouteNames
{
public const string ListKittens = "api/kittens/list";
public const string FeedKitten = "api/kitten/{kittenId}/feed";
public const string AdoptKitten = "api/kitten/{kittenId}/adopt";
public const string RenameKitten = "api/kitten/{kittenId}/rename/{newName}";
}
View KittenController.cs
public class KittenContoller: Controller
{
[Route(RouteNames.KittenList)]
public ActionResult Index()
{
return View();
}
[Route(RouteNames.FeedKitten)]
public ActionResult Feed(int kittenId)
View BadKittenController.cs
public class KittenContoller: Controller
{
[Route("api/kittens/list")]
public ActionResult Index()
{
return View();
}
[Route("api/kitten/{kittenId}/feed")]
public ActionResult Feed(int kittenId)
View kitten-routes.tt
<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ assembly name="$(SolutionDir)Kittens.Web\bin\Kittens.Web.dll "#>
<#@ output extension=".ts" #>
export class KittensRoutes {
<#
// Get a collection of the constants in the class
var constants = typeof(Kittens.Web.KittensRoutes).GetFields();
View BadKittenService.ts
export class KittenService {
feedKitten(kittenId: number): void {
const url = `api/kitten/${kittenId}/feed`;
this.http.post(url, {}).subscribe();
}
}
View KittenService.ts
import { KittenRoutes } from './kitten-routes';
export class KittenService {
feedKitten(kittenId: number): void {
const url = KittenRoutes.feedKitten(kittenId);
this.http.post(url, {}).subscribe();
}
}