Skip to content

Instantly share code, notes, and snippets.

View jiyuhan's full-sized avatar
👋

Thomas Han jiyuhan

👋
  • AWS Fargate
  • Seattle, WA
  • LinkedIn in/t-han
View GitHub Profile
@jiyuhan
jiyuhan / index.js
Created December 28, 2021 00:20 — forked from o-az/index.js
Simple React Context
import React from "react";
import ReactDOM from "react-dom";
// set the defaults
const LanguageContext = React.createContext({
language: "en",
setLanguage: () => {}
});
const LanguageSwitcher = () => {
@jiyuhan
jiyuhan / cachedJwks.ts
Created December 27, 2021 19:34
Caching JWKS
import * as https from 'https';
import { JwksModel, JwksKidToPemMap } from '../models/jwks';
import jwkToPem from 'jwk-to-pem';
import { AWS_CONFIG } from '../variables-config';
export class CachedJwks {
private static jwks: JwksKidToPemMap = new Map<string, string>();
private static invalidTime = 0;
@jiyuhan
jiyuhan / jwtVerifier.ts
Created December 27, 2021 19:26
JWT verifier using JWKS in Cognito
import { decode, verify } from 'jsonwebtoken';
import { Request, Response, NextFunction } from 'express';
import { CachedJwks } from '../common/cached-jwks';
import { UserInformationFromToken } from '../models/api/user/user-metadata';
import HttpStatusCode from 'http-status-typed';
import { AWS_CONFIG } from '../variables-config';
import { UNAUTHORIZED_RESPONSE } from '../models/api/shared/unauthorized-response';
import ProfileLogger from '../common/logger';
import { UserService } from '../services/user-service';
import { getCompanyNameAndSuffix } from '../common/group-naming';
@jiyuhan
jiyuhan / linux-resize-after-cloning.sh
Created July 13, 2021 02:42
Linux filesystem resizing with NVME LVM partitioned - after cloning/duplication
# let partition take all the extra space
$ sudo growpart <disk location: /dev/nvme0n1> <partition num> # i.e. nvme0n1p3 typically means it is on partition 3
# run a lsblk to validate what you see
$ lsblk
# you should see the partition has grown to consume all the leftover space
# then run pvresize to have your physical volume (on that partition)
$ sudo pvresize /dev/nvme0n1p3