Skip to content

Instantly share code, notes, and snippets.

View anaarezo's full-sized avatar
🫖
Tea?

Ana Arezo anaarezo

🫖
Tea?
View GitHub Profile
@anaarezo
anaarezo / generic-waf-cdk-example_three.ts
Last active June 28, 2024 10:01
WAF CDK examples with WAF Stack.
import * as cdk from "aws-cdk-lib";
import * as cloudfront from "aws-cdk-lib/aws-cloudfront";
import * as origins from "aws-cdk-lib/aws-cloudfront-origins";
import * as acm from "aws-cdk-lib/aws-certificatemanager";
import { ApplicationStack, ApplicationStackProps } from "./application";
export function createCDN(
stack: ApplicationStack,
props: ApplicationStackProps
) {
@anaarezo
anaarezo / generic-waf-cdk-example_two.ts
Last active June 28, 2024 10:00
WAF CDK examples with WAF Stack.
// https://spoofing.medium.com/deploying-a-cloudfront-waf-with-typescript-and-aws-cdk-e35df6d7d00c
import * as cdk from "aws-cdk-lib";
import * as wafv2 from "aws-cdk-lib/aws-wafv2";
import { aws_opensearchservice as opensearchservice } from "aws-cdk-lib";
import { aws_kinesisfirehose as kinesisfirehose } from "aws-cdk-lib";
import { aws_s3 } from "aws-cdk-lib";
import * as ec2 from "aws-cdk-lib/aws-ec2";
import * as secretsmanager from "aws-cdk-lib/aws-secretsmanager";
import * as logs from "aws-cdk-lib/aws-logs";
import { RetentionDays } from "aws-cdk-lib/aws-logs";
@anaarezo
anaarezo / generic-waf-cdk-example_one.ts
Last active June 28, 2024 09:55 — forked from statik/waf.ts
WAF CDK examples with WAF Stack.
import * as cdk from "@aws-cdk/core";
import * as wafv2 from "@aws-cdk/aws-wafv2";
// This extends the base cdk stack properties to include a tag name input.
export interface StackProps extends cdk.StackProps {
tag: string;
applicationName?: string;
}
export class WAFStack extends cdk.Stack {
export const removeSpecialCharacters = (str?: string) => {
return str
?.replace(/[ÀÁÂÃÄÅ]/g, 'A')
.replace(/[àáâãäå]/g, 'a')
.replace(/[ÈÉÊË]/g, 'E')
.replace(/[^a-z0-9]/gi, ' ');
};
export const getNameInitials = (name?: string) => {
const initials = name?.match(/\b(\w)/g);
@anaarezo
anaarezo / reduce-array.js
Last active June 28, 2024 10:22
Group array of objects based in Date
const data = [
{ transactionStatus: 'PROCESSING', date: '2021-12-26T09:40:50', brand: 'MASTERCARD', transactionType: 'CREDIT', value: 500000,},
{ transactionStatus: 'RECEIVED', date: '2021-12-26T10:12:41', brand: 'MASTERCARD', transactionType: 'CREDIT', value: 500000,},
{ transactionStatus: 'CANCELED', date: '2021-12-26T10:12:41', brand: 'MASTERCARD', transactionType: 'CREDIT', value: 500000,},
{ transactionStatus: 'CANCELED', date: '2021-12-27T12:35:23', brand: 'MASTERCARD', transactionType: 'CREDIT', value: 500000,},
];
const groups = data.reduce((groups, sale) => {
const time = sale.date.split('T')[0];
@anaarezo
anaarezo / generate-ssh-key.md
Last active June 28, 2024 10:13
How to generate SSH Key to put on GitHub
  1. Open the terminal and run the code below:
$ cat ~/.ssh/id_rsa.pub
  1. Copy the generated code, as example:
ssh-rsa AAADDDB3NzaC1yc2EAAAADAQABAAACAQDYEuGZGyrJZZW8+IsZhvbi4Mb/1alI8g6HCyxLBrL0EikwLVnskKSgDH2/t+Uayyf3jPJbV4lnG3ciKHAZZvuiXkh80YvrO+BxmAbWSZvk3ppcsypsYi+4T5cbJX5f3h5jfpYOhR1cNw1bj23jIBA6VEQgVFWMGA4vEomOc1AkHI5WUveGb/TSg1Zl5Q+4jIKaHfIRfE+Ykymaxp/TSol9lrrUUmhHngQmMVDEBI0NAIt60lkO4wBB2xvRLDTxKScXe2OPQ7YMG+trIPKQH2M8uS3fyc0wWwhOYx20OXc4bpiLLvoOOjFLWL26GBQgmST7NZeU83QcMuFCMMlhsfrCWJjYlghhrfWVWJezTJghJWiW2fpfqjJIYrtI2umNgZywxPWTebMo07fGLZHr5Dc4NWbPDzN+PtUmpE+lxHp68KlOun6eh+xEzuPIAxhpGV/bwjH9MeDlj9YMAgzhJy/ORM/S/CmI7pLVZR/mUD8IB4qbo7hePf5WCyWzyG98BGmkKlHyM+Lb5QotW8d+fDIm1NqObG5btzY5b15N/9VJXQkt8OVtc7StuXcWFj3Xyq300msLb+E/cF1ZX185Rn4pqYJH0OCCGCZXTtUo6MjZybWFskZVR5bJs0++13RfM0ruhY7Bvr3Yt7IySxp8AR6Yw1ZL5k4qt31HkyWvOf3k5w== laura.arezo@gmail.com
@anaarezo
anaarezo / gdc.md
Last active June 28, 2024 10:12
Amazon GDC algorithm
var houses = [1, 0, 0, 0, 0, 1, 0, 0];
var days = 1;

function cellCompete(state, days){
  if(state.length > 8 || days < 1){
    return false;
  }

 var currentIndex, previousValue, nextValue;