Skip to content

Instantly share code, notes, and snippets.

davideicardi / static-website.sub-stack.ts
Created October 17, 2023 23:17
AWS CDK Static Web Site stack from S3 with CloudFront and custom domain
import { Bucket } from 'aws-cdk-lib/aws-s3';
import { BucketDeployment, Source } from 'aws-cdk-lib/aws-s3-deployment';
import { CloudFrontWebDistribution, OriginProtocolPolicy } from 'aws-cdk-lib/aws-cloudfront';
import { ARecord, HostedZone, RecordTarget } from 'aws-cdk-lib/aws-route53';
import { CloudFrontTarget } from 'aws-cdk-lib/aws-route53-targets';
import { Construct } from 'constructs';
import { aws_s3 } from 'aws-cdk-lib';
interface StaticWebsiteProps {
domainName: string;
davideicardi /
Created May 25, 2022 10:05
How to print current date as UTC ISO 8601 format
date --utc --iso-8601=seconds
davideicardi /
Last active May 4, 2022 09:09
Remove all GIT branches that match a specific name using bash
# Remove all GIT branches starting with `fix/`, just locally
git branch | grep fix/ | xargs -I '{}' git branch -d '{}'
davideicardi / aws-console
Last active May 18, 2022 18:56 — forked from ottokruse/aws-console
Python script to launch the AWS console in your webbrowser, using a presigned URL generated from your AWS CLI credentials
#!/usr/bin/env python3
Based on:
- Save this script somewhere on your path (e.g. `vi /usr/local/bin/aws-console && chmod +x /usr/local/bin/aws-console`)
- Install dependencies: pip install boto3
- Make AWS credentials available in one of the usual places where boto3 can find them (~/.aws/credentials, env var, etc.)
- Excute the script: `AWS_PROFILE=your-profile aws-console`
- :tada: Your browser opens and you are signed in into the AWS console
davideicardi / azure-pipelines.yaml
Created December 21, 2021 13:37
Calculate version inside an Azure DevOps pipeline using counter function
# Calculate version that will be incremented for each build whenever Major or Minor change, and different for each branch.
# Solution based on
# This could be useful if gitversion cannot be used.
# Otherwise the best solution is to use instead the default gitversion task:
# ....
# Versioning is handled using a format like major.minor.patch{-snapshot}
# Major and Minor are fixed, patch is calculated using a counter (it will reset to 0 every time other values change).
davideicardi / Dockerfile
Created November 24, 2021 16:43
Dockerfile template for node following best practices
# References:
FROM node:16.13-alpine3.12 AS builder
WORKDIR /usr/src/app
davideicardi / gist:ba15ebc5d784bd670723c16627eddcc9
Last active November 26, 2021 09:01
Bash script best practices
# set -e = exit in case of errors
# set -u = no undefined variable
# set -o pipefail = prevent pipeline errors
# more info:
set -euo pipefail
# TODO Add your script
davideicardi / FutureUtils.scala
Last active January 29, 2021 01:01
Scala Future utilities to process elements asynchronous one after another
import scala.concurrent.{ExecutionContext, Future}
object FutureUtils {
* Process elements asynchronous one after another.
* Equivalent to `Future.sequence(`
* but doing the processing sequentially instead of in parallel
def mapAsyncSequentially[TInput, TResult](elements: Iterable[TInput])
(mapFunction: TInput => Future[TResult])
davideicardi / SimpleTopology.scala
Last active September 30, 2020 19:52
Simple Kafka Streams Testing
import java.util.Properties
import org.apache.kafka.streams.scala.ImplicitConversions._
import org.apache.kafka.streams.scala._
import org.apache.kafka.streams.scala.kstream._
import org.apache.kafka.streams.{StreamsConfig, Topology}
import Serdes._
class SimpleTopology(
val bootstrapServers: String,
davideicardi /
Created September 12, 2020 21:46
Publish Maven library to Github packages with SBT and github actions


Add the following configuration to your build.sbt:

  // publish to github packages settings
  publishTo := Some("GitHub <GITHUB_OWNER> Apache Maven Packages" at "<GITHUB_OWNER>/<GITHUB_PROJECT>"),
  publishMavenStyle := true,
  credentials += Credentials(
    "GitHub Package Registry",