Skip to content

Instantly share code, notes, and snippets.

Erik Ralston eralston

Block or report user

Report or block eralston

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
eralston / List Indices.sql
Created Jun 14, 2018
A Query for listing all indices in a SQL database with their
View List Indices.sql
TableName =,
IndexName =,
IndexId = ind.index_id,
ColumnId = ic.index_column_id,
ColumnName =,
eralston / Missing Index.sql
Last active Jun 14, 2018
A query for asking SQL Server about performance recommendations AKA "Missing Indices"
View Missing Index.sql
-- Missing Index Script
-- Original Author: Pinal Dave
dm_mid.database_id AS DatabaseID,
dm_migs.avg_user_impact*(dm_migs.user_seeks+dm_migs.user_scans) Avg_Estimated_Impact,
dm_migs.last_user_seek AS Last_User_Seek,
OBJECT_NAME(dm_mid.OBJECT_ID,dm_mid.database_id) AS [TableName],
'CREATE INDEX [PERF_' + OBJECT_NAME(dm_mid.OBJECT_ID,dm_mid.database_id) + '_'
+ REPLACE(REPLACE(REPLACE(ISNULL(dm_mid.equality_columns,''),', ','_'),'[',''),']','')
eralston / Initialize.cs
Created Nov 18, 2016
Boilerplate for an assembly initialization class to map the datadirectory and reset the local db for unit testing in C# using Entity Framework
View Initialize.cs
public class Initalize
public static void InitializeDbContext(TestContext context)
// Connection string in app.config should use LocalDb, EG:
// <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\DefaultConnection.mdf;Initial Catalog=DefaultConnection;Integrated Security=True" providerName="System.Data.SqlClient" />
AppDomain.CurrentDomain.SetData("DataDirectory", context.TestDeploymentDir);
Database.SetInitializer(new DropCreateDatabaseAlways<ApplicationDbContext>());
eralston / ControllerExtensions.cs
Last active Aug 29, 2015
A set of helpers to enable ASP.Net MVC Controllers to render their views and send them as e-mail
View ControllerExtensions.cs
/// <summary>
/// Extension methods for the system MVC controller and related classes
/// </summary>
public static class ControllerExtensions
/// <summary>
/// Renders a view to string using the given model
/// </summary>
/// <param name="controller"></param>
/// <param name="viewName"></param>
eralston / ZeroClipboardExample
Last active Aug 29, 2015
A code snippet for adding ZeroClipboard ( to an HTML page from CDN.js
View ZeroClipboardExample
<script src=""></script>
$(function () {
ZeroClipboard.config({ swfPath: "" });
client = new ZeroClipboard($(".copy-button"));
eralston / Web.Release.config
Created Apr 9, 2015
Web.config setting example for inserting a setting to force SSL in IIS; originally used in an ASP.Net MVC web application in Visual Studio
View Web.Release.config
<?xml version="1.0"?>
<!-- For more information on using Web.config transformation visit -->
<configuration xmlns:xdt="">
In the example below, the "SetAttributes" transform will change the value of
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
finds an attribute "name" that has a value of "MyDB".
eralston / .tfignore
Created Feb 26, 2015
Example ignore file for Team Foundation Server, excluding files from Bin, NuGet packages, etc
View .tfignore
# User-specific files
# Build results
#include nuget executable
View jquery.plugintemplate.js
/// jqury.plugintemplate.js
/// A short explanation of what it does right here
/// Intended HTML structure for targeted complex form (if applicable)
/// .postal-code-form - outer wrapper
/// .locationInputs - wrapper around all inputs
/// .postal-input - postal code input
eralston / drop_schema.sql
Created Apr 24, 2014
Drops all tables in a SQL Server database. At the moment, it may need to be run several times to decompose related tables.
View drop_schema.sql
-- Run several times to drop all tables
/* Drop all constraints */
SELECT @sql += N'
+ '.' + QUOTENAME(OBJECT_NAME(parent_object_id)) +
FROM sys.foreign_keys;
eralston / AsyncMethodExample.h
Created Feb 27, 2014
A contrived asynchronous method using two operation queues
View AsyncMethodExample.h
// This method can have a dedicated queue for all instances on it
// Or maybe per instance if downloadQueue were instead a class variable
static NSOperationQueue *downloadQueue = nil;
if(!downloadQueue) {
downloadQueue = [[NSOperationQueue alloc] init];
// Capture the queue that called us
You can’t perform that action at this time.