Skip to content

Instantly share code, notes, and snippets.

@cdroulers
cdroulers / FileVirtualPathProvider.cs
Last active August 29, 2015 14:16
Since a lot of .NET classes are internal, I copied one and implemented missing methods.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Web.Hosting;
namespace Helpers.Web
{
public class FileVirtualPathProvider : VirtualPathProvider
{
@cdroulers
cdroulers / SuperFakeHttpContext.cs
Last active August 29, 2015 14:16
This file is required because the FakeHttpContext does not implement the Cache property.
public class SuperFakeHttpContext : HttpContextBase
{
public SuperFakeHttpContext(string relativeUrl)
{
}
public override System.Web.Caching.Cache Cache
{
get { return HttpRuntime.Cache; }
}
@cdroulers
cdroulers / SvgHandler.cs
Last active August 29, 2015 14:19
SvgHandler.cs
public class SvgHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
var fileName = Path.GetFileName(context.Request.AppRelativeCurrentExecutionFilePath) ?? string.Empty;
var svgIndex = fileName.LastIndexOf(".svg", StringComparison.InvariantCultureIgnoreCase);
var classIndex = fileName.IndexOf('.');
string[] classNames = new string[0];
string svgPath;
@cdroulers
cdroulers / svgHover.ts
Created April 13, 2015 12:50
svgHover.ts
angular.module("shared.ui").directive(
"svgHover",
[
() => {
return {
restrict: "A",
link: (scope: ng.IScope, element: ng.IAugmentedJQuery) => {
function getSvg(svg: HTMLObjectElement): SVGElement {
var svgDocument: Document;
try {
module app.controllers {
export class MyController extends BaseController {
public static $inject = [
"$scope",
"MyService"
];
public SomeData: app.models.DataClass[] = [];
// Scope members
<div>
<input type="text" ng-model="ctrl.SomeProperty"><br>
<input type="text" ng-model="ctrl.SomeModel.SomeField" ng-show="ctrl.ShouldShow()"><br>
</div>
// Usage of the directive:
<my-directive model="Whatever"></my-directive>
@cdroulers
cdroulers / BaseEntity.ts
Last active May 23, 2016 21:53
BaseEntity for blog post about TypeScript and JSON.stringify (http://cdroulers.com/blog/2015/04/22/typescript-properties-and-json-stringify/)
module shared {
"use strict";
export interface IMapOptions {
Properties: { [key: string]: (x: any) => any };
Ignore?: string[];
PropertyNames?: { [key: string]: string };
}
function includeProperty(mapOptions: IMapOptions, prop: string) {
@cdroulers
cdroulers / Sample.tsv
Last active February 23, 2024 11:38
A sample tab separated file.
Some parameter Other parameter Last parameter
CONST 123456 12.45
@cdroulers
cdroulers / build.fsx
Created May 7, 2015 00:11
FAKE target to run code coverage on NUnit tests
open Fake.OpenCoverHelper
let buildDir = "./build/"
let coverageDir = buildDir + "coverage/"
let testsDir = buildDir + "tests/"
Target "RunNUnitTests" (fun _ ->
let assembliesToTest = (" ", (!! (buildDir + "/*.Tests.dll"))) |> System.String.Join
CreateDir coverageDir
CreateDir testsDir
@cdroulers
cdroulers / XmlType.cs
Created May 29, 2015 11:56
An NHibernate Mutable Type for XML in SQL Server.
[Serializable]
public class XmlType<T> : MutableType
where T : class
{
public XmlType()
: base(new XmlSqlType())
{
}