Skip to content

Instantly share code, notes, and snippets.

View aaronolds's full-sized avatar

Aaron.Olds aaronolds

  • Michigan
View GitHub Profile
#####################
# PREREQUISITES
#####################
Set-ExplorerOptions -showHiddenFilesFoldersDrives -showProtectedOSFiles -showFileExtensions
Set-TaskbarSmall
# Console
cinst PowerShell
cinst poshgit
// This file was initially generated by Windows Terminal 1.4.3243.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
@aaronolds
aaronolds / bash
Created March 5, 2019 18:57
Grep
grep -rnw --include *.csproj --include *.config '/mnt/e/Source/Repos' -e '[pattern]' > find.txt
@aaronolds
aaronolds / gist:b8247dcfc6c6ad677a492b5181cbfdeb
Created September 5, 2018 21:44
Remove folder from Git repository
git rm -r --cached FolderName
git commit -m "Removed folder from repository"
git push origin master
@aaronolds
aaronolds / git aliases - Windows
Last active August 6, 2018 01:18
Git Aliases for Windows (Linux and Mac use single quotes instead of double quotes)
Alias:
git config --global alias.add-commit "!git add -A && git commit"
Usage:
git add-commit -m "My commit message"
Alias:
git config --global alias.lg "log --oneline --decorate --all --graph"
Usage:
git lg
@aaronolds
aaronolds / MSSQLObjectReferences.sql
Created June 26, 2018 13:56
Find missing MS SQL Object References
-- http://en.gravatar.com/sqlmonger
SELECT
QuoteName(OBJECT_SCHEMA_NAME(referencing_id)) + '.' + QuoteName(OBJECT_NAME(referencing_id)) AS [this Object...],
o.type_desc,
ISNULL(QuoteName(referenced_server_name) + '.', '')
+ ISNULL(QuoteName(referenced_database_name) + '.', '')
+ ISNULL(QuoteName(referenced_schema_name) + '.', '')
+ QuoteName(referenced_entity_name) AS [... depends ON this missing entity name]
,sed.referenced_class_desc
,case when o.type_desc in( 'SQL_STORED_PROCEDURE' ,'SQL_SCALAR_FUNCTION' ,'SQL_TRIGGER' ,'VIEW')
@aaronolds
aaronolds / AspDotNetCoreServiceFactory.cs
Created June 8, 2018 19:29
How to use a Service Factory in ASP.net Core
// Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddTransient<Func<key, IRepository<model>>>(serviceProvider => key =>
{
var repositoryServiceFactory = new RepositoryServiceFactory();
return repositoryServiceFactory.Build(key, Configuration);
});
}
.
-- From - http://www.itprotoday.com/software-development/cheat-sheet-calculating-important-dates.
--First Day of Last Year
SELECT DATEADD(YEAR, DATEDIFF(YEAR, '19000101', GETDATE()) - 1 , '19000101') AS [First Day of Last Year];
GO
--First Day of This Year
SELECT DATEADD(YEAR, DATEDIFF(YEAR, '19000101', GETDATE()), '19000101') AS [First Day of This Year];
GO
@aaronolds
aaronolds / DbContext.cs
Created September 29, 2017 14:13
Detach all entities in a DbContext before loading it again with data. The only issue I have with this is, that the detached entities are still in memory.
...
public void DetatchAllEntities()
{
ChangeTracker.Entries().Where(dbEntityEntry => dbEntityEntry.Entity != null).ToList().ForEach(e => e.State = System.Data.Entity.EntityState.Detached);
}
...
@aaronolds
aaronolds / Utf8StringWriter.cs
Created May 10, 2017 13:48
StringWriter Encoding UTF8
public class Utf8StringWriter : StringWriter
{
public override Encoding Encoding => Encoding.UTF8;
}