Skip to content

Instantly share code, notes, and snippets.

View Adam--'s full-sized avatar

Adam Anderson Adam--

View GitHub Profile
@Adam--
Adam-- / Integrating Pipenv and Azure Private Package Indexes.md
Last active March 23, 2023 19:12
Integrating Pipenv and Azure Private Package Indexes

Integrating Pipenv and Azure Private Package Indexes

Pipenv is a popular tool for automatically creating and managing Python virtual environments and installing and managing pip packages.

For more information on pipenv, the problems it solves and its benefits checkout the first page of the pipenv docs: Pipenv: Python Dev Workflow for Humans.

Unfortunately, using Azure private package indexes present some technical challenges regarding authentication. Specifically, Azure uses a web based authentication workflow that needs some addition configuration to work with pipenv.

It is assumed that you have a python and pip installed and added to your shell’s path. It's generally recommended to pip install to the user site using --user; however, I found that these user directories are typically not added to the path.

@Adam--
Adam-- / Open-Solution.psd1
Last active May 10, 2024 12:37 — forked from refactorsaurusrex/Open-Solution.psd1
PowerShell function to open the first Visual Studio solution file found within the current directory.
@{
RootModule = 'Open-Solution.psm1'
ModuleVersion = '0.2.0'
GUID = '0d320efd-ae51-49bf-a0b2-3f20ae76d6d0'
Author = 'Original: Nick Spreitzer; Modified: Adam Anderson'
FunctionsToExport = @('Open-Solution', 'Open-AtmelSolution')
AliasesToExport = @('sln', 'atsln')
}
@Adam--
Adam-- / Microsoft.PowerShell_profile.ps1
Last active November 29, 2022 16:25
Loads tools I use in the PowerShell prompt
function RunStep([string] $Description, [ScriptBlock]$script)
{
Write-Host -NoNewline "Loading" $Description.PadRight(20)
& $script
Write-Host "✓" # checkmark emoji
}
RunStep "posh-git" {
# Provides prompt with Git status summary information and tab completion for Git commands, parameters, remotes and branch names.
# https://github.com/dahlbyk/posh-git
{
"version": "1.0",
"components": [
"Component.OpenJDK",
"Component.Android.SDK.MAUI",
"Microsoft.VisualStudio.Component.MonoDebugger",
"Microsoft.VisualStudio.Component.Merq",
"Component.Xamarin.RemotedSimulator",
"Microsoft.VisualStudio.ComponentGroup.WebToolsExtensions.TemplateEngine",
"Microsoft.VisualStudio.Component.NuGet",
#r "nuget:Newtonsoft.Json, 13.0.1"
using Newtonsoft.Json;
public class Product
{
public string Name { get; set; }
public DateTime Expiry { get; set; }
public string[] Sizes { get; set; }
}
@Adam--
Adam-- / TerminalSetup.md
Last active September 16, 2022 13:39
How to setup an awesome terminal for software development on Windows

Windows Terminal

Windows Terminal is a modern feature-rich open source terminal from Microsoft that runs many shells, including PowerShell. The easiest way to install it is from the Microsoft Store.

Go ahead and open Windows Terminal, which should default to PowerShell. Have a look around, it's already pretty awesome. There's support for multiple tabs, color schemes, custom fonts, custom shells, and more. We are going to customize it even further by setting up git support, customizing the prompt, installing custom fonts, setting the color scheme, and optionally adding a couple of extra tools.

posh-git and oh-my-posh

posh-git allows git information to be displayed within PowerShell and provides tab completion of git commands and branches.

oh-my-posh is a prompt theme engine for PowerShell.

@Adam--
Adam-- / LinqAnyPerformance.md
Last active May 25, 2021 16:58
I often see `.Count() > 0` or `.Count > 0` to check if there are any elements in some collection. Linq provides an `Any()` method to check if there are any elements. `Any()` sure reads better but does it come with any downsides?

Linq Any() performance compared to Count() > 0

I often see .Count() > 0 or .Count > 0 to check if there are any elements in some collection. Linq provides an Any() method to check if there are any elements. Any() sure reads better but does it come with any downsides? Inspired by a twitter post on using Any() and benchmarking it, I decided to run some of my own tests using BenchmarkDotNet.

The benchmarks that were run compare the use of these two methods, comparing enumerables and lists with two sizes, 1000 and 1000.

BenchmarkDotNet=v0.13.0, OS=Windows 10.0.19042.985 (20H2/October2020Update)
Intel Core i7-8650U CPU 1.90GHz (Kaby Lake R), 1 CPU, 8 logical and 4 physical cores
@Adam--
Adam-- / choco packages.bat
Last active June 10, 2022 14:33
Installs software I use
REM Installing chocolatey...
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
REM Installing packages...
REM General tools
choco install microsoft-teams -fy
choco install 7zip -fy
choco install paint.net -fy
choco install greenshot -fy
choco install licecap -fy
@Adam--
Adam-- / Example.csproj
Last active October 3, 2019 17:18
Load image resource from netstandard library in Xamarin Forms (from https://github.com/xamarin/xamarin-forms-samples/tree/master/UserInterface/ThemingDemo)
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>pdbonly</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
@Adam--
Adam-- / Example.xaml
Created October 3, 2019 17:09
Create view model and set binding context in view's XAML
<!-- From https://github.com/jamesmontemagno/app-pretty-weather/blob/master/PrettyWeather/PrettyWeather/MainPage.xaml -->
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
x:Class="PrettyWeather.MainPage"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:pancake="clr-namespace:Xamarin.Forms.PancakeView;assembly=Xamarin.Forms.PancakeView"
xmlns:converters="clr-namespace:PrettyWeather.Converters"
xmlns:viewmodel="clr-namespace:PrettyWeather.ViewModel"
xmlns:model="clr-namespace:PrettyWeather.Model"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"