Skip to content

Instantly share code, notes, and snippets.

View thebeebs's full-sized avatar
🏠
Working from home

Martin Beeby thebeebs

🏠
Working from home
View GitHub Profile
@thebeebs
thebeebs / index.html
Created July 17, 2020 21:45
status page concept
<div class="container">
<h1>MYOB Status Page Concept</h1>
<div class="accordion">
<dl>
<dt><a class="accordionTitle" href="#">MYOB Advanced</a></dt>
<dd class="accordionItem accordionItemCollapsed">
<div class="accordionStatusItem itemN"><p>SYSTEM STATUS: NORMAL</p>
<br><p>2 days, 3 hours, 6 minutes and 11 seconds. </p></div>
<hr>
<div class="accordionStatusItem"><p>UPTIME OVERVIEW</p></div>
@thebeebs
thebeebs / Function.cs
Created May 21, 2020 16:08
Lambda Injection without a decorator.
public async Task<APIGatewayProxyResponse> FunctionHandlerException(APIGatewayProxyRequest apigProxyEvent, ILambdaContext context)
{
return await new ChaosWrap<InjectException>().Execute(async () =>
{
var location = await GetCallingIP();
var body = new Dictionary<string, string>
{
{"message", "hello world"},
{"location", location}
};
@thebeebs
thebeebs / Function.cs
Created May 21, 2020 16:00
Lambda Injection Prototype
[InjectDelayPolicy]
public async Task<APIGatewayProxyResponse> FunctionHandler(APIGatewayProxyRequest apigProxyEvent,
ILambdaContext context)
{
var location = await GetCallingIP();
var body = new Dictionary<string, string>
{
{"message", "hello world"},
{"location", location}
};
@thebeebs
thebeebs / InjectDelayPolicy.cs
Last active May 21, 2020 15:59
Embarrassing
private static async Task<T> WrapAsync<T>(Func<object[], object> target, object[] args, string name)
{
try
{
return await new ChaosWrap<InjectException>().Execute<T>(() => (Task<T>) target(args));
}
catch (Exception e)
{
Console.WriteLine($"Async method `{name}` throws {e.GetType()} exception.");
return default;
@thebeebs
thebeebs / S0-60207104
Created March 4, 2020 21:29
A solution to the questiond 60207104 on stack overflow.
static void Main(string[] args)
{
var prog = new Program();
prog.MainAsync().Wait();
}
private async Task MainAsync()
{
var kmsClient = new AmazonKeyManagementServiceClient(RegionEndpoint.EUCentral1);
@thebeebs
thebeebs / gist:14163a865788eb0ded1dedb12b8f9877
Created September 3, 2019 14:15
PowerShell Lambda Script
#Requires -Modules @{ModuleName='AWSPowerShell.NetCore';ModuleVersion='3.3.343.0'}
$rulesRemoved = 0
Get-EC2SecurityGroup | ForEach-Object -Process {
$securityGroupId = $_.GroupId
$_.IpPermission | ForEach-Object -Process {
if($_.ToPort -eq 3389) {
@thebeebs
thebeebs / gist:6f9af41001df66c606be102fd349a8bf
Last active September 3, 2019 14:29
PowerShell Commands
Install-Module AWSLambdaPSCore -Scope CurrentUser
Get-AWSPowerShellLambdaTemplate
New-AWSPowerShellLambda -ScriptName RDPLockDown -Template Basic
Publish-AWSPowerShellLambda -ScriptPath .\RDPLockDown.ps1 -Name RDPLockDown -Region us-east-1
@thebeebs
thebeebs / lambda.cs
Created August 12, 2019 21:21
Simple Lambda Example
using Amazon.Lambda.Core;
// Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class.
[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))]
namespace demoLambda
{
public class Function
{
@thebeebs
thebeebs / cdk-bucket.cs
Created August 12, 2019 21:03
Creating a bucket using the CDK
new Bucket(this, "MyFirstBucket", new BucketProps
{
Versioned = true
});
@thebeebs
thebeebs / s3.cs
Created August 12, 2019 20:49
The following C# code example creates two objects with two PutObjectRequest requests: The first PutObjectRequest request saves a text string as sample object data. It also specifies the bucket and object key names. The second PutObjectRequest request uploads a file by specifing the file name. This request also specifies the ContentType header an…
using Amazon.S3;
using Amazon.S3.Model;
using System;
using System.Threading.Tasks;
namespace Amazon.DocSamples.S3
{
class UploadObjectTest
{
private const string bucketName = "*** bucket name ***";