Skip to content

Instantly share code, notes, and snippets.

View LanceMcCarthy's full-sized avatar
💾
Bashing __(ง'̀-'́)ง__ bugs

Lance McCarthy LanceMcCarthy

💾
Bashing __(ง'̀-'́)ง__ bugs
View GitHub Profile
@LanceMcCarthy
LanceMcCarthy / YourMauiApp.csproj
Last active May 2, 2023 23:53
An example csproj that shows how to use conditionalsfor publishing settings
View YourMauiApp.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
<OutputType>Exe</OutputType>
<RootNamespace>Hacked.Maui</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
@LanceMcCarthy
LanceMcCarthy / MauiProgram.cs
Last active September 26, 2023 15:46
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 August 30, 2022 05:40
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 August 8, 2021 15:25
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 August 4, 2021 18:19
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 July 26, 2021 18:14
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 August 24, 2023 15:18
UDM Pro IPsec VPN Configuration Updater
View vpn-config-updater.sh
#!/bin/sh
# ***** warning ***** warning ***** warning ***** warning ***** warning ***** warning *****
# THIS IS NOT LONGER A GOOD APPROACH TO USE. SCROLL DOWN TO THE COMMENTS TO SEE HOW YOU CAN USE WIREGUARD WITH A DDNS FQDN INSTEAD
# ***** warning ***** warning ***** warning ***** warning ***** warning ***** warning *****
# ___ ____ _ _ _ _
# |_ _| _ \ ___ ___ ___ | | | |_ __ __| | __ _| |_ ___ _ __
@LanceMcCarthy
LanceMcCarthy / UpdateDns.ps1
Created January 6, 2021 21:05
GoDaddy DDNS Trick
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"
@LanceMcCarthy
LanceMcCarthy / UltimateListIds.md
Last active September 2, 2023 15:38
List of Package Ids
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 December 1, 2020 14:41
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