Skip to content

Instantly share code, notes, and snippets.

View eralston's full-sized avatar
🏠
Working from home

Erik Ralston eralston

🏠
Working from home
View GitHub Profile
@eralston
eralston / JestCheatSheet.js
Last active July 15, 2020 20:11
Jest Cheat Sheet
// package.json
{
...
"scripts": {
"test": "NODE_ENV=test jest --ci --verbose",
},
...
"devDependencies": {
"@types/jest": "^26.0.3",
"babel-jest": "^26.1.0",
@eralston
eralston / AddBindings
Created August 27, 2019 17:15
Adds assembly redirects to current config file for the project
Get-Project –All | Add-BindingRedirect
@eralston
eralston / UDK .gitignore
Last active July 26, 2019 23:38
A .gitignore for projects created using the Unreal Development Kit (UDK). This will retain your changes in custom config, code, and content, but ignore foundational components of a UDK install. This list is current as of the February 2013 Beta UDK installation. To use, simply add this content to a .gitignore file before running your initial "git…
# File Types known to be unecessary
*.swp
*.bin
*.checkpoint
*ShaderCache*
*PCTOC*
*.log
*.obj
*IphoneTOC*
*.dmp
@eralston
eralston / Web.Release.config
Created April 9, 2015 18:24
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
<?xml version="1.0"?>
<!-- For more information on using Web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=301874 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
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".
<connectionStrings>
@eralston
eralston / Missing Index.sql
Last active June 14, 2018 18:03
A query for asking SQL Server about performance recommendations AKA "Missing Indices"
-- Missing Index Script
-- Original Author: Pinal Dave
SELECT TOP 25
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,''),', ','_'),'[',''),']','')
+ CASE
@eralston
eralston / List Indices.sql
Created June 14, 2018 16:41
A Query for listing all indices in a SQL database with their
SELECT
TableName = t.name,
IndexName = ind.name,
IndexId = ind.index_id,
ColumnId = ic.index_column_id,
ColumnName = col.name,
ind.*,
ic.*,
col.*
FROM
@eralston
eralston / .tfignore
Created February 26, 2015 19:00
Example ignore file for Team Foundation Server, excluding files from Bin, NuGet packages, etc
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
bin
obj
#include nuget executable
@eralston
eralston / SimpleFilesCache.h
Created February 27, 2014 18:37
An Objective-C class for caching files in the CachesDirectory of an app quickly and easily
//
// SimpleFilesCache.h
//
#import <Foundation/Foundation.h>
///
/// A static class for basic management of the NSCachesDirectory contents
///
@interface SimpleFilesCache : NSObject
@eralston
eralston / Initialize.cs
Created November 18, 2016 01:10
Boilerplate for an assembly initialization class to map the datadirectory and reset the local db for unit testing in C# using Entity Framework
[TestClass]
public class Initalize
{
[AssemblyInitialize]
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
eralston / ResignOnReturnDelegate.m
Created December 31, 2013 18:49
A delegate for resigning a UITextField when the return key is pressed. It's a corrected version of the code here: http://stackoverflow.com/questions/3186065/uitextfield-resign-first-responder-ios4
@interface ResignOnReturnDelegate : NSObject <UITextFieldDelegate>
@end
@implementation ResignOnReturnDelegate
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
if ([string isEqualToString:@"\n"]) {