Skip to content

Instantly share code, notes, and snippets.

<#
.SYNOPSIS
Uninstall an application based on the exact name in Programs and Features
.DESCRIPTION
Will accept a DisplayNamee value that will be searched for in Programs and Features.
.PARAMETER DisplayName
The DisplayName as it found in Programs and Features
.PARAMETER LogPath
[Optional] Full path to the client logs folder
.PARAMETER LogName
@markhallen
markhallen / Install-Font.ps1
Created October 30, 2018 14:01
Install font files in Windows 10. Font files should be in the same folder as the script file.
$shell = New-Object -ComObject Shell.Application
foreach ($font in $shell.Namespace($PSScriptRoot).Items()) {
if (($font.Path).ToLower() -like "*.ttf" -or ($font.Path).ToLower() -like "*.otf" -or ($font.Path).ToLower() -like "*.ttc") {
if (-not (Test-Path ($env:windir + "\Fonts\" + $font.Path.Split("\")[-1]) -ErrorAction SilentlyContinue)) {
$font.InvokeVerbEx("Install")
}
}
}
@markhallen
markhallen / amplitude_data_tags.js.coffee
Created October 15, 2018 10:35
Use data-log in tags for amplitude.com events
$(document).on 'turbolinks:load', ->
$("a[data-log]").click (event) ->
logEvent = $(this).data("log")
amplitude.getInstance().logEvent(logEvent)
@markhallen
markhallen / sanitize_filename
Last active September 19, 2018 12:50
Remove characters that are invalid for file names
[System.IO.Path]::GetInvalidFileNameChars() | % {$text = $text.replace($_,'.')}
def sumInRange(nums, queries)
sum = 0
startIndices = {}
endIndices = {}
m = 1000000007
queries.each do |q|
startIndices[q[0]].nil? ? startIndices[q[0]] = 1 : startIndices[q[0]] += 1
endIndices[q[1]].nil? ? endIndices[q[1]] = 1 : endIndices[q[1]] += 1
end
function Add-Numbers($a, $b) {
return $a + $b
}
Describe "Add-Numbers" {
$testCases = @(
@{ a = 2; b = 3; expectedResult = 5 }
@{ a = -2; b = -2; expectedResult = -4 }
@{ a = -2; b = 2; expectedResult = 0 }
@{ a = 'two'; b = 'three'; expectedResult = 'twothree' }