Skip to content

Instantly share code, notes, and snippets.

@aadennis
aadennis / HbAviToMp4.ps1
Last active June 10, 2017 12:35
Handbrake AVI to MP4 using built in present
# Given a folder with a set of avi files, convert each of those files to mp4 format,in the same folder.
# If the target mp4 name already exists, then skip.
# Following the conversion the file creation and amendment times get copied from the source/avi to the target/mp4.
# And finally, the target name (minus extension) is copied to the clipboard so that you can check the details in Explorer/search.
# The rootnames rename the same, only the extension changes.
# https://blogs.technet.microsoft.com/heyscriptingguy/2012/06/01/use-powershell-to-modify-file-access-time-stamps/
$currDir = "G:\VideosCollection\TheRest"
$handBrakeDir= "C:\temp\HandBrakeCLI-1.0.7-win-x86_64"
$logFile = "$currDir/Conversion.$(Get-Random).log"
# Try to copy all named files starting with the biggest to e.g. a DVD
# Once less than $minAllowedSpace, exit, in the hope that a bit of contingency on the DVD
# makes it easier to read and write files... which are a pain on a DVD writer.
#Remove-Item -Path E:\Set1 -Recurse -Force
$srcDir = "G:\VideosCollection\TheRest\MP4"
$targetDir = "E:\Set3"
$minAllowedSpace = 100mB
$set = gci -Path $srcDir -Filter *.mp4 | Sort-Object -Property Length -Descending
# Try to remove all files from a named folder, typically on a DVD
#Remove-Item -Path E:\Set1 -Recurse -Force
$targetDir = "E:\Set1b"
$set = gci -Path $srcDir -Filter *.mp4
$set | % {
$file = $_
$baseName = $file.BaseName
$target = "$targetDir/$baseName.mp4"
# Compare a reference folder and children, with a copy of that reference
$refPath = "G:\VideosCollection\TheRest\MP4"
$copyPath = "e:\set3"
$refSet = Get-ChildItem -Recurse -path $refPath
$copySet = Get-ChildItem -Recurse -path $copyPath
Compare-Object -ReferenceObject $refSet -DifferenceObject $copySet
<#
.SYNOPSIS
Given a wildcard representing a service logon ("Log On As" in the Windows services grid),
find all services executed by that logon, ON THE CURRENT SERVER.
.DESCRIPTION
As synopsis, plus to use this across a number of VMs, you will have to call this as a script block
.PARAMETER UserWildcard
workflow Invoke-PerfCounter {
param($counters)
foreach -parallel ($counter in $counters) {
(Get-Counter $counter).CounterSamples |
Select -Property Path, CookedValue } }
$counters =
'\Processor(*)\% Processor Time',
'\Processor(*)\% User Time',
'\Process(*)\Handle Count',
@aadennis
aadennis / NodeAssert.js
Created September 20, 2017 21:41
Basic node testing
Next is dennis-rules.js...
// Example call: dennisRules.applyRule(currName, results);
// The function applyRule always "expects" [v] of 'dennis'.
// if [v] is not 'dennis', then it follows convention by populating the callback with an
// Error object as the first argument, and leaving the other positions er undefined.
// Else ([v] IS 'dennis'), it leaves the first argument as null (again, following convention),
// and populates argument 2 with the input [v] value, and argument 3 with the random period to
// wait before returning.
// For the function to be available to callers, we call module.exports.(function name) = (function name);
@aadennis
aadennis / index.js, index.spec.js
Last active September 21, 2017 22:26
Code for WP article 21st September 2017
//i.js
'use strict';
console.log('Loading function');
exports.handler = (event, context, callback) => {
console.log('Received event:', JSON.stringify(event, null, 2));
console.log('value1x =', event.key1);
console.log('value2x =', event.key2);
console.log('value3x =', event.key3);
@aadennis
aadennis / VsCodeJavaScriptSnippets.js
Created October 1, 2017 16:34
VsCodeJavaScriptSnippets.js
{
"Print to console": {
"prefix": "dw-testlambdajs-example",
"body": [
"'use strict';",
"// Package imports...",
"const LambdaTester = require('lambda-tester');",
"const expect = require('chai').expect;",
"",
"// Local helpers...",
@aadennis
aadennis / DwVisualStudioSettings3.vssettings
Created October 21, 2017 08:07
Visual Studio Full Fat settings
<UserSettings><ApplicationIdentity version="15.0"/><ToolsOptions><ToolsOptionsCategory name="Environment" RegisteredName="Environment"><ToolsOptionsSubCategory name="Documents" RegisteredName="Documents" PackageName="Visual Studio Environment Package"><PropertyValue name="ShowMiscFilesProject">false</PropertyValue><PropertyValue name="AutoloadExternalChanges">false</PropertyValue><PropertyValue name="CheckForConsistentLineEndings">true</PropertyValue><PropertyValue name="SaveDocsAsUnicodeWhenDataLoss">false</PropertyValue><PropertyValue name="InitializeOpenFileFromCurrentDocument">true</PropertyValue><PropertyValue name="ReuseSavedActiveDocWindow">false</PropertyValue><PropertyValue name="DetectFileChangesOutsideIDE">true</PropertyValue><PropertyValue name="DontShowGlobalUndoChangeLossDialog">true</PropertyValue><PropertyValue name="AllowEditingReadOnlyFiles">true</PropertyValue><PropertyValue name="DocumentDockPreference">0</PropertyValue><PropertyValue name="MiscFilesProjectSavesLastNItems">0</PropertyValue