Skip to content

Instantly share code, notes, and snippets.

@LSTANCZYK
LSTANCZYK / gist:6eb71a9662a6899a5e68ea1d3c82b115
Created October 12, 2018 17:34
Synchronize logins between servers
USE master
GO
IF OBJECT_ID ('sp_hexadecimal') IS NOT NULL
DROP PROCEDURE sp_hexadecimal
GO
CREATE PROCEDURE sp_hexadecimal
@binvalue varbinary(256),
@hexvalue varchar (514) OUTPUT
AS
DECLARE @charvalue varchar (514)
using System;
using Microsoft.Owin;
using NLog; // Using NLog in this example
namespace com.github.gist.coenm
{
public static class LogRequestResponseHelper
{
public static void LogDebugResponse(Logger logger, IOwinResponse response)
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using RestSharp;
using Newtonsoft.Json;
using RestSharp.Deserializers;
Set-ExecutionPolicy Unrestricted -Force
Update-ExecutionPolicy Unrestricted
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions -EnableShowFullPathInTitleBar
disable-uac
disable-microsoftupdate
install-windowsupdate -acceptEULA
Set-TaskbarOptions -Size Small -Lock -Dock Bottom
Enable-RemoteDesktop
Enable-PSRemoting -Force
Set-StartScreenOptions -EnableBootToDesktop -EnableDesktopBackgroundOnStart -EnableShowStartOnActiveScreen -EnableShowAppsViewOnStartScreen -EnableSearchEverywhereInAppsView -EnableListDesktopAppsFirst
@LSTANCZYK
LSTANCZYK / DEVBoxStarter-NoReboot.ps1
Last active April 20, 2018 17:12
New dev machine chocolatey packages
# From a command prompt:
# USE: Pase this into cmd/powershell "START http://boxstarter.org/package/nr/url?{RAW-URL-FOR-THIS-FILE}"
choco feature enable -n=allowGlobalConfirmation
choco feature enable -n=autoUninstaller
choco feature enable -n=failOnAutoUninstaller
choco install PowerShell DotNet3.5 DotNet4.0 4.5
chocolatey install IIS-WebServerRole -source windowsFeatures
@LSTANCZYK
LSTANCZYK / PowerShell Customization.md
Created April 17, 2018 21:06 — forked from jchandra74/PowerShell Customization.md
PowerShell, Cmder / ConEmu, Posh-Git, Oh-My-Posh, Powerline Customization

Pimping Up Your PowerShell & Cmder with Posh-Git, Oh-My-Posh, & Powerline Fonts

Backstory (TLDR)

I work as a full-stack developer at work. We are a Windows & Azure shop, so we are using Windows as our development platform, hence this customization.

For my console needs, I am using Cmder which is based on ConEmu with PowerShell as my shell of choice.

Yes, yes, I know nowadays you can use the Linux subsystem on Windows 10 which allow you to run Ubuntu on Windows. If you are looking for customization of the Ubuntu bash shell, check out this article by Scott Hanselman.

@LSTANCZYK
LSTANCZYK / BooleanJsonConverter.cs
Created February 12, 2018 21:08 — forked from randyburden/BooleanJsonConverter.cs
A Json.NET JsonConverter that can handle converting the following values into boolean values: true, false, yes, no, y, n, 1, 0.
using System;
using Newtonsoft.Json;
namespace JsonConverters
{
/// <summary>
/// Handles converting JSON string values into a C# boolean data type.
/// </summary>
public class BooleanJsonConverter : JsonConverter
{
@LSTANCZYK
LSTANCZYK / gist:a880e1f46672fa909b40554e3abacb02
Created December 9, 2017 00:54 — forked from darrelmiller/gist:28221417620db2973a25
Coloured Request/Response console logger
public class ConsoleRequestLogger : DelegatingHandler
{
protected async override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine("> {0} {1}",request.Method,request.RequestUri.GetComponents(UriComponents.PathAndQuery, UriFormat.SafeUnescaped));
ProcessHeader(request.Headers, (name, value) => Console.WriteLine("> {0}: {1}", name, value));
if (request.Content != null)
{
@LSTANCZYK
LSTANCZYK / gist:70a176b3f8cc6bb9a0c1a0876452bb50
Created December 9, 2017 00:53 — forked from darrelmiller/gist:8548166
How to tell Web API 2.1 to allow errors to propagate up the MessageHandler pipeline so all exceptions can be converted to HttpResponseMessages in one place.
class Program
{
static void Main(string[] args)
{
var server = WebApp.Start("http://localhost:1002/", (app) =>
{
var config = new HttpConfiguration();
config.MapHttpAttributeRoutes();
config.Services.Replace(typeof(IExceptionHandler), new RethrowExceptionHandler());
@LSTANCZYK
LSTANCZYK / PrettyXml.cs
Created November 27, 2017 20:22 — forked from kristopherjohnson/PrettyXml.cs
Example of pretty-printing XML in C# using the XmlWriter class
using System;
using System.Text;
using System.Xml;
using System.Xml.Linq;
static string PrettyXml(string xml)
{
var stringBuilder = new StringBuilder();
var element = XElement.Parse(xml);