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
internal static class DataReaderUtil | |
{ | |
public static T GetValue<T>(this IDataRecord record, string columnName) | |
{ | |
T result = default(T); | |
int ordinal = record.GetOrdinal(columnName); | |
if (record.IsDBNull(ordinal)) | |
return result; |
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
$http = new-object System.Net.WebClient | |
$feed = [xml]$http.DownloadString("https://nuget.org/api/v2/Packages") | |
$feed.feed.entry | % { | |
$http.DownloadFile($_.content.src, ("C:\temp\"+ $_.title.InnerText + "." + $_.Properties.Version +".nupkg")) | |
} |
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
SET NOCOUNT ON | |
DECLARE @bakfile nvarchar(max) = 'C:\Temp\MyDb.BAK'; | |
DECLARE @dbname nvarchar(max) = 'MyDb'; | |
--DECLARE @datapath nvarchar(max) = 'c:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA'; | |
DECLARE @datapath nvarchar(max) = (SELECT TOP(1) left(physical_name, len(physical_name) - len('\master.mdf')) FROM master.sys.database_files) | |
--SELECT @datapath | |
--Drop db if exists |
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.ComponentModel; | |
using System.Web.UI; | |
namespace WebApplication | |
{ | |
public partial class ManyToManyField : System.Web.DynamicData.FieldTemplateUserControl | |
{ | |
protected override void OnDataBinding(EventArgs e) | |
{ |
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
:: NOTE needs to be elevated | |
@set /p HTTP_PORT=Enter Port number [e.g. 10082]: | |
netsh http add urlacl url=http://*:%HTTP_PORT%/ user=everyone | |
netsh http add urlacl url=http://localhost:%HTTP_PORT%/ user=everyone | |
netsh http add urlacl url=http://%COMPUTERNAME%:%HTTP_PORT%/ user=everyone | |
netsh http add urlacl url=http://%COMPUTERNAME%.local:%HTTP_PORT%/ user=everyone | |
@pause |
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
class ConsoleExec | |
{ | |
public string FileName { get; set; } | |
public string Arguments { get; set; } | |
public TextWriter StdOut { get; set; } | |
public TextWriter StdErr { get; set; } | |
public ConsoleExec() | |
{ |
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.ComponentModel; | |
using System.Linq; | |
using System.Runtime.InteropServices; | |
using System.Diagnostics; | |
public class MailUtil | |
{ | |
#region DLL Imports |
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
select | |
SchemaName = schema_name(t.schema_id) | |
, TableName = t.name | |
, ColumnName = c.name | |
, IsPrimaryKey = (select count(*) from | |
sys.indexes as i join sys.index_columns as ic on i.OBJECT_ID = ic.OBJECT_ID and i.index_id = ic.index_id and ic.column_id = c.column_id | |
where i.is_primary_key = 1 and i.object_id = t.object_id) | |
, ColumnType = TYPE_NAME(c.system_type_id) | |
, MaxLength = c.max_length | |
from sys.tables t join sys.columns c on t.object_id = c.object_id |
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
static void ensureServiceBrokerEnabled() | |
{ | |
var sql = @"if (SELECT is_broker_enabled FROM sys.databases WHERE name = DB_NAME()) = 0 | |
begin | |
declare @sql nvarchar(max) = 'ALTER DATABASE ' + QUOTENAME(DB_NAME()) + ' SET ENABLE_BROKER WITH ROLLBACK IMMEDIATE' | |
exec(@sql) | |
end"; | |
using (var db = DependencyResolver.Current.GetService<IDbConnection>()) | |
{ | |
db.Open(); |
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
// call with %systemroot%\System32\cscript.exe, schedule with Task Scheduler | |
var systemRestore = GetObject("winmgmts:\\\\.\\root\\Default:SystemRestore") | |
var result = systemRestore.CreateRestorePoint("Scheduled restore point", 0, 100) | |
WScript.Echo("result " + result) |