Skip to content

Instantly share code, notes, and snippets.

Avatar

Michael Phillips idiotandrobot

View GitHub Profile
View 2022-11-21-managing-gists-locally.md
$ git clone https://gist.github.com/DannyQuah/5f43f9b75970bc4e357e42c7c9214b5d 2020.05-D.Quah-Managing-Gists-Locally.md
View win-update-powershell.ps1
iex "& { $(irm https://aka.ms/install-powershell.ps1) } -UseMSI"
View nuget-restore.ps1
if (Test-Path "nuget.exe") {
Invoke-Expression "./nuget restore"
}
elseif((Get-Command "nuget" -ErrorAction SilentlyContinue) -ne $null) {
nuget restore
}
else {
"Nuget was not found and is required to run bootstrap.ps1. Download and retry now?"
choice /c yn
if ($LASTEXITCODE -eq 1) {
View GetLatestVersion.cs
using Newtonsoft.Json;
public static async Task<Version> GetLatestVersion()
{
const string latestReleaseRequestUrl =
@"https://api.github.com/repos/{user}/{repo}/releases/latest";
try
{
string versionStr;
@idiotandrobot
idiotandrobot / Clear-NuGet-Cache.ps1
Last active December 22, 2018 16:53 — forked from thoemmi/Clear-NuGetCache.ps1
Script to delete old NuGet packages from the default global packages folder which haven't been accessed for 150 days
View Clear-NuGet-Cache.ps1
[CmdletBinding(SupportsShouldProcess=$True)]
Param(
[int]$CutoffDays = 150
)
$cutoffDate = (Get-Date).AddDays(-$CutoffDays)
# get path to cached NuGet packages
$nugetCachePath = .\Get-Nuget-Cache-Path.ps1
@idiotandrobot
idiotandrobot / dosomethingasync.cs
Last active July 21, 2018 08:13
async/await in Windows Runtime Components
View dosomethingasync.cs
public async Task DoSomethingAsync()
{
await SomethingElseAsync();
}
public async Task<Foo> DoAnotherAsync()
{
return await ReturnAFooAsync();
}
View lists.txt
3D1W9MPQGSM8P,29C9ZTBRYZTRN,BT1GTNLE3DJW,1EAB07GESHF2W,2PF1IAYUTBODP,204W6ITX1MQF4
View linq_expression.cs
// IObservable<byte> (socket.Receiver) to IObservable<string> (Receiver)
Receiver = from header in socket.Receiver.Buffer(sizeof(int))
let length = BitConverter.ToInt32(header.ToArray(), 0)
let body = socket.Receiver.Take(length)
select encoding.GetString(body.ToEnumerable().ToArray());
@idiotandrobot
idiotandrobot / appbarbutton.xaml
Created January 29, 2018 17:28
AppBarButton focus
View appbarbutton.xaml
<AppBarButton AllowFocusOnInteraction="True"/>