This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Mock<IConfiguration> configuration = new Mock<IConfiguration>(); | |
configuration.Setup(c => c.GetSection(It.IsAny<String>())).Returns(new Mock<IConfigurationSection>().Object); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd path/to/project-b | |
git remote add project-a path/to/project-a | |
git fetch project-a | |
git merge --allow-unrelated-histories project-a/master # or whichever branch you want to merge | |
git remote remove project-a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using Microsoft.Extensions.Hosting; | |
namespace WebApplication24 | |
{ | |
public abstract class HostedService : IHostedService |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--This assumes 24 hours to the minute: | |
DELETE | |
MyTableWhere | |
WHERE | |
MyColumn < DATEADD(day, -1, GETDATE()) | |
--This assumes yesterday midnight: | |
DELETE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Drop all non-system stored procs */ | |
DECLARE @name VARCHAR(128) | |
DECLARE @SQL VARCHAR(254) | |
SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'P' AND category = 0 ORDER BY [name]) | |
WHILE @name is not null | |
BEGIN | |
SELECT @SQL = 'DROP PROCEDURE [dbo].[' + RTRIM(@name) +']' | |
EXEC (@SQL) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ngrok http -host-header=localhost 5000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Column(TypeName = "nvarchar(24)")] | |
public SomeEnum Name { get; set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String strPathAndQuery = HttpContext.Current.Request.Url.PathAndQuery; | |
String strUrl = HttpContext.Current.Request.Url.AbsoluteUri.Replace(strPathAndQuery, "/"); | |
// OR | |
Request.Url.GetLeftPart(UriPartial.Authority) | |
// https://stackoverflow.com/a/10337955/1158845 | |
// OR | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected override void OnModelCreating(ModelBuilder modelBuilder) | |
{ | |
foreach (var relationship in modelBuilder.Model.GetEntityTypes().SelectMany(e => e.GetForeignKeys())) | |
relationship.DeleteBehavior = DeleteBehavior.Restrict; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// More details: https://addyosmani.com/resources/essentialjsdesignpatterns/book/#revealingmodulepatternjavascript | |
// https://stackoverflow.com/a/7513721 | |
var JsApp = (function() { | |
function callback() { | |
alert("done"); | |
}; | |
return { | |
callbackAlert: callback |
NewerOlder