Skip to content

Instantly share code, notes, and snippets.

@johnallers
johnallers / Combine-Logs.ps
Created September 8, 2017 13:42
PowerShell script to combine log4net logs
Get-ChildItem | Sort-Object LastWriteTime -Descending | Get-Content | Out-File combined.log
# Derived from https://stackoverflow.com/a/8743878
function Get-MsiDatabaseVersion {
param (
[string]$FilePath
)
if(!(Test-Path $FilePath)){
throw "Could not find " + $FilePath
}
@johnallers
johnallers / temp.ps1
Created August 11, 2017 12:31
Switch DEBUG directive conditions to allow for a debug build that mimmicks release functionality.
Get-ChildItem *.cs -recurse | ForEach { (Get-Content $_.FullName).Replace("#if DEBUG", "#if DEBUG_DISABLE").Replace("#if !DEBUG", "#if DEBUG") | Set-Content -Path $_.FullName -Encoding UTF8 }
@johnallers
johnallers / SlackHotkeys.ahk
Last active June 29, 2021 10:19
AutoHotKey script for changing Slack status
:://call::
SendInput, /status :phone: Call{enter}
Return
:://clear::
SendInput, /status clear{enter}
Return
:://wfh::
SendInput, /status :house_with_garden: Working From Home{enter}
#Run this every 1/2 hour and in an 8 hour work day there will be approximately 3 times per day that your victim hears a cat fact
if ((Get-Random -Maximum 10000) -lt 1875) {
Add-Type -AssemblyName System.Speech
$SpeechSynth = New-Object System.Speech.Synthesis.SpeechSynthesizer
$CatFact = (ConvertFrom-Json (Invoke-WebRequest -Uri 'http://catfacts-api.appspot.com/api/facts')).facts
$SpeechSynth.Speak("did you know?")
$SpeechSynth.Speak($CatFact)
}
// ==UserScript==
// @name Show and expand all Salesforce feed items
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @include https://*.salesforce.com
// @run-at document-end
// @require http://code.jquery.com/jquery-latest.min.js
// @grant none
@johnallers
johnallers / HkdfHmacSha256.cs
Created December 4, 2016 01:04
Dirty implementation of HMAC-based Extract-and-Expand Key Derivation Function (HKDF) using HMAC-SHA-256. Based on RFC 5869 (https://tools.ietf.org/html/rfc5869).
public class HkdfHmacSha256
{
public const int HASH_LENGTH = 32;
public byte[] Compute(int length, byte[] ikm, byte[] salt = null, byte[] info = null)
{
salt = salt ?? new byte[] { };
info = info ?? new byte[] { };
var prk = HmacSha256(salt, ikm);
@johnallers
johnallers / PS-ViewNuGetPackages.ps1
Created November 6, 2015 17:40
Use PowerShell to view NuGet packages.config
# http://stackoverflow.com/a/10472358/73986
$packageConfig = Get-Item packages.config
$content = [Xml](Get-Content $packageConfig)
$content | Select-Xml /packages/package | Selet-Object -ExpandProperty Node
@johnallers
johnallers / GetProxyObject.ps1
Last active August 29, 2015 14:23
Create an instance of an object for a PowerShell web service proxy.
$proxy = New-WebServiceProxy -uri $url -UseDefaultCredential -Namespace "SecretServer"
$NewUser = New-Object -TypeName "SecretServer.GroupOrUserRecord"
$NewUser.Name= 'PW'
$NewUser.IsUSer =$true
$NewUser.UserID =5
$NewUser.GroupID =5
@johnallers
johnallers / gist:ef4672200c508522d214
Created May 22, 2015 13:19
Conversion to/from HexString and byte array
// http://stackoverflow.com/questions/311165/how-do-you-convert-byte-array-to-hexadecimal-string-and-vice-versa
public static string ByteArrayToString(byte[] ba)
{
StringBuilder hex = new StringBuilder(ba.Length * 2);
foreach (byte b in ba)
hex.AppendFormat("{0:x2}", b);
return hex.ToString();
}