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
$files = Get-ChildItem -Include Web.config -recurse | Select-String -pattern 'Database=[a-zA-Z_0-9\-]+;' | select path,matches | |
if ($files.length -eq 0 ) | |
{ | |
Write-Host "no files found" -ForegroundColor red | |
exit 0 | |
} | |
Write-Host "Found the following matches:" -ForegroundColor green |
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
public class MinifyInlineScriptsAttribute : ActionFilterAttribute | |
{ | |
public override void OnActionExecuting(ActionExecutingContext filterContext) | |
{ | |
var originalFilter = filterContext.HttpContext.Response.Filter; | |
if(originalFilter != null) filterContext.HttpContext.Response.Filter = new MinifyStream(originalFilter); | |
base.OnActionExecuting(filterContext); | |
} |
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
[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") | |
$publish = New-Object System.EnterpriseServices.Internal.Publish | |
foreach ($file in Get-ChildItem *.dll) { | |
echo $file.FullName | |
$publish.GacRemove($file.FullName) | |
} | |
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
[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") | |
$publish = New-Object System.EnterpriseServices.Internal.Publish | |
foreach ($file in Get-ChildItem *.dll) { | |
echo $file.FullName | |
$publish.GacInstall($file.FullName) | |
} | |
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
public static class ThreadSafeRandom | |
{ | |
[ThreadStatic] | |
private static Random _local; | |
public static Random ThisThreadsRandom => _local ?? (_local = new Random(unchecked(Environment.TickCount * 31 + Thread.CurrentThread.ManagedThreadId))); | |
} | |
public static class ListShuffleExtension | |
{ |
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
<# | |
.Synopsis | |
Trigger a TeamCity backup using the TeamCity REST API. | |
.Parameter username | |
Defines a TeamCity username which has authority to trigger backups. | |
.Parameter password | |
Defines the password for the user which will trigger the backup. | |
.Parameter baseUrl | |
Defines the URL to the TeamCity server (eg: http://teamcity.example.com). | |
If not set, the script will attempt to determine it from the TeamCity properties file. |
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
public class DateTimeWithEditFormatModelBinder : DefaultModelBinder | |
{ | |
public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) | |
{ | |
if (bindingContext.ModelType == typeof(DateTime?) || bindingContext.ModelType == typeof(DateTime)) | |
{ | |
var displayFormat = bindingContext.ModelMetadata.EditFormatString; | |
var value = bindingContext.ValueProvider.GetValue(bindingContext.ModelName); |
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
public class AbstractFactoryModelBinder : DefaultModelBinder | |
{ | |
public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) | |
{ | |
var modelType = bindingContext.ModelType; | |
if (modelType.IsAbstract) | |
{ | |
var value = bindingContext.ModelName == "model" ? bindingContext.ValueProvider.GetValue("Type") : bindingContext.ValueProvider.GetValue(bindingContext.ModelName + ".Type"); | |
if (value == null) | |
throw new ApplicationException("View does not contain Type"); |
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
ko.extenders.numeric = function (target, params) { | |
var options = { | |
precision: 0, | |
allowNegative: false | |
}; | |
$.extend(options, params); | |
//create a writable computed observable to intercept writes to our observable | |
var result = ko.pureComputed({ | |
read: target, //always return the original observables value |
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
1. Map network drive | |
EXEC XP_CMDSHELL 'net use W: \\mainstore\Backup PASSWORD /user:USERNAME' | |
2. Backup Database | |
declare | |
@timestamp varchar(8), | |
@fileName varchar(1024) |
NewerOlder