Skip to content

Instantly share code, notes, and snippets.

@vgerbase
vgerbase / simplest-way-to-form-a-union-of-two-lists.md
Last active June 15, 2020 15:02
Simplest way to form a union of two lists

If it is a list, you can also use AddRange method.

var listB = new List<int>{3, 4, 5};  
var listA = new List<int>{1, 2, 3, 4, 5};
listA.AddRange(listB); // listA now has elements of listB also.

If you need new list (and exclude the duplicate), you can use Union.

@vgerbase
vgerbase / ToXml.cs
Created May 26, 2020 16:44
Serialize object to XML in Visual Studio immediate window while debugging
(new System.Xml.Serialization.XmlSerializer(obj.GetType())).Serialize(new System.IO.StreamWriter(@"C:\Temp\obj.xml"), obj)
@vgerbase
vgerbase / VisualStudio-WinMerge.md
Last active November 5, 2019 14:59
Configure Visual Studio to use WinMerge

Configure Visual Studio to use WinMerge

  • Open Source Control > Visual Studio Team Foundation under the Tools > Options... menu in Visual Studio
  • Click on Configure User Tools...
  • Click Add.. and fill the information below to configure the Compare operation
Extension: .*
Operation: Compare
Command: C:\Program Files\WinMerge\WinMergeU.exe
using System;
using System.Collections.Generic;
using System.Linq;
using System.Globalization;
public class Program
{
public static void Main()
{
decimal value = 123456.7890m;
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];
@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
{
@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 / 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 / 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
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>