Skip to content

Instantly share code, notes, and snippets.

Avatar

Michael Phillips idiotandrobot

View GitHub Profile
View broken-wsl.cmd
lxrun /uninstall /full`
lxrun /install`
View 1-linq-list-to-dictionary.cs
var result = List.Select((x, i) => new { Key = i, Value = x }).ToDictionary(x => x.Key, x => x.Value);
View wpf-page-in-frame.xaml
<Frame>
<Frame.Content>
<Page/>
</Frame.Content>
</Frame>
View wpf-system-net-sockets-error.xml
<PropertyGroup>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
</PropertyGroup>
View syndicationclient-error.cs
var client = new SyndicationClient();
client.SetRequestHeader("accept", "text/html, application/xhtml+xml, */*");
client.SetRequestHeader("user-agent", "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)");
View removing-characters-forbidden-in-windows-filenames.cs
Regex illegalInFileName = new Regex(@"[\\/:*?""<>|]");
string myString = illegalInFileName.Replace(myString, "");
View mynaturewatchcamera-download-all.bat
scp –r pi@mynaturewatchcamera:/home/pi/NaturewatchCameraServer/naturewatch_camera_server/static/data ~/Desktop/data
View PowerShellInvoke.cs
string directory = ""; // directory of the git repository
using (PowerShell powershell = PowerShell.Create()) {
// this changes from the user folder that PowerShell starts up with to your git repository
powershell.AddScript($"cd {directory}");
powershell.AddScript(@"git init");
powershell.AddScript(@"git add *");
powershell.AddScript(@"git commit -m 'git commit from PowerShell in C#'");
powershell.AddScript(@"git push");
View App.xaml
<Application x:Class="WpfTrayIcon.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
ShutdownMode="OnExplicitShutdown"
>
<Application.Resources>
</Application.Resources>
</Application>
View md5hash.ps1
$md5 = New-Object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider
$utf8 = New-Object -TypeName System.Text.UTF8Encoding
$String = "Hello, world!"
$Hash = ([System.BitConverter]::ToString($md5.ComputeHash($utf8.GetBytes($String)))).replace("-","").ToLower()