Skip to content

Instantly share code, notes, and snippets.

View ssippe's full-sized avatar

Sam Sippe ssippe

  • Reckon
  • Gold Coast, Australia
View GitHub Profile
@ssippe
ssippe / CreateDashboard.cs
Created March 21, 2024 02:05
Create a dashboard per asg that beats the 3hr aws CloudWatch Metrics Insights limit
using Amazon.AutoScaling.Model;
using Amazon.AutoScaling;
using Amazon.CloudWatch.Model;
using Amazon;
using Amazon.CloudWatch;
const string Namespace = "CWAgent";
const string MetricName = "TCPv4 Connections Established";
@ssippe
ssippe / cartesianProduct.ts
Created April 20, 2017 00:33
Typescript Cartesian Product
const f = (a: any[], b: any[]): any[] =>
[].concat(...a.map(a2 => b.map(b2 => [].concat(a2, b2))));
export const cartesianProduct = (a: any[], b: any[], ...c: any[]) => {
if (!b || b.length === 0) {
return a;
}
const [b2, ...c2] = c;
const fab = f(a, b);
return cartesianProduct(fab, b2, c2);
@ssippe
ssippe / aws-env-var.ps1
Last active March 21, 2023 02:19
aws-env-var.ps1
aws --profile r1-dev sso login; aws --profile r1-dev configure export-credentials --format powershell | iex; devenv
using System.Linq;
using System.Data.Entity.Infrastructure;
using System;
namespace Reckon.Data.EF
{
public static class DbChangeTrackerExtension
{
/// <summary>
/// Get a summary of Tracked Changes on a DbContext.ChangeTracker
@ssippe
ssippe / AwsFirewallHolePunch.cs
Last active December 23, 2022 03:29
awspunch
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using Amazon;
parse @message "* * * * * * * * * * * * * * *" as
date, time, s_ip, cs_method, cs_uri_stem, cs_uri_query, s_port, cs_username, c_ip, cs_User_Agent, cs_Referer, sc_status, sc_substatus, sc_win32_status, time_taken
| display @timestamp,cs_method, cs_uri_stem, time_taken
| filter time_taken > 1000
| sort @timestamp desc
| limit 20
@ssippe
ssippe / gist:8fc11c4d7e766e66f06db0431dba3f0a
Created December 2, 2017 11:21
jwt+rsa+dotnet with pem
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.OpenSsl;
using Org.BouncyCastle.Security;
@ssippe
ssippe / wslNotes.md
Last active June 22, 2021 06:08
wsl notes
namespace cs9test
{
// @jbogard "it looks like the "immutable-by-default" behavior of C# 9 records is really only with the compact positional syntax, not with just the "record" keyword"
// https://twitter.com/jbogard/status/1321120266676850688
/// <summary>
/// immutable with compact positional syntax
/// </summary>
public record Person(string FirstName, string LastName);
@ssippe
ssippe / listGen.cs
Created September 14, 2020 23:53
List generation with optional members and immutable variables
static IReadOnlyList<int> GenerateList(int option)
{
IEnumerable<int> F()
{
if (option > 0)
yield return 1;
if (option > 1)
yield return 2;
if (option > 3)
yield return 3;