Skip to content

Instantly share code, notes, and snippets.

@mitchelldavis
mitchelldavis / SublimeTextProjectFileTemplate.js
Last active December 17, 2015 22:29
Sublime Text 2 Project File Template
//http://www.sublimetext.com/docs/2/projects.html
{
"folders":
[
{
"path": "src",
"folder_exclude_patterns": ["backup"]
},
{
"path": "docs",
@mitchelldavis
mitchelldavis / WmiExplorer.ps1
Created October 7, 2013 14:28
A GUI WMI explorer and WMI Method Help generator www.ThePowerShellGuy.com
#
# WmiExplorer.ps1
#
# A GUI WMI explorer and WMI Method Help generator
#
# /\/\o\/\/ 2006
# www.ThePowerShellGuy.com
#
# load Forms NameSpace
[void][System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms")
@mitchelldavis
mitchelldavis / PowershellDiff.ps1
Created November 14, 2013 17:01
A simple diff function for two files in powershell.
param($VersionOne, $VersionTwo)
$result = compare-object (get-content $VersionOne) (get-content $VersionTwo) -IncludeEqual
Write-Host "+ " $VersionOne -ForegroundColor DarkGray
Write-Host "- " $VersionTwo -ForegroundColor DarkGray
Write-Host "=======================================" -ForegroundColor DarkGray
$result | foreach {
if($_.SideIndicator -eq "==")
@mitchelldavis
mitchelldavis / Remote-Connect.ps1
Created December 13, 2013 16:47
A simple cmdlet that will take care of all the lifting while only asking me for the machine name and credentials.
# All you should have to do to connect to a remote machine is type:
# Remote-Connect <machineIP>
# Then the cmdlet will ask you for your credentials and you can continue.
function Remote-Connect
{
param([Parameter(Mandatory=$true)][string]$machine)
$opt=New-PSSessionOption –skipcacheck
Enter-PsSession $machine -usessl -SessionOption $opt –cred (get-credential)
@mitchelldavis
mitchelldavis / mingw.common.targets
Created December 31, 2013 04:11
MSBuild for MinGW
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<Target Name="SetupProject">
<MakeDir Directories="$(MSBuildProjectDirectory)\obj;$(MSBuildProjectDirectory)\bin" />
</Target>
<Target Name="CleanProject">
<RemoveDir Directories="$(MSBuildProjectDirectory)\obj;$(MSBuildProjectDirectory)\bin" />
</Target>
@mitchelldavis
mitchelldavis / Liquibase.Common.Tasks
Last active November 15, 2022 23:05
Some MSBuild Scripts for Liquibase and MS Sql.
<?xml version="1.0" encoding="utf-8"?>
<Project InitialTargets="" DefaultTargets="All" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<AssemblyFile>$(MSBuildThisFileDirectory)\..\packages\MSBuild.Extension.Pack\tools\net40\MSBuild.ExtensionPack.TaskFactory.PowerShell.dll</AssemblyFile>
</PropertyGroup>
<UsingTask TaskFactory="PowershellTaskFactory" TaskName="CreateDatabaseTask" AssemblyFile="$(AssemblyFile)">
<ParameterGroup>
<ScriptsDirectory Required="true" ParameterType="System.String" />
<Server Required="true" ParameterType="System.String" />
@mitchelldavis
mitchelldavis / get-hash.ps1
Last active August 29, 2015 14:03
Get SHA256 hash of a file.
param(
[string] $file = $(throw 'a filename is required'),
[string] $algorithm = 'sha256'
)
$fileStream = [system.io.file]::openread((resolve-path $file))
$hasher = [System.Security.Cryptography.HashAlgorithm]::create($algorithm)
$hash = $hasher.ComputeHash($fileStream)
$fileStream.close()
$fileStream.dispose()
@mitchelldavis
mitchelldavis / Base64Conversions.ps1
Created January 19, 2015 16:37
Base64 String Conversions in Powershell
function Convert-ToBase64
{
param( [Parameter(Mandatory=$true)][String]$target )
$b = [System.Text.Encoding]::UTF8.GetBytes($target)
[System.Convert]::ToBase64String($b)
}
function Convert-FromBase64
{
param( [Parameter(Mandatory=$true)][String]$target )
@mitchelldavis
mitchelldavis / Get-FileHash.ps1
Created February 9, 2015 14:26
Get-FileHash
function Get-FileHash
{
param( [string]$filePath,
[string]$alg = 'SHA256')
$stream = $null
$filePath = Resolve-Path $filePath
try
{
var SCREEN_WIDTH = window.innerWidth,
SCREEN_HEIGHT = window.innerHeight,
mousePos = {
x: 400,
y: 300
},
// create canvas
canvas = document.createElement('canvas'),
context = canvas.getContext('2d'),