Skip to content

Instantly share code, notes, and snippets.

View kamauwashington's full-sized avatar

kamauwashington kamauwashington

View GitHub Profile
@kamauwashington
kamauwashington / react-naming-conventions-simplified.md
Last active April 18, 2024 18:05
React Naming Conventions Simplified

Simple React Naming Conventions (anyone or any team can follow)

This is a list of best practices found not only in catalyst projects, but from years of web articles and personal practices that are easy to remember and implement across small or large React applications.

One of the most common discussions I have seen is which casing to use for what. The goal here is to keep it simple

A general Guideline (TLDR)

  • Pascal Case (MyComponent) for components, Classes, Interfaces
  • Kebab Case (my-component) for directories, non react components, and Function, Class, Interfaces file names
@kamauwashington
kamauwashington / aws-cdk-with-dotenv-and-typescript.md
Last active May 22, 2025 16:16
Using AWS CDK with dotenv and TypeScript (--require module implementation)

Using AWS CDK with dotenv and TypeScript

Note, I prefer the node --require option of loading .env variables over importing or requiring in application code.

TLDR;

  • install dotenv as a development dependency
  • in the cdk.json in the root of the project directory add the following in bold :
    • { "app": "npx ts-node -r dotenv/config --prefer-ts-exts bin/<stack-name>.ts" }

When developing via AWS CDK it is easy to set environment variables on resources as they are being defined to be stored in AWS. However, in some repositories there is a need to set environment variables for the CDK Stack to use.

@kamauwashington
kamauwashington / opensearch-search-request-logging.md
Last active April 14, 2022 17:16
AWS OpenSearch Search Request Logging

AWS OpenSearch Search Request Logging

There may be rules and regulations for logging in your production environment, please consult with your web engineering, or infrastructure equivalent prior to logging in this fashion to prevent unwanted charges and or side-effects.

This one took some time to figure out, and the AWS documentation Monitoring audit logs in Amazon OpenSearch Service did not point directly to how to log inbound REST search requests to OpenSearch to CloudWatch. There wasn't much on the web either in terms of discussions, or questions on the matter, so I hope this helps someone 😃

Steps

@kamauwashington
kamauwashington / luhn.py
Last active March 19, 2022 20:27
Simple Python Luhn / Mod 10 Algorithm, works with v3
import re
def luhn(input : str) -> bool :
if input is None :
return False
# keep it clean and pure to avoid failure, strip all non numeric characters from the input
workingInput : str = re.sub(r"[^\d]","",input)

TypeScript Bits

Preload dotenv, don't require it

TypeScript Bits are small, easily digestible pieces of information to encourage TypeScript/JavaScript best practices. From beginner, to intermediate, to ninja, these bits are for you 😄


Estimated reading time : 2 minutes

Oh my dotenv! If you work with NodeJS at some point you will use and implement dotenv. It loads environment variables from a .env file (configurable name btw), into process.env, following the 12 Factor App methodology of separating environment from code. Pure awesomeness, and makes development configuration loading a breeze mimicking your higher environments.

TypeScript Bits

Avoid using ts-node when performance testing

TypeScript Bits are small, easily digestible pieces of information to encourage TypeScript/JavaScript best practices. From beginner, to intermediate, to ninja, these bits are for you 😄


Estimated reading time : 2 minutes

Often times when performance testing, or comparing resource utilization (ex NodeJS vs Java), I have seen developers load testing (even one off testing) with ts-node. ts-node is an awesome piece of kit, but it is for rapid prototyping, watching, and development only, it is not a production runtime.

TypeScript Bits

Double vs Triple Equals

TypeScript Bits are small, easily digestible pieces of information to encourage TypeScript/JavaScript best practices. From beginner, to intermediate, to ninja, these bits are for you 😄


Estimated reading time : 2 minutes

A very common point of confusion in JS/TS programming is what double equals and triple equals actually do. While this is base JS functionality, the method by how it works is quite simple (maybe) : Type Coercion

TypeScript Bits

The awesome Readonly<T> Utility Type

TypeScript Bits are small, easily digestible pieces of information to encourage TypeScript/JavaScript best practices. From beginner, to intermediate, to ninja, these bits are for you 😄


Estimated reading time : 2 minutes

Lets all be honest, side effects are terrible. They are especially terrible when working with a runtime that doesn't implicitly discern between mutable and immutable pre transpilation or compilation (like JavaScript). I have often found functions during code review where an Array or Object is manipulated in the subroutine returning the input Array or Object. Ideally, functions should remain pure.

TypeScript Bits

Enum Flags ... are ... awesome!

TypeScript Bits are small, easily digestible pieces of information to encourage TypeScript/JavaScript best practices. From beginner, to intermediate, to ninja, these bits are for you 😄


Estimated reading time : 5 minutes

An often overlooked feature of most if not all languages is the concept of Enum Flags. In a nutshell, Enum Flags are an efficient way of storing and representing a collection of boolean values with one value 😎. This applies to all SQL languages, C#, Java, Python, Rust, GoLang, the list goes on, and illustrated here in TypeScript.

TypeScript Bits

Literal Types / Type Guards

TypeScript Bits are small, easily digestible pieces of information to encourage TypeScript/JavaScript best practices. From beginner, to intermediate, to ninja, these bits are for you 😄


Estimated reading time : 2 minutes

When using TypeScript, we often (and hopefully as a manner of practice, always) declare the type of a variable or property. TypeScript allows the possibility of a variable or property to be of one or more types. This means that a variable or property can be either a number, string, or custom type by declaring it like so :