Skip to content

Instantly share code, notes, and snippets.

View yetanotherchris's full-sized avatar
🔏
;ÿÿÿÿrules

Chris S. yetanotherchris

🔏
;ÿÿÿÿrules
View GitHub Profile
@yetanotherchris
yetanotherchris / install-rabbitmq.sh
Last active April 29, 2023 07:10
RabbitMQ on Docker with admin UI
# AWS specific install of Docker
sudo yum update -y
sudo yum install -y docker
sudo service docker start
sudo usermod -a -G docker ec2-user
# exit the SSH session, login again
# Docker
docker run -d --hostname my-rabbit --name some-rabbit -p 4369:4369 -p 5671:5671 -p 5672:5672 -p 15672:15672 rabbitmq
@yetanotherchris
yetanotherchris / hastebin-client-csharp.cs
Last active April 18, 2023 06:27
A Hastebin client in C#
void Main()
{
// To run Hastebin in Docker:
// docker run --name pastebin -p 801:80 mkodockx/docker-pastebin
string baseUrl = "http://localhost:801/";
var hasteBinClient = new HasteBinClient(baseUrl);
HasteBinResult result = hasteBinClient.Post("Hello hastebin").Result;
if (result.IsSuccess)
@yetanotherchris
yetanotherchris / gist:5181209
Last active April 17, 2023 08:32
Arrange act assert snippet for Visual Studio
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Arrange Act Assert</Title>
<Author>Chris</Author>
<Description>Adds an arrange, act, assert to a test</Description>
<HelpUrl />
<Keywords />
<SnippetTypes />
@yetanotherchris
yetanotherchris / gist:4757231
Created February 11, 2013 20:15
XML formatter for C#
/// <summary>
/// Formats the provided XML so it's indented and humanly-readable.
/// </summary>
/// <param name="inputXml">The input XML to format.</param>
/// <returns></returns>
public static string FormatXml(string inputXml)
{
XmlDocument document = new XmlDocument();
document.Load(new StringReader(inputXml));
@yetanotherchris
yetanotherchris / PublicKeyCryptographyExample.cs
Last active January 12, 2023 09:25
Public key cryptography by example in .NET Core
using System;
using System.IO;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
namespace PublicKeyCryptographyExample
{
//
// https://yetanotherchris.dev/security/public-private-key-in-netcore-by-example/
//
@yetanotherchris
yetanotherchris / google-cloud-pubsub-example.cs
Last active December 16, 2022 13:56
Google Cloud Pub/Sub C# example
//
// Google Cloud Pub/Sub C# example
// NOTE: This is a .NET Core 1.1 console app.
// Use "dotnet run" to run it, run setup.ps1 first.
//
using System;
using System.Collections.Generic;
using Google.Cloud.PubSub.V1;
using Google.Protobuf;
@yetanotherchris
yetanotherchris / gist:4960171
Last active September 26, 2022 02:04
Double Linked List C# example
public static void Main()
{
DoubleLinkedList list = new DoubleLinkedList();
list.Insert("1");
list.Insert("2");
list.Insert("3");
DoubleLink link4 = list.Insert("4");
list.Insert("5");
Console.WriteLine("List: " + list);
@yetanotherchris
yetanotherchris / gist:4953115
Last active May 17, 2022 03:38
Syntax highlighter for C#
/// <summary>
/// A basic implementation of a pretty-printer or syntax highlighter for C# soure code.
/// </summary>
public class SourceColorer
{
private string _commentCssClass;
private string _keywordCssClass;
private string _quotesCssClass;
private string _typeCssClass;
private bool _addStyleDefinition;
@yetanotherchris
yetanotherchris / first-steps.md
Created August 1, 2018 16:42
Converting NUnit to XUnit
  • Get VS Code
  • Remove using NUnit.Framework;
  • Add using XUnit;
  • Replace all [Test] with [Fact]
  • Replace [SetUp] with a constructor
  • Replace Assert.That(actualValue, Is.EqualTo(value)); with Assert.Equal(expected, actual)
    • highlight Is.EqualTo(
    • Delete it
    • Select to the end of the line
  • Ctrl + X
@yetanotherchris
yetanotherchris / NorvigSpellChecker.cs
Last active April 22, 2022 14:18
How to Write a Spelling Corrector in C# (from Peter Norvig's Python example)
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
namespace SpellingCorrector
{
/// <summary>
/// Conversion from http://norvig.com/spell-correct.html by C.Small