Skip to content

Instantly share code, notes, and snippets.

http://dba.stackexchange.com/a/112434
@vgerbase
vgerbase / DependencyService.cmd
Last active August 6, 2017 14:47
Create a dependency on a Windows service
@Echo Off
Cls
:CheckServiceName
If "%~1"=="" Goto AskServiceName
Set Service=%~1
Goto CheckDependencyServiceName
:AskServiceName
@vgerbase
vgerbase / TableEntityProperties.sql
Created November 9, 2016 23:29
Generate class properties from table
SELECT
'public '
+ CASE
WHEN c.DATA_TYPE IN ('bigint') THEN 'long'
WHEN c.DATA_TYPE IN ('int') THEN 'int'
WHEN c.DATA_TYPE IN ('smallint') THEN 'short'
WHEN c.DATA_TYPE IN ('tinyint') THEN 'byte'
WHEN c.DATA_TYPE IN ('decimal', 'numeric', 'smallmoney', 'money') THEN 'decimal'
WHEN c.DATA_TYPE IN ('real') THEN 'single'
WHEN c.DATA_TYPE IN ('float', 'decimal') THEN 'double'
@vgerbase
vgerbase / web.config
Last active August 6, 2017 14:47
Remove WWW and ensure HTTPS in IIS. Require URL Rewrite module.
<system.webServer>
<rewrite>
<rules>
<rule name="Remove WWW and Ensure HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^(www\.)" />
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://mydomain.com/{R:1}" />
@vgerbase
vgerbase / web.config
Last active August 6, 2017 14:46
Ensure HTTPS in IIS. Require URL Rewrite module.
<system.webServer>
<rewrite>
<rules>
<rule name="Ensure HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://mydomain.com/{R:1}" />
</rule>
@vgerbase
vgerbase / Export-IIS-sites-and-bindings.cmd
Created August 6, 2017 14:45
How to export site list and bindings info from IIS 7 and IIS 7.5 to a TXT file
REM http://manjitsinhal.blogspot.com.br/2013/04/how-to-export-site-list-and-bindings.html
Cd %windir%\system32\inetsrv
appcmd list site > c:\sites-list.txt
@vgerbase
vgerbase / web.config
Created August 6, 2017 14:59
Web.config settings to switch off certificate validation
<configuration>
<system.net>
<settings>
<servicePointManager
checkCertificateName="false"
checkCertificateRevocationList="false" />
</settings>
</system.net>
</configuration>
@vgerbase
vgerbase / web.config
Created August 31, 2017 14:40
Ensure WWW in IIS. Require URL Rewrite module.
<system.webServer>
<rewrite>
<rules>
<rule name="Ensure WWW" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{HTTP_HOST}" pattern="www.mydomain.com" negate="true" />
</conditions>
<action type="Redirect" url="http://www.mydomain.com/{R:1}" redirectType="Permanent" />
</rule>
@vgerbase
vgerbase / PipeExtensions.cs
Created July 8, 2018 18:19
Pipe extension in C#
public static class PipeExtensions
{
public static TOut Then< TIn, TOut >(this TIn item, Func< TIn, TOut > fn)
{
return fn(item);
}
}
public class PipeTest
{
String.prototype.formatUnicorn = String.prototype.formatUnicorn ||
function () {
"use strict";
var str = this.toString();
if (arguments.length) {
var t = typeof arguments[0];
var key;
var args = ("string" === t || "number" === t) ?
Array.prototype.slice.call(arguments)
: arguments[0];