Skip to content

Instantly share code, notes, and snippets.

@steve-jansen
steve-jansen / MsDepSvc.Port.cmd
Created February 28, 2013 21:37
Windows batch script to modify the TCP/IP port binding for the Microsoft Web Deployment Agent Service
:: Name: MsDepSvc.Port.cmd
:: Purpose: Modifies the TCP/IP port that the Web Deployment Agent Service
:: (MsDepSvc) listens on. Tested on Win7 Enterprise 32-bit.
:: Author: stevejansen_github@icloud.com
:: Revision: January 2013
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
@steve-jansen
steve-jansen / git-diff-add
Last active September 19, 2018 21:37
A custom script for git to interactively run "git difftool" against each modified and untracked file, then prompt to stage (add) the change, undo (checkout) the change, or ignore (skip) the change.
#!/bin/bash
# query the root of the repo because git status prints
# relative paths within the repo
if ! pushd "`git rev-parse --show-toplevel`" >/dev/null
then
echo "git rev-parse --show-toplevel failed to return the root dir of the repo"
exit 1
else
gitroot=`pwd`
@steve-jansen
steve-jansen / git-update
Created March 8, 2013 16:29
A custom script for git to stash any working changes, checkout master, pull origin master, checkout your working branch, rebase master, and unstash your working changes
#!/bin/bash
stash() {
# check if we have uncommited changes to stash
git status --porcelain | grep "^." >/dev/null;
if [ $? -eq 0 ]
then
if git stash save -u "git-update on `date`";
then
@steve-jansen
steve-jansen / Startup.Windows.cmd
Created March 8, 2013 17:18
A Windows batch file designed to run at logon from the Start / Programs / Startup to do the following: SUBST drive letters, wipe the %TEMP% folder, and run the disk defragmenter
:: Name: Windows Startup.cmd
:: Purpose: A logon script to SUBST drive letters, wipe %TEMP%, and run defrag
:: Author: stevejansen_github@mac.com
:: Revision: April 2012
@ECHO OFF
SETLOCAL
:: map local folders to drive letters
CALL :MAPDRIVE P: "%USERPROFILE%\Documents\Visual Studio 2010\Projects"
@steve-jansen
steve-jansen / Startup.Cmd.cmd
Created March 8, 2013 17:22
A Command Prompt auto-run script to injet DOSKEY macros into the shell from a text file, change the initial working directory to a SUBST'd drive letter, update the PATH to include SysInternal utilities, and log all Command Prompt launches to a history file
:: Name: Startup.Cmd.cmd
:: Purpose: Initializes a Windows command prompt shell
:: Author: stevejansen_github@mac.com
:: Revision: April 2012
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
:: self-install this script, but, don't force an overwrite if an auto run script is already configured
IF /I "%~1"=="/install" (
@steve-jansen
steve-jansen / TestData.cmd
Created June 24, 2013 02:44
A helpful way to import or export data from SQL Server to bcp.exe binary flat files. This can be helpful for storing relatively small sets of test data in source control, dropbox, etc for multiple environments.
:: Name: TestData.cmd
:: Purpose: Convenience script to use SQL Server bcp.exe to import or export
:: sample data as binary files in ~/src/Database/TestData
:: Author: Steve Jansen
:: Revision: December 2012
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
:: default values
@steve-jansen
steve-jansen / yeoman.cmd
Created June 24, 2013 02:46
A script to run yeoman on Windows with dependencies managed in source tree. This script assumes that Ruby, NodeJS, and PhantomJS are under source control, while the yeoman and grunt node modules can be downloaded via npm.
:: Name: yeoman.cmd
:: Purpose: Convenience script to run yeoman on windows
:: Author: Steve Jansen
:: Revision: January 2013
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
SET /A ERR=0
PUSHD %~dps0\.. > NUL
@steve-jansen
steve-jansen / Global.asax
Created August 14, 2013 19:32
Preventing IIS Integrated Windows Authentication from prompting authenticated users for a new username/password when permission to a URL is denied.
<Script language="C#" runat="server">
void Application_EndRequest() {
// rewrite HTTP 401s to HTTP 403s if the user is authenticated using
// integrated Windows auth with impersonation, but,
// the user lacks permissions to the requested URL
if (Context.User != null &&
Context.User.Identity != null &&
Context.User.Identity.IsAuthenticated &&
Context.User is System.Security.Principal.WindowsPrincipal &&
Context.Response.StatusCode == 401)
@steve-jansen
steve-jansen / ExportVisualBasicCode.bas.vb
Created November 21, 2013 20:56
Excel macro to export all VBA source code in this project to text files for proper source control versioning
' Excel macro to export all VBA source code in this project to text files for proper source control versioning
' Requires enabling the Excel setting in Options/Trust Center/Trust Center Settings/Macro Settings/Trust access to the VBA project object model
Public Sub ExportVisualBasicCode()
Const Module = 1
Const ClassModule = 2
Const Form = 3
Const Document = 100
Const Padding = 24
Dim VBComponent As Object
@steve-jansen
steve-jansen / ResourceInterceptor.cs
Last active December 30, 2015 15:28
A custom implementation of the `Awesomium.Windows.Forms.ResourceDataSourceProvider` functionality. This interceptor supports using the standard `http://` protocol scheme instead of Awesomium's use of the custom `asset://` scheme, which can cause problems with cross origin requests in Chromium, as well as third party services like Google APIs whi…
using System;
using System.IO;
using System.Reflection;
using Awesomium.Core;
namespace MyApp
{
/// <summary>
/// A custom implementation of the `Awesomium.Windows.Forms.ResourceDataSourceProvider` functionality.
/// This interceptor supports using the standard `http://` protocol scheme instead of Awesomium's use of the