$ git clone https://gist.github.com/DannyQuah/5f43f9b75970bc4e357e42c7c9214b5d 2020.05-D.Quah-Managing-Gists-Locally.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<PropertyGroup> | |
<RestoreProjectStyle>PackageReference</RestoreProjectStyle> | |
</PropertyGroup> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Regex illegalInFileName = new Regex(@"[\\/:*?""<>|]"); | |
string myString = illegalInFileName.Replace(myString, ""); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scp –r pi@mynaturewatchcamera:/home/pi/NaturewatchCameraServer/naturewatch_camera_server/static/data ~/Desktop/data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Icon IconFromImage(Image img) { | |
var ms = new System.IO.MemoryStream(); | |
var bw = new System.IO.BinaryWriter(ms); | |
// Header | |
bw.Write((short)0); // 0 : reserved | |
bw.Write((short)1); // 2 : 1=ico, 2=cur | |
bw.Write((short)1); // 4 : number of images | |
// Image directory | |
var w = img.Width; | |
if (w >= 256) w = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dotnet tool update --global powershell |