Skip to content

Instantly share code, notes, and snippets.

View anotherlab's full-sized avatar

Chris Miller anotherlab

View GitHub Profile
@anotherlab
anotherlab / fix-audition-devices.ps1
Last active March 20, 2023 04:40
PowerShell script to update Adobe Audition's MachineSpecificSettings.xml to use the specific input and output devices
# Update MachineSpecificSettings when Windows does to change the UID for the audio hardware
# To use Get-AudioDevice, install AudioDeviceCmdlets
# Install-Module -Name AudioDeviceCmdlets
# See https://github.com/frgnca/AudioDeviceCmdlets
#
# I used https://jsonlint.com/ for verifying the embedded JSON that Adobe uses
# get the latest version of Audition installed
$version = (gci ([IO.Path]::Combine( $env:APPDATA, "Adobe\Audition")) | sort-object Name -Descending | Select-Object -First 1).Name
@anotherlab
anotherlab / convert-vtt.ps1
Last active November 2, 2022 15:48
PowerShell script to convert a WebVTT caption file (*.vtt) to SubRip (*.srt)
# SRT File format https://docs.fileformat.com/video/srt/
# WebVTT file format https://developer.mozilla.org/en-US/docs/Web/API/WebVTT_API
param (
[Parameter(Mandatory = $true)][string]$localPath
)
# Get all of the matching file names
$MatchingFileNames = (Get-ChildItem $localPath -File) | sort-Object Name
# walk through the list of files
@anotherlab
anotherlab / dump-cmap.py
Created May 10, 2022 03:55
Generate a list of glyph names or a C# constants file from a font
#! /usr/bin/env python3
# Use this to generate a list of glyph names from a font to a
# text file. This can be passed to pyftsubset to generate a
# small font.
# This can also generate a C# constants class from the font
# Usage:
# dump-cmap.py fontfile.ttf glyphlist.txt
# or
# dump-cmap.py fontfile.ttf constants.cs fontname namespace
@anotherlab
anotherlab / WalkThru.py
Created May 10, 2022 03:43
Python script for collecting Xamarin.Forms or .NET MAUI named font glyphs
#! /usr/bin/env python3
# This script will recursively walk through all of the .xaml files
# in a project and collect the names of the icon font glyphs
# For a line that contains the following markup
# Glyph="{x:Static icons:MaterialDesignIconFont.AccountEditOutline}"/>
# It would return account-edit-outline
#
# Usage:
# WalkThru.py project-folder IconFontAlias
@anotherlab
anotherlab / MakeValidCall.cs
Last active May 19, 2021 03:15
Sample code code to illustrate how to call MakeValid
/*
SQL code for SQL Server from
https://stackoverflow.com/questions/66496778/sql-statement-including-makevalid-crushing-the-server
*/
/*
C# version using SqlGeography instead of SqlGeometry
Requires the Microsoft.SqlServer.Types assembly
Install-Package Microsoft.SqlServer.Types -Version 14.0.1016.290
*/
void MakeValidCall()
@anotherlab
anotherlab / num-lock.ps1
Last active July 5, 2020 04:40
Windows-only script to set the state of the Num Lock key
# One parameter, to set the Num Lock state to On or Off, with
# On as the default
Param(
[Parameter(Mandatory=$false)]
[ValidateSet("On", "Off")]
[String[]] $onoff='On'
)
# Get the current state of the Num Lock key
$CurrentState = [console]::NumberLock
@anotherlab
anotherlab / get-static-console.ps1
Created July 4, 2020 20:55
Get a list of static members from the system.console class
[system.console] | Get-Member -Static -MemberType property | Format-Table name
@anotherlab
anotherlab / adb-32.png
Last active September 18, 2024 21:46
Quick little PowerShell script to add the ADB tools to the path
adb-32.png
@anotherlab
anotherlab / SysProp.cs
Created February 8, 2019 20:41
Xamarin C# code to access system properties via Android's hidden SystemProperties class
using System;
namespace Os.Properties
{
// Get access to the hidden SDK class SystemProperties. The SystemProperties
// class provides access to the System Properties store. This store contains
// a list of key-value pairs
// See https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/os/SystemProperties.java
public static class SysProp
{
@anotherlab
anotherlab / program.cs
Created April 6, 2018 01:10
Creating a video capture filter with DirectShow
if (new FilterGraph() is IFilterGraph2 graphBuilder)
{
// Create a video capture filter for the device
graphBuilder.AddSourceFilterForMoniker(dev.Mon, null, dev.Name, out IBaseFilter capFilter);
// Cast that filter to IAMCameraControl from the DirectShowLib
IAMCameraControl _camera = capFilter as IAMCameraControl;
// Get the current focus settings from the webcam
_camera.Get(CameraControlProperty.Focus, out int v, out CameraControlFlags f);