Skip to content

Instantly share code, notes, and snippets.

@JamesTryand
JamesTryand / docs.md
Created November 14, 2023 06:06
roslyn

You i have a lot of C# source code. There are certain strings in the text of the source that i would like to extract into yaml for instance a line like "class ShoppingCartEmptied : INotification" - would be

messages:
  ShoppingCartEmptied:
    payload:
      type: string
      pattern: '^hello .+$'
@JamesTryand
JamesTryand / DomainTests.cs
Created January 23, 2023 10:45
example of tests in BDD style for eventsourcing library
public class DomainModelTests {
[Fact]
public void ANewModelWillHaveNoUncommittedChangesTest() {
new SimpleDomainModel().Changes().ShouldBeEmpty();
}
[Fact]
public void ANewModelDoingNothingWIllHaveNoUncommittedChanges() {
@JamesTryand
JamesTryand / Program.cs
Created January 23, 2023 10:35
Abusing yield to expose internal state machine
Console.WriteLine();
var statemachine = new StateMachineInstance();
statemachine.State2();
statemachine.State3();
statemachine.State4();
Console.ReadLine();
Add-Type: C:\Users\james\Documents\PowerShell\Modules\showui\1.5\CodeGenerator\InstallShowUIAssembly.ps1:176
Line |
176 | Add-Type @addTypeParameters
| ~~~~~~~~~~~~~~~~~~
| Cannot bind parameter 'Language'. Cannot convert value "CSharpVersion3" to type "Microsoft.PowerShell.Commands.Language". Error: "Unable to match the identifier name CSharpVersion3 to a valid enumerator name. Specify
| one of the following enumerator names and try again: CSharp"
Add-Type: C:\Users\james\Documents\PowerShell\Modules\showui\1.5\CodeGenerator\Add-UiModule.ps1:228
Line |
228 | Add-Type @addTypeParameters
@JamesTryand
JamesTryand / OpenSourceBaas.md
Created February 8, 2020 01:58 — forked from PARC6502/OpenSourceBaas.md
List of open source, self hosted BaaS - Backend as a service

Parse Server - ~16K stars

  • javascript based
  • mongodb or postgres database
  • Has dockerfile

nakama - ~2.2k stars

  • go based
  • cockroach db
  • designed for use with games
1..9| %{$sb = [text.stringbuilder]::new()}{ [void]$sb.Append($_); "$([string]::Join('',[linq.enumerable]::Repeat(' ',9 - $_)))$($sb.ToString()) x 8 + $_ = $([int]$sb.ToString() * 8 + $_)" }
# for the correct coloring use
1..9| %{$sb = [text.stringbuilder]::new()}{ [void]$sb.Append($_);$ws = [string]::Join('',[linq.enumerable]::Repeat(' ',9 - $_)); "$($ws)$($sb.ToString()) x 8 + $_ = $([int]$sb.ToString() * 8 + $_)$($ws)" } | %{ write-host $_.substring(0,12) -b white -f black -NoNewline ; write-host $_.substring(12,1) -b white -f red -NoNewline ; write-host $_.substring(13) -b white -f black }

Keybase proof

I hereby claim:

  • I am jamestryand on github.
  • I am monkeyonahill (https://keybase.io/monkeyonahill) on keybase.
  • I have a public key ASAQkcHwjhAAt1u3eWz4VT0HRQ7V5v2Pd0IdLkjzyi6Mvwo

To claim this, I am signing this object:

@JamesTryand
JamesTryand / .lein\profiles.clj
Created February 13, 2019 00:34
setup nrepl
{:user {:plugin-repositories [["private-plugins" {:url "private repo url"}]]
:dependencies [[pjstadig/humane-test-output "0.8.2"]]
:injections [(require 'pjstadig.humane-test-output)
(pjstadig.humane-test-output/activate!)]
:plugins [[io.sattvik/lein-ancient "0.6.11"]
[lein-pprint "1.1.2"]
[com.jakemccrary/lein-test-refresh "0.5.5"]
[lein-autoexpect "1.4.2"]
[jonase/eastwood "0.2.1"]
[lein-kibit "0.0.8"]]
<html>
<head>
<title>DONE</title>
<style>
.container {
display: flex;
flex-direction: column;
flex-wrap: nowrap;
align-items: center;
}
@JamesTryand
JamesTryand / randomcheck.ps1
Created January 6, 2017 06:38
.net random number generator test
$a = [array]::CreateInstance([int],101)
1..1000000 | %{ get-random -max 100 -min 0 } | %{ $a[$_] = $a[$_] + 1 }
0..100| select @{n='Value';e={$_}}, @{n='Count';e={$a[$_]}} | sort count
gave the following results
Value Count
----- -----
100 0
32 9669