Skip to content

Instantly share code, notes, and snippets.

@emmanuelnk
emmanuelnk / aws-block-stack.ts
Created January 28, 2022 18:43 — forked from leegilmorecode/aws-block-stack.ts
Example of API Gateway caching on AWS using the CDK
// create the rest API for accessing our lambdas
const api: apigw.RestApi = new apigw.RestApi(this, "blogs-api", {
description: "blogs api gateway",
deploy: true,
deployOptions: {
// this enables caching on our api gateway, with a ttl of five minutes (unless overridden per method)
cachingEnabled: true,
cacheClusterEnabled: true,
cacheDataEncrypted: true,
stageName: "prod",
@emmanuelnk
emmanuelnk / displayAwsAccountAlias.js
Last active June 6, 2024 22:40
GreaseMonkey script to show an AWS account alias in the top nav bar
// ==UserScript==
// @name DisplayAWSAccountAlias
// @version 1
// @grant none
// @match https://*.console.aws.amazon.com/*
// ==/UserScript==
// Replace with your account numbers and desired alias
// The key is the account number and the value is the alias to display
const accountAliases = {
@emmanuelnk
emmanuelnk / merge.squash.rebase.md
Created August 25, 2022 16:46
git merge vs git merge --squash vs git rebase

Let's start by the following example:

[![enter image description here][1]][1]

Now we have 3 options to merge changes of feature branch into master branch:

  1. Merge commits
    Will keep all commits history of the feature branch and move them into the master branch
    Will add extra dummy commit.
@emmanuelnk
emmanuelnk / tree_style_tab_firefox.md
Created August 29, 2022 14:28 — forked from ruanbekker/tree_style_tab_firefox.md
Hide Native Tabs with Tree Style Tabs for Firefox
@emmanuelnk
emmanuelnk / CompareSheetsModifiedColumns.js
Last active September 4, 2022 16:10
CompareSheetsModifiedColumns
/**
* HOW TO USE
*
* 1. From your spreadsheet, go to Extensions > Apps Script
* 2. Paste the following function and click Run
* 3. You may be asked to give Apps Script permission to your sheet (Accept)
*
* IMPORTANT
*
* The first sheet MUST be the old sheet
@emmanuelnk
emmanuelnk / .zshenv
Last active September 13, 2022 16:10
Aliases for jira-cli with Jira Cloud and ZSH
export JIRA_API_TOKEN=XXXXXXXXXXXXXXXXXXX
@emmanuelnk
emmanuelnk / log_bash_commands.bash
Last active September 16, 2022 22:10
Log bash commands
function log_cmd()
{
"$@"
ret=$?
if [[ $ret -eq 0 ]]
then
echo "$(date -u +"%Y-%m-%dT%H:%M:%SZ") user[ $USER ] status[ Success ] code[ $ret ] cmd[ $@ ]" >> bash_command.log
else
echo "$(date -u +"%Y-%m-%dT%H:%M:%SZ") user[ $USER ] status[ Error ] code[ $ret ] cmd[ $@ ]" >> bash_command.log
@emmanuelnk
emmanuelnk / albLogFormat.interface.ts
Created February 23, 2023 15:20
AWS Application Load Balancer Access Logs Typescript Interface
export interface AlbAccessLogFormat {
/**
* The type of request or connection. The possible values are as follows (ignore any other values):
*
* * http — HTTP
* * https — HTTP over TLS
* * h2 — HTTP/2 over TLS
* * grpcs— gRPC over TLS
* * ws — WebSockets
* * wss — WebSockets over TLS
@emmanuelnk
emmanuelnk / Queries.md
Last active April 26, 2023 16:25
Useful Athena Queries

A collection of useful Athena Queries

Web Application Firewall

Create WAF logs with projection (no need to partition)

  • See the docs for reference

  • Replace the values BUCKET_NAME, AWS_ACCOUNT_NUMBER, AWS_REGION, WEB_ACL_NAME accordingly

  • Replace 'projection.date.range' = '2023/01/01/00/00,NOW', with the date your WAF logging begins (find in S3)

    Query
@emmanuelnk
emmanuelnk / mwaa_cloudwatch_get_worker_count.md
Created April 21, 2023 17:00
Managed Worklows for Apache Airflow get worker Count from Cloudwatch Insights

Cloudwatch does not provide metrics on how many workers you are running in a MWAA Environment. Fortunately we can get this information from Cloudwatch Insights using the MWAA_ENVIRONMENT_NAME-Worker log group. Every log stream has the ip address of the worker in the @logStream field

  1. Open the relevant MWAA_ENVIRONMENT_NAME-Workerlog group
  2. Open in CloudWatch Insights and paste and run the following query for your desired time range.
  3. you can then add the visualization to your desired Cloudwatch dashboard
fields @timestamp