Skip to content

Instantly share code, notes, and snippets.

@andreacioni
andreacioni / app.controller-1.ts
Last active October 25, 2024 16:29
NestJS Authentication: Single Sign On with SAML 2.0
@Get('api/auth/sso/saml/login')
@UseGuards(SamlAuthGuard)
async samlLogin() {
//this route is handled by passport-saml
return;
}
@LayZeeDK
LayZeeDK / should-i-use-an-angular-module.md
Created August 23, 2022 08:45
Should I use an Angular module?
graph TD
  A[Should I use an Angular module?] --> B{Is it a component?}
  B -->|Yes| X[Don't use an Angular module]
  B -->|No| C{Is it a directive?}
  C -->|Yes| X
  C -->|No| D{Is it a pipe?}
  D -->|Yes| X
  D -->|No| E{Is it a service?}
 E -->|Yes| X
@statik
statik / waf.ts
Last active October 16, 2024 02:36
WAF with CDK examples
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 {
@lorey
lorey / selenium_xhr_requests_via_performance_logging.py
Last active November 5, 2024 15:20
Access Chrome's network tab (e.g. XHR requests) with Selenium
#
# This small example shows you how to access JS-based requests via Selenium
# Like this, one can access raw data for scraping,
# for example on many JS-intensive/React-based websites
#
from time import sleep
from selenium import webdriver
from selenium.webdriver import DesiredCapabilities
@fourgates
fourgates / auth.ts
Last active September 27, 2024 02:15
express.js middleware to validate a AWS Cognito / Amplify Token
import { Router } from "express";
import jwt from "jsonwebtoken";
import jwkToPem from "jwk-to-pem";
import * as Axios from 'axios';
interface PublicKeys {
keys: PublicKey[];
}
interface PublicKey {
alg: string;
@cajames
cajames / fargate-efs-cdk-stack.ts
Last active July 26, 2023 08:40
Sample Fargate + EFS CDK Stack. Written up here: https://caj.ms/writing/aws-fargate-with-efs
import cdk = require("@aws-cdk/core");
import { Vpc, Port } from "@aws-cdk/aws-ec2";
import {
Cluster,
ContainerImage,
AwsLogDriver,
FargatePlatformVersion,
NetworkMode,
CfnService,
} from "@aws-cdk/aws-ecs";
@kshailen
kshailen / Connecting_postgress_RDS_from_local_via_bastion.md
Last active July 8, 2024 19:04
Ways to connect to postgress RDS instance from bastion host and from local host

When it comes to databases and AWS VPC, best practice is to place your database in private subnet. By definition, private subnet in AWS is not reachable from the Internet because no Internet gateway is attached to private subnet. This is the way you protect your data. This kind of configuration is good for security but bad for data management.

How can you easily access and manage your secured data?

basic_RDS_bastion_architecture

There are two basic ways to acees it.

  1. Access postgres RDS from bastion host. There are following requirements for this.
@npearce
npearce / install-docker.md
Last active November 11, 2024 13:09
Amazon Linux 2 - install docker & docker-compose using 'sudo amazon-linux-extras' command

UPDATE (March 2020, thanks @ic): I don't know the exact AMI version but yum install docker now works on the latest Amazon Linux 2. The instructions below may still be relevant depending on the vintage AMI you are using.

Amazon changed the install in Linux 2. One no-longer using 'yum' See: https://aws.amazon.com/amazon-linux-2/release-notes/

Docker CE Install

sudo amazon-linux-extras install docker
sudo service docker start
const AWS = require('aws-sdk');
const client = new AWS.SecretsManager({});
// Call the AWS API and return a Promise
function getAwsSecret(secretName) {
return client.getSecretValue({ SecretId: secretName }).promise();
}
// Create a async function to use the Promise
@zaenk
zaenk / ui-router-to-angular-router.md
Last active August 13, 2024 16:07
Migrating AngularJS UI Router to Angular Router

Migrating AngularJS UI Router to Angular Router

This migration path focuses on AngularJS UI Router and Angular Router interopability,

This method not good for everyone! The main characteristics of this path is that the AngularJS and Angular apps does not share the same layout. So new components are always introduced in Angular, old components are rewritten and downgraded for AngularJS. Migration of old modules happens at once, when almost all components are updated. UI Router states cannot be reused in Angular, so every state and listener should bre rewriten to routes and event listeners or strategies for Angular Router.

Prerequisites