This file contains hidden or 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 hidden or 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.Text; | |
using System.Security.Cryptography; | |
class MailgunUtil | |
{ | |
/// <summary> | |
/// Authenticates incoming requests to a Mailgun webhook (https://documentation.mailgun.com/user_manual.html#webhooks). | |
/// </summary> | |
/// <example> |
This file contains hidden or 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 hidden or 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.Net; | |
using System.Net.Http; | |
using System.Net.Http.Headers; | |
using System.Threading.Tasks; | |
[TestFixture] | |
public class MyClass | |
{ | |
const string DOMAIN = "samples.mailgun.org"; | |
const string API_KEY = "key-..."; |
This file contains hidden or 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 hidden or 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 hidden or 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 string compressGuid(Guid guid) | |
{ | |
// "MspzuC2oLkKjoUEgZrbJFg==" | |
return Convert.ToBase64String(guid.ToByteArray()) | |
.Substring(0, 22) | |
.Replace('+', '-') | |
.Replace('/', '_'); | |
} |
This file contains hidden or 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 hidden or 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 hidden or 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) |