Skip to content

alexpulver/useful-stuff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Useful stuff

Development tooling

Web application OIDC authentication flow approach

Client-side design:

  • Store refresh token as HTTP-only secure cookie
  • Store ID token in memory

Client/server flow:

  • Client sends POST request to /auth/refresh API
  • If user didn't authenticate yet, client gets 401 response (there is no refresh token cookie), and redirects to /auth/login API
    • After user authenticates, /auth/login API sets refresh token cookie, and responds with ID token
  • Client calls APIs with ID token in Authorization header
  • APIs authenticate calls using ID token

Related information:

Insert a hard space (works in Markdown)

Source: https://stackoverflow.com/a/53112628/1658138

OS Input method
macOS OPTION+SPACE (ALT+SPACE)
Linux Compose Space Space or AltGr+Space
Windows Alt+0+1+6+0

Some text editors use Ctrl+Shift+Space.

Copy with hidden files to an existing directory

cp -r <source>/. <destination>

Remove all packages installed by pip

pip uninstall -y -r <(pip freeze)

List licenses of Python packages installed with pip

pipx install pip-licenses
pip-licenses --python /usr/bin/python -nv --output-file licenses.txt

Resolve packaging dependency version conflict between black and safety

pip-compile -P black==22.12.0 --upgrade requirements-dev.in

AWS CLI commands

Bash command to perform an operation on multiple AWS CloudFormation stacks:

for stack in $(aws cloudformation describe-stacks --query Stacks[].StackName --output text); do echo $stack; done

List physical resource IDs of specific resource types in an AWS CloudFormation stack:

aws cloudformation list-stack-resources --stack-name STACK_NAME --query 'StackResourceSummaries[?ResourceType==`RESOURCE_TYPE`].PhysicalResourceId'

List services that support AWS PrivateLink VPC endpoints but do not support VPC endpoint policies:

aws ec2 describe-vpc-endpoint-services --query 'ServiceDetails[?VpcEndpointPolicySupported==`false`].{ServiceName:ServiceName, VpcEndpointPolicySupported:VpcEndpointPolicySupported}' --output table

cfn_nag command for cdk.out directory

cfn_nag_scan --output-format txt --input-path cdk.out/ --template-pattern '..*\.template\.json'

PyCharm external documentation for AWS CDK

PyCharm => Preferences => Tools => External documentation => Module Name: aws_cdk => URL/Path Pattern: https://docs.aws.amazon.com/cdk/api/v2/python/{module.name}/{class.name}.html

tree command for AWS CDK project

tree --dirsfirst --matchdirs -I '.mypy_cache|cdk.out|node_modules|__pycache__|.git|.idea'

history without numbers

history -w /dev/stdout

Disable AWS Cloud9 managed temporary credentials

aws cloud9 update-environment  --environment-id $C9_PID --managed-credentials-action DISABLE
rm -vf ${HOME}/.aws/credentials

Archive, tree and diff two projects directories

Archive

git archive --prefix=aws-cdk-project-structure-python/ -o aws-cdk-project-structure-python.zip HEAD

Tree

$ fd | as-tree

Diff two AWS CDK project trees

diff -qrub -x "cdk.out" -x "node_modules" -x ".git" -x "package-lock.json" -x "chalice.out" -x "__pycache__" -x ".idea" -x ".chalice" -x ".DS_Store" -x ".mypy_cache" aws-cdk-sam-chalice/ aws-cdk-project-structure-python/

Replace AWS CDK version in requirements file

sed -i .orig 's/1\.106\.1/1\.114\.0/g' requirements.txt

Make bash case-insensitive for the current user

# If ~/.inputrc doesn't exist yet: First include the original /etc/inputrc
# so it won't get overriden
if [ ! -a ~/.inputrc ]; then echo '$include /etc/inputrc' > ~/.inputrc; fi

# Add shell-option to ~/.inputrc to enable case-insensitive tab completion
echo 'set completion-ignore-case On' >> ~/.inputrc

Google Chrome deep linking

#:~:text=

Stop iTunes from launching when connecting Bluetooth devices

https://github.com/tombonez/noTunes

pyenv plugins

pyenv-virtualenv - manage virtualenvs and conda environments

Pretty print raw JSON string

aws cloudtrail lookup-events --max-results 1 --query 'Events[0].CloudTrailEvent' | jq 'fromjson'

Restart macOS sound driver

sudo pkill coreaudiod

Outlook query for tasks in calendar

category:="Israel Israeli" OR category:="Israel Israelit" start:>=today isrecurring:no

Simple HTTP request handler

python -m SimpleHTTPServer 8000

Change macOS font smoothing

defaults -currentHost write -g AppleFontSmoothing -int [0,1,2,3]

and restart

System design examples

GenAI for programmers

Without GenAI:

  • Coding - 2 hours
  • Debugging - 6 hours

With GenAI:

  • Generate code - 5 minutes
  • Debugging - 24 hours

Linking strategy, mechanism, tool and architecture

Cloud automation tools like AWS CDK and Pulumi allow you to implement application’s architecture and domain logic using the same programming language.

Strategy

  • Context
  • Objective
  • Mechanism
  • Design decision

Mechanism

  • Output => Objective
  • Tool
  • Adoption
  • Inspection
  • Iteration
  • Input

Tool

  • Use case => Output
  • Stories and flows
  • Requirements
  • Architecture

Architecture

  • Application

Application

  • Repositories and pipeline
  • Domain logic

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published