Skip to content

Instantly share code, notes, and snippets.

@vgerbase
vgerbase / code.cs
Last active August 6, 2017 15:04
C# code to fill an array with a value
byte[] a = Enumerable.Repeat((byte)10, 100).ToArray();
@vgerbase
vgerbase / DNS-hide-version-number.cmd
Last active August 6, 2017 15:03
Cmd line to hide Windows DNS Server version number
dnscmd /config /EnableVersionQuery 0
@vgerbase
vgerbase / code.cs
Last active August 6, 2017 15:02
C# code to generate list of months's names
DateTimeFormatInfo dateTimeFormatInfo = new DateTimeFormatInfo();
var months = dateTimeFormatInfo.MonthNames.ToList();
@vgerbase
vgerbase / code.cs
Last active August 6, 2017 15:02
C# code to generate a list of numbers
var numbers = Enumerable.Range(0, 100).ToList();
@vgerbase
vgerbase / smtp.cs
Last active August 20, 2022 09:49
C# code to switch off certificate validation
{
...
ServicePointManager.ServerCertificateValidationCallback =
delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) {
return true;
};
smtpclient.Send();
...
}
@vgerbase
vgerbase / autodiscover.xml
Last active August 28, 2024 16:19
Autodiscover XML request POST
<?xml version="1.0" encoding="utf-8" ?>
<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/requestschema/2006">
<Request>
<AcceptableResponseSchema>http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a</AcceptableResponseSchema>
<EMailAddress>[email protected]</EMailAddress>
</Request>
</Autodiscover>
@vgerbase
vgerbase / autodiscover.xml
Last active August 28, 2024 16:20
Model for an Autodiscover XML response
<!-- RESPONSE FROM THE SERVER -->
<?xml version="1.0" encoding="utf-8" ?>
<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006">
<!-- Response: Required
This tag serves as an indication that the retrieved XML is an Autodiscovery Response
-->
<Response xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a">
<!-- User: Optional
This tag gives user-specific information. Autodiscover must be UTF-8 encoded.
-->
@vgerbase
vgerbase / web.config
Last active August 6, 2017 14:49
Elmah Error Filter
<!-- EN-US -->
<errorFilter>
<test>
<or>
<equal binding="HttpStatusCode" value="404" type="Int32" />
<regex binding="Context.Request.ServerVariables['URL']" pattern="/favicon\.ico(\z|\?)" />
</or>
<or>
<and>
@vgerbase
vgerbase / db_executor.sql
Last active May 13, 2016 21:19
Script to create a role to grant execute permission in all stored procedures
-- Create a db_executor role
CREATE ROLE [db_executor] AUTHORIZATION [dbo];
-- Grant execute rights to the new role
GRANT EXECUTE TO [db_executor];
@vgerbase
vgerbase / db_viewdefinition.sql
Created May 13, 2016 21:20
Script to create a role to grant view definition permission in all objects
-- Create a db_viewdefinition role
CREATE ROLE [db_viewdefinition] AUTHORIZATION [dbo];
-- Grant view definition rights to the new role
GRANT VIEW DEFINITION TO [db_viewdefinition];