Skip to content

Instantly share code, notes, and snippets.

View mattheyan's full-sized avatar

Bryan Matthews mattheyan

View GitHub Profile
@mattheyan
mattheyan / FolderDiff.bat
Created September 6, 2018 19:03
A simple Folder Diff script for Windows, using TF.exe
@echo OFF
set tf=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\TF.exe
"%tf%" folderdiff %1 %2 /recursive /filter:!.git/;!node_modules/;!WIP/
@mattheyan
mattheyan / ps-download-all-nuget-packages
Created September 4, 2018 16:03 — forked from bevand/ps-download-all-nuget-packages
Powershell script to download all packages from a nuget feed
$destinationDirectory = "C:\LocalNuGetTest\"
$webClient = New-Object System.Net.WebClient
$webClient.Credentials = New-Object System.Net.NetworkCredential("USERNAME", "PASSWORD")
$feed =[xml]$webClient.DownloadString("https://hostednugetfeed.com/custom-feed/nuget/v2/Packages")
$records = $feed | select -ExpandProperty feed | select -ExpandProperty entry #| select -ExpandProperty content
for ($i=0; $i -lt $records.Length; $i++) {
$content = $records[$i] | select -ExpandProperty content
$properties = $records[$i] | select -ExpandProperty properties
@mattheyan
mattheyan / wildcard.js
Created January 19, 2017 16:51
JavaScript: Filter array using wildcard string
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
function escapeRegExp(str) {
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
}
function convertWildcardStringToRegExp(expression) {
var terms = expression.split('*');
var trailingWildcard = false;
@mattheyan
mattheyan / FirstOfMonth-MSSQL.sql
Created December 1, 2016 20:23
Get the first of the month in SQL
select
Today = cast(getdate() as Date),
LastMonth = cast((cast(DATEPART(YEAR, GETDATE()) as char(4)) + '-' + cast((DATEPART(MONTH, GETDATE()) - 1) as CHAR(2)) + '-1') as DATE),
ThisMonth = CAST((cast(DATEPART(YEAR, GETDATE()) as char(4)) + '-' + cast((DATEPART(MONTH, GETDATE())) as CHAR(2)) + '-1') as DATE)
@mattheyan
mattheyan / GetDayOfWeek.sql
Created October 13, 2016 17:26
MYSQL: Get day of week index from name.
SELECT DAYOFWEEK(DATE_ADD(DATE('2007-01-07'), INTERVAL ((LOCATE(LEFT(@name, 2), 'SuMoTuWeThFrSa') - 1) / 2) DAY)) AS `DayOfWeek`
@mattheyan
mattheyan / SilentUninstall.xml
Last active July 26, 2016 14:01
Office Product Silent Uninstall
<?xml version="1.0" encoding="utf-8"?>
<Configuration Product="ProPlus">
<Display Level="basic" CompletionNotice="no" SuppressModal="yes" NoCancel="yes" AcceptEula="yes" />
<Setting Id="SETUP_REBOOT" Value="NEVER" />
</Configuration>
@mattheyan
mattheyan / Project.cs
Last active June 1, 2016 17:21
.NET: Find the project root from your running application.
using System;
using System.IO;
using System.Reflection;
using System.Web;
class Project
{
public static string GetRootDirectory()
{
var webCtx = HttpContext.Current;
@mattheyan
mattheyan / deleteVCRedistTempFiles.ps1
Last active August 29, 2015 14:24
Clean up vcredist files erroneously placed on the root of the system drive.
# https://support.microsoft.com/en-us/kb/950683
# These temporary files are erroneously generated by the installer into the
# root directory of one of your drives, instead of the temp directory.
# Possible causes:
# * WinMerge - http://forums.winmerge.org/viewtopic.php?f=4&t=1002
$identity = [Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()
if (!$identity.IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
throw "This script must be run as administrator."
@mattheyan
mattheyan / FindIFrame.js
Created May 27, 2015 17:34
When a DOM event within an iframe that is captured by the parent frame, find the iframe that it originated from.
function handleEvent(e) {
// NOTE: The use of 'parentNode' is important b/c the document is not returned by
// parentElement (because it's outside of the HTML and isn't a real element).
// http://www.w3schools.com/jsref/prop_node_parentelement.asp
var targetDocument = e.target.parentElement.parentNode;
// Document property 'defaultView' is supported in IE9+.
// https://developer.mozilla.org/en-US/docs/Web/API/Document/defaultView
// Alternative that is not as well supported: `e.view` -> https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/view
var targetWindow = targetDocument.defaultView;
@mattheyan
mattheyan / Install-Common.ps1
Last active August 29, 2015 14:16
BoxStarter-Scripts
# http://boxstarter.org/Weblauncher
# https://gist.github.com/racingcow/3e099ee7dc4ad3e4c8ae
# Windows customization/settings
# ==============================
Set-ExplorerOptions -showHidenFilesFoldersDrives -showProtectedOSFiles -showFileExtensions
if (Test-PendingReboot) { Invoke-Reboot }