Skip to content

Instantly share code, notes, and snippets.

View peter-sereda's full-sized avatar

Peter Sereda peter-sereda

View GitHub Profile
@peter-sereda
peter-sereda / amplify-lambda-sqs-handler-sample.json
Last active June 3, 2021 14:57
Sad example of how verbose and messy Amplify and Cloudformation template files are. This 300 lines long piece of code is just an example of a descriptor for a tiny Lambda function listening to messages in SQS queue. Also keep in mind source code of the lambda itself on top of this as well as several other small config files.
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Lambda Function resource stack creation using Amplify CLI",
"Parameters": {
"CloudWatchRule": {
"Type": "String",
"Default": "NONE",
"Description": " Schedule Expression"
},
"env": {
@peter-sereda
peter-sereda / NestedPartialBuilder.cs
Last active February 11, 2019 15:33
Implementation of the well-known GoF Builder pattern but using C# nested types and partial classes features to make sure: 1) nobody else is able to instantiate our class; 2) code is clean and short by splitting it into 2 different files. Please see my other gist for the sample of how to use it with Fluent API code-style.
// Product we need to build. Located in the first file Product.cs
public partial class Product
{
public int Id { get; private set;}
public int Name { get; private set; }
public void IEnumerable<Product> Children { get; }
// many-many lines of some complex internal details of our class
// private contructor to make sure nobody can directly create our instances.
private Product() {}