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 / hello.md
Created February 12, 2024 20:59
Env Tips

To determine where an environment variable is set, you can follow these steps:

  1. Environment Variables Dialog:

    • Press Win + R to open the Run dialog.
    • Type sysdm.cpl and hit Enter.
    • Go to the Advanced tab and click the Environment Variables button.
    • Here, you'll find both user-specific and system-wide environment variables. You can view, edit, or delete them.
  2. Registry Editor:

    • Open the Registry Editor by pressing Win + R, typing regedit, and hitting Enter.
@LanceMcCarthy
LanceMcCarthy / README.md
Last active December 20, 2023 13:28
VS Live Episode: Resources for Publishing .NET MAUI Projects

.NET MAUI Publishing Resources

So you're done building your .NET MAUI application, congrats! Now it's time to publish them, This can be a tricky topic to navigate, even to dedicated DevOps engineers who do this regularly because of the number of moving pieces in the puzzle.

To help you, I have combined several resources that are a great place to get started. These are not only a good Getting Started experience, but it's also a good thing to bookmark as a quick look-up reference.

Table of Contents

@LanceMcCarthy
LanceMcCarthy / YourMauiApp.csproj
Last active May 2, 2023 23:53
An example csproj that shows how to use conditionalsfor publishing settings
<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 January 25, 2024 21:33
Mica support in .NET MAUI
// ************************************************************************ //
// 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)
// ******** 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
# 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
<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
# 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
#!/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
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"