Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Martin Beeby thebeebs

🏠
Working from home
Block or report user

Report or block thebeebs

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@thebeebs
thebeebs / Function.cs
Created May 21, 2020
Lambda Injection without a decorator.
View Function.cs
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
Lambda Injection Prototype
View Function.cs
[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}
};
View InjectDelayPolicy.cs
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 Mar 4, 2020
A solution to the questiond 60207104 on stack overflow.
View S0-60207104
static void Main(string[] args)
{
var prog = new Program();
prog.MainAsync().Wait();
}
private async Task MainAsync()
{
var kmsClient = new AmazonKeyManagementServiceClient(RegionEndpoint.EUCentral1);
View gist:14163a865788eb0ded1dedb12b8f9877
#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) {
View gist:6f9af41001df66c606be102fd349a8bf
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 Aug 12, 2019
Simple Lambda Example
View lambda.cs
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 Aug 12, 2019
Creating a bucket using the CDK
View cdk-bucket.cs
new Bucket(this, "MyFirstBucket", new BucketProps
{
Versioned = true
});
@thebeebs
thebeebs / s3.cs
Created Aug 12, 2019
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…
View s3.cs
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 ***";
View index.html
<div id="app">
<button @click="disconnect" v-if="status === 'connected'">Disconnects </button>
<button @click="connect" v-if="status === 'disconnected'">Connect</button> {{ status }}
<br /><br />
<div v-if="status === 'connected'">
<form @submit.prevent="sendMessage" action="#">
<input v-model="message"><button type="submit">Send Message</button>
</form>
<ul id="logs">
<li v-for="log in logs" class="log">
You can’t perform that action at this time.