Skip to content

Instantly share code, notes, and snippets.

View theorigin's full-sized avatar

Andy Robinson theorigin

View GitHub Profile
SELECT
t.NAME AS TableName,
s.Name AS SchemaName,
p.rows AS RowCounts,
SUM(a.total_pages) * 8 AS TotalSpaceKB,
SUM(a.used_pages) * 8 AS UsedSpaceKB,
(SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB
FROM
sys.tables t
INNER JOIN
@theorigin
theorigin / UrlHelperExtensions.cs
Last active August 29, 2015 13:57
Add a datetime suffix to style/script tags in HTML to force a refresh when they change
public static class UrlHelperExtensions
{
public static string ContentWithHash(this UrlHelper urlHelper, string contentPath)
{
var virtualFile = urlHelper.Content(contentPath);
var actualFile = urlHelper.RequestContext.HttpContext.Server.MapPath(contentPath);
var creationDateTime = (File.Exists(actualFile) ? File.GetLastWriteTimeUtc(actualFile) : new DateTime()).ToString("yyyyddMMHHmmss");
var compareResult = new KellermanSoftware.CompareNetObjects.CompareLogic().Compare(actualResult, expectedResult);
Assert.IsTrue(compareResult.AreEqual, compareResult.DifferencesString);
@theorigin
theorigin / Index.cs
Created August 4, 2012 15:06
Json TDD Controller
public ActionResult Index(InputModel model)
{
return Json(new
{
total = 1234,
page = 1,
rows = new List
{
new
{
@theorigin
theorigin / gist:3258269
Created August 4, 2012 15:08
Json TDD Unit Test
[Test]
public void SomeTest()
{
var viewResult = this.controller.Index(new InputModelBuilder().Build()) as JsonResult;
viewResult.Should().NotBeNull();
var data = viewResult.Data;
var pageNumber = data.GetType().GetProperty("page").GetValue(data, null);
@theorigin
theorigin / gist:3258274
Created August 4, 2012 15:09
Json TDD Refactor
private object GetValue(object source, string propertyName)
{
return source.GetType().GetProperty(propertyName).GetValue(source, null);
}
@theorigin
theorigin / gist:3258279
Created August 4, 2012 15:10
Json TDD Example Call
this.GetValue(data, "page").Should().Be(1);
@theorigin
theorigin / gist:3258287
Created August 4, 2012 15:11
Json TDD get at rows
var rows = (List<object><p>
)data.GetType().GetProperty("rows").GetValue(data, null);&nbsp;
rows.Count.Should().Be(1);
this.GetValue(rows[0], "id").Should().Be("98732312");
var cell = rows[0].GetType().GetProperty("cell").GetValue(rows[0], null);
this.GetValue(cell, "prop1").Should().Be("a");
@echo off
echo Pre req checks...
echo|set /p=... Running as ADMIN ...
reg query "HKU\S-1-5-19" >nul 2>&1
if %errorlevel% == 1 echo FAILED : Not runing as ADMIN
if %errorlevel% == 0 echo Passed
echo|set /p=... SQL Server ...
osql.exe -? >nul 2>&1
[Test]
public void ShouldReturnModelWithValuesSetCorrectly()
{
var formCollection = new NameValueCollection
{
{ "page", "5" },
{ "rp", "8" },
{ "query", "smith" },
{ "sortname", "sname" },
{ "sortorder", "sorder" }