Skip to content

Instantly share code, notes, and snippets.

View ScottGuymer's full-sized avatar

Scott Guymer ScottGuymer

View GitHub Profile
@ScottGuymer
ScottGuymer / gist:5583937
Created May 15, 2013 13:18
Set maximum IIS connection on windows XP to 40
cd \inetpub\adminscripts
cscript adsutil.vbs set w3svc/MaxConnections 40
iisreset
@ScottGuymer
ScottGuymer / EFStoredProc.cs
Created May 28, 2013 14:56
Accessing a SQL Stored procedure with multiple result sets using Entity Framework
using (var db = new BloggingContext())
{
// Create a SQL command to execute the sproc
var cmd = db.Database.Connection.CreateCommand();
cmd.CommandText = "[dbo].[uspCustomerAndCompanySearch] @Query";
// Add Parameters to cmd here
cmd.Parameters.Add(new SqlParameter("query", response.Query));
try
@ScottGuymer
ScottGuymer / BundleConfig.vb
Last active August 29, 2015 13:56
IBundleTransform and file reader to allow on the fly compilation of less in .net
Public Module BundleConfig
''' <summary>
''' Registers the bundles.
''' </summary>
''' <param name="bundles">The bundles.</param>
''' <remarks></remarks>
Public Sub RegisterBundles(ByVal bundles As BundleCollection)
@ScottGuymer
ScottGuymer / RunAllTests.proj
Created February 17, 2014 16:24
MsBuild file to run multiple test projects through mstest and put results into a single file
<Project ToolsVersion="4.0" DefaultTarget="RunTests" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<results_file>./TestResults/results.trx</results_file>
</PropertyGroup>
<PropertyGroup>
<MsTestExePath Condition="'$(MsTestExePath)'==''">C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\MSTest.exe</MsTestExePath>
</PropertyGroup>
@ScottGuymer
ScottGuymer / index.html
Created March 26, 2014 15:31
Angular $http interceptor to allow for a loading spinner whenever any ajax request is made. Could be extended to provide request logging and error handling.
<div id="loadingWidget" loading-widget>
<div class="loadingContent">
<p>
Loading....Loading....Loading....Loading....Loading....Loading....Loading....Loading....Loading....Loading....Loading....Loading....Loading....Loading....Loading....Loading....Loading....Loading....
</p>
</div>
</div>
@ScottGuymer
ScottGuymer / gist:9910569
Created April 1, 2014 09:04
angular directive to format a number in an input
var common = angular.module('common', []);
/** allows numbers to be displayed from a model value with the correct decimal rounding */
common.directive('inputCurrency', function ($filter, $locale) {
return {
terminal: true,
restrict: 'A',
require: '?ngModel',
link: function (scope, element, attrs, ngModel) {
@ScottGuymer
ScottGuymer / DateInterceptor.js
Created July 3, 2014 07:23
Angular interceptor to reformat ISO 8601 strings into Javascript date objects
angular.module('dateInterceptor',[])
.config(['$httpProvider', function ($httpProvider) {
var regexIso8601 = /^(\d{4}|\+\d{6})(?:-(\d{2})(?:-(\d{2})(?:T(\d{2}):(\d{2}):(\d{2})\.(\d{1,})(Z|([\-+])(\d{2}):(\d{2}))?)?)?)?$/;
// function to parse through response json and replace ISO8601 date strings with date objects
var convertDateStringsToDates = function(input) {
// Ignore things that aren't objects.
if (typeof input !== "object") return input;
@ScottGuymer
ScottGuymer / DumpTablesToCsv.sql
Last active October 24, 2015 13:14
Create a list of commands to dump all tables to csv
select 'exec master..xp_cmdshell'
+ ' '''
+ 'bcp'
+ ' "' + TABLE_CATALOG + '.' + TABLE_SCHEMA + '.[' + TABLE_NAME + ']"'
+ ' out'
+ ' "C:\temp\'
+ TABLE_CATALOG + '.' + TABLE_SCHEMA + '.' + TABLE_NAME + '.csv"'
+ ' -c -t,'
+ ' -T'
+ ' -S' + @@servername
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using System.Linq;
@{
Layout = null;
Response.ContentType = "text/xml";
}<?xml version='1.0' encoding='UTF-8' ?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemalocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
@ListChildNodes(Umbraco.TypedContent(UmbracoContext.Current.PageId).AncestorOrSelf(1))
@ScottGuymer
ScottGuymer / ICommandHandler.cs
Last active October 24, 2015 13:13
Design Patterns and Useful Methods
public interface ICommandHandler<TCommand> where TCommand : ICommand
{
void Handle(TCommand command);
}
public interface ICommand
{
}