Skip to content

Instantly share code, notes, and snippets.

View szul's full-sized avatar
💻

Michael Szul szul

💻
View GitHub Profile
@szul
szul / launch.json
Created September 25, 2018 18:42
Visual Studio Code launch file for Firefox debugging of TypeScript files running under IIS Express locally, as well as ASP.NET MVC .NET Framework debugging under IIS Express
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Firefox Debugger",
"type": "firefox",
"request": "attach",
@ECHO off
:top
CLS
ECHO Choose a shell:
ECHO [1] cmd
ECHO [2] bash
ECHO [3] PowerShell
ECHO [4] PowerShell Core
ECHO [5] Python
ECHO.
@szul
szul / EventCalendar.cs
Created February 20, 2018 16:26
Code snippet for ICS attachment creation
public sealed class EventCalendar
{
private string _ics;
public EventCalendar()
{
}
public EventCalendar(string summary, string description, System.DateTime start, System.DateTime end, string location)
{
StringBuilder sb;
@szul
szul / project.json
Created July 3, 2016 14:46 — forked from darrelmiller/project.json
Project.json comparison with XML equivalent
{
"authors": [
"Sam Saffron",
"Marc Gravell",
"Nick Craver"
],
"owners": [
"marc.gravell",
"nick.craver"
],
//Assumes you've created a nuspec file using nuget spec FILE_NAME.csproj
<Target Name="AfterBuild">
<Exec Command="nuget pack FILE_NAME.csproj -IncludeReferencedProjects" />
</Target>
@szul
szul / nuget-install-example.md
Last active May 14, 2016 15:06
Example README for updating NuGet when there are issues with ASP.NET MVC and ASP.NET Web API 2

Update NuGet

If your references are still causing you issues when you attempt to build, you can try the following commands from the NuGet Package Manager Console:

Update-Package -ProjectName '<PROJECT_NAME>' -Reinstall

Install-Package Microsoft.AspNet.WebApi.HelpPage

Update-Package -ProjectName '<PROJECT_NAME.TEST>' -Reinstall

@szul
szul / sftp.ps1
Created January 21, 2016 20:03
PowerShell Script for use with Team Foundation Server as a build step to transfer files. Assumes pscp.exe from the puTTY team.
param(
[string]$files,
[string]$username,
[string]$password,
[string]$url
)
try {
Start-Process 'C:\puTTY\pscp.exe' -ArgumentList('-sftp -v -r -hostkey "TARGET_SERVER_HOST_KEY" -l ' + $username + ' -pw "' + $password + '" ' + $files + ' ' + $url) -Wait
}
@szul
szul / HttpContextConversion.cs
Created June 29, 2015 12:40
HttpContext to HttpContextBase and vice versa
//HttpContextBase to HttpContext (assumes HttpContextBase variable named contextBase)
HttpContext context = contextBase.ApplicationInstance.Context;
//HttpContext to HttpContextBase (assumes HttpContext variable named context)
HttpContextBase contextBase = new System.Web.HttpContextWrapper(context);
@szul
szul / TurnOffCodeFirst.cs
Created June 16, 2015 14:02
Turning off code first migrations in ASP.NET MVC and Web API for when legacy databases are used
protected void Application_Start()
{
//Where DatabaseContext is the class name of your database context for MVC/Web API
Database.SetInitializer<DatabaseContext>(null);
}
@szul
szul / RecursiveCTE.sql
Last active September 17, 2015 00:25
Using a CTE for a recursive select
WITH CTE_ITEM_HIERARCHY AS
(
SELECT i.[ItemID]
,i.[Text]
,i.[ParentItemID]
FROM [dbo].[Item] AS i
WHERE i.[ParentItemID] = 0
UNION ALL