Skip to content

Instantly share code, notes, and snippets.

Avatar
💾
Bashing __(ง'̀-'́)ง__ bugs

Lance McCarthy LanceMcCarthy

💾
Bashing __(ง'̀-'́)ง__ bugs
View GitHub Profile
@LanceMcCarthy
LanceMcCarthy / MauiProgram.cs
Last active Nov 10, 2022
Mica support in .NET MAUI
View MauiProgram.cs
// ************************************************************************ //
// This implementation is inspired from the official WinUI3 backdrops examples
// https://github.com/microsoft/WinUI-Gallery/blob/winui3/XamlControlsGallery/ControlPagesSampleCode/SystemBackdrops/SystemBackdropsSample2.txt
// *********************************************************************** //
using Microsoft.Maui.LifecycleEvents;
#if WINDOWS10_0_17763_0_OR_GREATER
// The namespace of where the WindowsHelpers class resides
// In older versions of .NET MAUI, this was
@LanceMcCarthy
LanceMcCarthy / Example_A.MauiProgram.cs
Last active Aug 30, 2022
MAUI Window Position and Size (WinUI3 and MacCatalyst)
View Example_A.MauiProgram.cs
// ******** WinUI3 Window management ******** //
using Microsoft.Maui.LifecycleEvents;
#if WINDOWS
using Microsoft.UI;
using Microsoft.UI.Windowing;
using Windows.Graphics;
#endif
namespace MyApp.Maui
@LanceMcCarthy
LanceMcCarthy / sensors.yaml
Created Aug 8, 2021
Tesla Powerwall Energy Sensor Template for HomeAssistant
View sensors.yaml
# This template reports three values to Home Assistant through: grid_import, grid_export and solar_production sensors
- platform: template
sensors:
grid_import:
value_template: "{{state_attr('sensor.powerwall_site_now', 'energy_exported_(in_kW)')}}"
unit_of_measurement: kWh
device_class: energy
attribute_templates:
last_reset: "1970-01-01T00:00:00+00:00"
state_class: "measurement"
@LanceMcCarthy
LanceMcCarthy / MainWindow.xaml
Created Aug 4, 2021
A WPF control that stacks a TextBox and a TextBlock togetther
View MainWindow.xaml
<Window x:Class="YourApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:YourApp"
Title="MainWindow" Height="350" Width="525">
<Grid>
<local:TextSandwichControl Text="I'm in the textbox"
HeaderText="I'm the label"
Margin="10"/>
@LanceMcCarthy
LanceMcCarthy / Clean_Bin_Obj_Zip.ps1
Created Jul 26, 2021
Clean up bin obj packages
View Clean_Bin_Obj_Zip.ps1
# PowerShell script that recursively deletes all 'bin' and 'obj' (or any other specified) folders inside current folder
$CurrentPath = (Get-Location -PSProvider FileSystem).ProviderPath
# recursively get all folders matching given includes, except ignored folders
$FoldersToRemove = Get-ChildItem .\ -include bin,obj,*.zip -Recurse | Where-Object {$_ -notmatch '_tools' -and $_ -notmatch '_build'} | ForEach-Object {$_.fullname}
# recursively get all folders matching given includes
$AllFolders = Get-ChildItem .\ -include bin,obj,*.zip -Recurse | ForEach-Object {$_.fullname}
# subtract arrays to calculate ignored ones
@LanceMcCarthy
LanceMcCarthy / vpn-config-updater.sh
Last active Sep 7, 2022
UDM Pro IPsec VPN Configuration Updater
View vpn-config-updater.sh
#!/bin/sh
# ___ ____ _ _ _ _
# |_ _| _ \ ___ ___ ___ | | | |_ __ __| | __ _| |_ ___ _ __
# | || |_) / __|/ _ \/ __| | | | | '_ \ / _` |/ _` | __/ _ \ '__|
# | || __/\__ \ __/ (__ | |_| | |_) | (_| | (_| | || __/ |
# |___|_| |___/\___|\___| \___/| .__/ \__,_|\__,_|\__\___|_|
# |_|
# CLI parameters
View UpdateDns.ps1
Write-Output "$(Get-Date -Format 'u') Quick & Dirty DDNS"
# Go to https://developer.godaddy.com/ and get an API key + secret
$godaddy_api_key = ""
$godaddy_api_key_secret = ""
$godaddy_authorization = "sso-key $($godaddy_api_key):$($godaddy_api_key_secret)"
# We will be using the domans endpoint https://developer.godaddy.com/doc/endpoint/domains
# Lets say you want to update "wan.mydomain.com", the hostname is 'wan' and domain is 'mydomain.com'
$domain = "mydomain.com"
View UltimateListIds.md
Name Package Id Version Source
7Zip 7zip.7zip 19.0.0 winget
Altap Salamander salamander choco
Alt-Tab Terminator alt-tab-terminator choco
AutoHotkey Lexikos.AutoHotkey 1.1.33.02 winget
AutoHotkey Store Edition HaukeGtze.AutoHotkeypoweredbyweatherlights.com Latest msstore (via winget)
Carnac
@LanceMcCarthy
LanceMcCarthy / Lance_McCarthy_Progress_public.asc
Created Dec 1, 2020
Lance McCarthy GPG Key Progress Software
View Lance_McCarthy_Progress_public.asc
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQGNBF/BYpsBDACpvtR0aTeVY3jwc84YXkQSSpf+Ihe8Si9OQGOiVRkD3bx0PeLg
HsjP6R5MarxVpOb1QN4v0tFuXm4xn2RAqgRjScwII8meGVjYrhvcr2dBfEykFn44
WNErRwzfn6gg8DpHQe9y/kIx15CzeTJw+iDUppsyLd9jXVohEH01C6q/l+LpX2Y8
dgUw/7F9dP6S8N4GjyZ7OiG5Wo7Y2DZVqgJSfjU5tjQDNUgl/8jY59lI0MePJwoE
0b5wQapiSfy95t40b4AftSYYnyrhq9aX9cU7A2ojE3QUjfj5FWHja34C54gkuS7u
Pq9FgvGzW68BAJNL6ZAh0u8LnOSPyJlB7KsMjGWjAfnZKFHz68RogjfmO4Tdd5JQ
T5+3taV6ug8zmt3HDR/T1O/PSn1bn3KUlNqyTiYDsmiHecFFdTv9xFrUuZCDSXWc
TW2QzhVYvImhh0B2l9/+Ke9qjNtYjVm/r7MPQ/GJEjwiHFfflbLHIbSua6mHTPqN
@LanceMcCarthy
LanceMcCarthy / App.xaml
Last active Aug 28, 2020
Lance Uno and Telerik app.xaml
View App.xaml
<Application
x:Class="UnoTester.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UnoTester"
xmlns:controls="using:Telerik.UI.Xaml.Controls">
<Application.Resources>
<ResourceDictionary>