Skip to content

Instantly share code, notes, and snippets.

View vadim-kovalyov's full-sized avatar
🇺🇦
🤍❤️🤍

Vadim Kovalyov vadim-kovalyov

🇺🇦
🤍❤️🤍
  • Microsoft
  • Redmond, WA
View GitHub Profile
@vadim-kovalyov
vadim-kovalyov / How to set ValidateAntiForgeryToken Attribute globaly
Last active June 28, 2019 08:04
How to set ValidateAntiForgeryToken Attribute globaly
public class AntiForgeryTokenFilterProvider : IFilterProvider
{
public IEnumerable<Filter> GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
{
IEnumerable<FilterAttribute> filters = actionDescriptor.GetFilterAttributes(true);
bool disableAntiForgery = filters.Any(f => f is DisableAntiForgeryCheckAttribute);
string method = controllerContext.HttpContext.Request.HttpMethod;
@vadim-kovalyov
vadim-kovalyov / MultiAssert.cs
Created April 1, 2016 19:34
Sometimes in order to test one logical concern you need to use multiple asserts. This class helps with that.
/// <summary>
/// The multi assert.
/// </summary>
/// <remarks>
/// Sometimes in order to test one logical concern you need to use
/// multiple asserts. This class helps with that.
/// </remarks>
public static class MultiAssert
{
/// <summary>
@vadim-kovalyov
vadim-kovalyov / AESGCM.cs
Last active October 21, 2016 15:52 — forked from jbtule/AESGCM.cs
Two code examples that I borrowed as best practices for encrypting a string in c#. They both are using authenticated encryption. http://stackoverflow.com/a/10366194/637783
/*
* This work (Modern Encryption of a String C#, by James Tuley),
* identified by James Tuley, is free of known copyright restrictions.
* https://gist.github.com/4336842
* http://creativecommons.org/publicdomain/mark/1.0/
*/
using System;
using System.IO;
using System.Text;
@vadim-kovalyov
vadim-kovalyov / CreateDevCert.cmd
Created May 18, 2016 14:19
This script creates development CA and Cert for using with IIS.
REM !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
REM This script must be run as Administrator
REM !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
REM Create a CA Certificate and place it into Trusted Root Certificate authorities storage on local machine.
makecert -n "CN=Development Root CA" -r -pe -a sha512 -len 4096 -cy authority -sr localmachine -ss Root -sk "Development Root CA"
REM Create a dev Certificate and place it into Personal certificates on local machine.
makecert -pe -n "CN=*.dev.local" -a sha512 -len 2048 -sky exchange -eku 1.3.6.1.5.5.7.3.1 -ir localmachine -is Root -in "Development Root CA" -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12 -sr localmachine -ss My -sk "*.dev.local"
@vadim-kovalyov
vadim-kovalyov / Create-IisSite.ps1
Created May 23, 2016 18:51
Creates a website and an app pool in IIS.
#
# Creates a website and an app pool in IIS.
#
function Create-IisSite
{
param([string]$SiteName, [string]$Url, [string]$DirectoryPath, [string]$AppPoolDotNetVersion = "v4.0")
Import-Module WebAdministration
$iisAppPoolName = $SiteName
@vadim-kovalyov
vadim-kovalyov / Create-IisVirtualDirectory.ps1
Created May 23, 2016 18:52
Creates a virtual directiry in the specified website.
#
# Creates a virtual directiry in the specified website.
#
function Create-IisVirtualDirectory
{
param([string]$DirName, [string]$SiteName, [string]$DirectoryPath)
Import-Module WebAdministration
cd IIS:\
@vadim-kovalyov
vadim-kovalyov / Register-Host.ps1
Created May 23, 2016 18:53
Creates a record in host file.
#
# Creates a record in host file.
#
function Register-Host
{
param([string]$IpAddress = "127.0.0.1", [string]$Url)
$hostfile = "$env:SystemRoot\System32\drivers\etc\hosts"
$content = "$IpAddress $Url"
@vadim-kovalyov
vadim-kovalyov / XmlSerializer.cs
Created June 9, 2016 14:19
Standard helper for XML Serialization
using System.IO;
using System.Xml.Serialization;
namespace Common
{
/// <summary>
/// XML Serialization utils.
/// </summary>
public static class XmlSerializer
{
@vadim-kovalyov
vadim-kovalyov / .gitconfig
Created August 30, 2016 17:18
How to enable TortoiseGitMerge as an external diff/merge tool in Visual Studio 2015
#Add this into your local (.git/config) or global (%USER_HOME%/.gitconfig) git config file.
[diff]
tool = tgm
[difftool "tgm"]
cmd = \"C:\\Program Files\\TortoiseGit\\bin\\TortoiseGitMerge.exe\" \"$LOCAL\" \"$REMOTE\"
[merge]
tool = tgm
[mergetool "tgm"]
cmd = \"C:\\Program Files\\TortoiseGit\\bin\\TortoiseGitMerge.exe\" \"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\"
@vadim-kovalyov
vadim-kovalyov / sp_help_dbrecovery.sql
Last active October 21, 2016 21:33
Stored Proc that generates RESTORE scripts from a set of backups created by Ola's Hallengren maintenance scripts.
-- This stored proc was developed based on the backup naming and folder convention from
-- https://ola.hallengren.com/ Maintenance Solution (as of 28 September, 2016).
-- It solely relies on files in the folder, it does not query MSDB, since it is
-- designed to work with Availability Groups (which may not have one single source of backup history).
-- Give it a database name and a backup root folder that you specified in Ola's Maintenance Solution script
-- and it will produce a sequence of RESTORE commands:
-- * Starting from MOST RECENT full backup,
-- * Then MOST RECENT diff backup (if exists)
-- * Then all T-Log backups after the last FULL/DIFF backup.