Skip to content

Instantly share code, notes, and snippets.

View savaged's full-sized avatar
418

David Savage savaged

418
View GitHub Profile
@savaged
savaged / FPish.cs
Last active February 22, 2023 08:27
FP styled C# example inspired by Isaac Abraham's book Programming With F#
using Unit = System.ValueTuple;
_ = App.Run(Console.WriteLine);
static class App
{
public static Unit Run(Action<string> outputter)
{
outputter(GetAwayWins().ToSummary());
return Unit.Create();
@savaged
savaged / ReverseEach.cs
Last active February 4, 2023 08:45
Demonstrating that the equivalent to the Haskell map function in C# is the Select in Linq
/*
* Trying to emulate the following Haskell, with the aim of demonstrating
* that the map function in C# is the Select in Linq...
*
* main = do
* print (reverseEach ["map", "select"])
*
* reverseEach l = map reverse l
*
*/
@savaged
savaged / Rot13.cs
Last active October 21, 2022 08:15
Caesar Cipher in C# (with Linq)
if (args?.Count() > 0)
Console.WriteLine(args[0].Select(c =>
c switch
{
>= 'a' and <= 'm' or >= 'A' and <= 'M' => (char)(c + 13),
>= 'n' and <= 'z' or >= 'N' and <= 'Z' => (char)(c - 13),
_ => c
}
).ToArray());
@savaged
savaged / coding-principles-map.wiki
Created May 5, 2022 09:32
Some coding principles / things to remember

```

                                   +----------------+
    +--------------------+         | B ehaviour     |
    | ctor for structure |         | D riven        |  
    | Load for data      |         | D evelopment   |
    +--------------------+         |         G iven |
                                   |         W hen  |
      +---------------------+      |         T hen  |
      | prefer aggregation¹ |      +----------------+
      |  to inheritance²    |     

@manualbashing
manualbashing / blog.md
Last active November 26, 2024 12:16 — forked from joncloud/pr.md
Checkout Azure DevOps Pull Requests locally

Forked from piscisaureus

Fetch and checkout one specific pull request

To identify one particular pull request, find the pull request number on the Azure DevOps site:

image

Then fetch and checkout the pull request in a local branch named pull/137

@primaryobjects
primaryobjects / readme.md
Last active January 31, 2025 17:22
How to remote desktop from Linux Mint to Windows 10 with AzureAD Azure AD login

How to remote desktop from Linux Mint to Windows 10 with AzureAD

The following steps detail how to connect over Remote Desktop from Linux Mint or Ubuntu to Windows 10 with an AzureAD username and password login account.

  1. In Windows 10, right-click This PC or My Computer and select Properties.
  2. Click Remote Settings.
  3. Check the option Allow remote connections to this computer.
  4. Uncheck the option Allow connections only from computers running Remote Desktop with Network Level Authentication.
  5. Click OK.
@savaged
savaged / FizzBuzz.cs
Last active October 12, 2022 10:00
Fizz Buzz
// Using top-level statements (see https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/tutorials/top-level-statements)
// and Linq along with pattern matching (see https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/functional/pattern-matching)
Enumerable.Range(1, 100).Select(
i =>
(i % 3, i % 5) switch
{
(0, 0) => "FizzBuzz",
(0, _) => "Fizz",
(_, 0) => "Buzz",
@krisleech
krisleech / renew-gpgkey.md
Last active February 27, 2025 20:06
Renew Expired GPG key

Renew GPG key

Given that your key has expired.

$ gpg --list-keys
$ gpg --edit-key KEYID

Use the expire command to set a new expire date:

@heroheman
heroheman / ranger-cheatsheet.md
Last active February 27, 2025 03:52
Ranger Cheatsheet

Ranger Cheatsheet

General

Shortcut Description
ranger Start Ranger
Q Quit Ranger
R Reload current directory
? Ranger Manpages / Shortcuts
@doncadavona
doncadavona / Aes256CbcEncrypterApp.cs
Last active September 9, 2024 07:17
A sample C# class to encrypt and decrypt texts using the cipher AES-256-CBC used in Laravel.
using System;
using System.Text;
using System.Security.Cryptography;
using System.Web.Script.Serialization;
using System.Collections.Generic;
namespace Aes256CbcEncrypterApp
{
class MainClass
{