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
private string EnsureFileNameDoesNotExist(string storagePath, string fileName) | |
{ | |
while (System.IO.File.Exists(Path.Combine(storagePath, fileName))) | |
{ | |
var extension = Path.GetExtension(fileName); | |
var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName); | |
var fileCountMarker = new Regex("\\((?<count>[0-9]+)\\)$"); | |
var matchResult = fileCountMarker.Match(fileNameWithoutExtension); |
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 string SanitizeFolderName(string name) | |
{ | |
string regexSearch = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars()); | |
var r = new Regex(string.Format("[{0}]", Regex.Escape(regexSearch))); | |
return r.Replace(name, ""); | |
} |
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
var AutocompleteTextarea = function () { | |
this.lastFocus = {}; | |
}; | |
AutocompleteTextarea.prototype = (function () { | |
function setSave(textareaId, storageKey) { | |
$("form").on("submit", function (ev) { |
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
Stop-Service w32time | |
w32tm /config /manualpeerlist:"0.ro.pool.ntp.org 1.ro.pool.ntp.org pool.ntp.org" /syncfromflags:MANUAL | |
Start-Service w32time |
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
Import-Module SQLPS -DisableNameChecking | |
Import-Module PSCX | |
$dt = Get-Date -Format yyyyMMddHHmmss | |
$dbname = 'DBNAME' | |
Backup-SqlDatabase -ServerInstance .\SQLEXPRESS -Database $dbname -BackupFile "C:\Backups\$($dbname)_db_$($dt).bak" | |
write-zip "C:\WebSites\SITENAME\*" "C:\Backups\$($dbname)_website_$($dt).zip" |
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) |
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
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
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
<# | |
.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. |
OlderNewer