Last active
August 5, 2023 21:19
-
-
Save snigdhasjg/2c19cb8a51784b985b93b7cc26ea236b to your computer and use it in GitHub Desktop.
Mac setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~/.gitconfig | |
# Note: | |
# [Windows users] If you are on windows, please search for the word 'windows' - and fix those lines - they seem to cause some trouble | |
# [General] Since some of the settings are specific to my setup (ie presence of fles), I have marked those lines with comments 'Personal' - you can go ahead and change those to your equivalents or delete them altogether | |
# [General] Since I use 'diff-so-fancy' as the diffing tool, it's absence on your system will cause some errors. If you are able to, I would sincerely urge you to install and use it for a much better experience. If not, please replace all such occurrences back to use 'diff' | |
# Note: Even though this will show up twice in `git config -l` - it will still be overridden based on the order of the includeIf lines below | |
[user] | |
email = snigdhasjg@users.noreply.github.com | |
name = Snigdhajyoti Ghosh | |
[includeIf "gitdir:~/JD/"] | |
path = ~/JD/.gitconfig | |
[alias] | |
# find dangling commits | |
dangling = fsck --no-reflog | |
# edit global git configuration | |
ec = config --global -e | |
# find files/folders with the parameter as part of the name | |
f = "!git ls-files | GREP_OPTIONS=\"--color=auto\" grep -i" | |
# if a local commit exists, then amend it, else create a new commit with the specified message | |
sci = "!sh -c 'git status | GREP_OPTIONS=\"--color=auto\" grep \"is ahead of\"; \ | |
if [ $? -eq 0 ]; then \ | |
echo \"Amending existing commit\"; \ | |
git amq; \ | |
else \ | |
echo \"Creating new commit\"; \ | |
echo $0; \ | |
git ci \"$0\"; \ | |
fi'" | |
what = show -s --pretty='tformat:%h (%s, %ad)' --date=short | |
# show commit info summary (count and name) | |
who = shortlog -s -- | |
# show username/email of the specified author | |
whois = log -i -1 --pretty=format:'%an <%ae>' --author | |
# show all commits in the past week done by the specified author | |
standup = log --since 1.week.ago --author | |
# show git log in colorful graph mode | |
lg = log --color --graph --pretty=format:'%C(yellow)%h%Creset -%C(bold blue)%d%Creset %s %C(green) %an, %cr%Creset' --abbrev-commit | |
l = log --decorate --graph --oneline --abbrev-commit | |
mn = merge --no-commit | |
cn = cherry-pick --no-commit | |
cr = cherry-pick | |
# commit with the following message | |
ci = commit -m | |
co = checkout | |
cl = clone | |
st = status | |
sts = status --short | |
b = branch | |
d = diff | |
dw = diff --word-diff | |
dc = diff --staged | |
dcw = diff --word-diff --staged | |
wipe = !git add -A && git commit -qm 'WIPE SAVEPOINT if needed later, can be resurrected using reflog' && git reset HEAD~1 --hard | |
amend = commit --amend | |
# amend last commit keeping the same commit comment | |
amq = commit --amend --no-edit --quiet | |
# unstage all staged changes | |
unstage = reset HEAD -- | |
diff = diff --word-diff | |
grep = grep -Ii | |
patch = !git --no-pager diff --no-color | |
pend = !sh -c 'git log origin/"$1".."$1"' - | |
fo = fetch --all --tags | |
# print the current branch name | |
br = rev-parse --abbrev-ref HEAD | |
# rebase from corresponding upstream branch | |
upreb = !git rebase upstream/`git br` | |
# prune local copy-of-remote to remove deleted branches | |
rpo = remote prune origin | |
# show incoming change commits without per-file content changes | |
in = log --reverse ..@{u} | |
# show incoming change commits with per-file content changes | |
inp = log -p --reverse ..@{u} | |
# show incoming changes as a single diff (without breakup of commits) | |
inc = !git --no-pager diff ..@{u} | diff-so-fancy | less --tabs=1,5 -RFX | |
# show outgoing change commits | |
out = log --reverse @{u}.. | |
# show outgoing change commits with content changes | |
outp = log -p --reverse @{u}.. | |
g = grep --break --heading --line-number | |
sf = submodule foreach | |
# compress disk-space-usage by deleting dangling commits | |
# Note: Do not use '--all' switch for reflog expire - since that also destroys stashes | |
cc = "!du -sh .git; git remote prune origin; git repack ; git prune-packed; git reflog expire --expire=1.week.ago; git gc --aggressive --prune=now; du -sh .git;" | |
# show the biggest files in the disk (this is not technically specific to git-tracked files) | |
big = "!git rev-list --objects --all | GREP_OPTIONS=\"--color=auto\" grep \"$(git verify-pack -v .git/objects/pack/*.idx | sort -k 3 -n | tail -100 | awk '{print $1}')\"" | |
# delete all local branches which are not present on remote | |
dlb = "!git branch -vv | GREP_OPTIONS= grep -v 'origin/' | awk '{print $1}' | xargs -I {} git branch -D {}; git branch -vv | GREP_OPTIONS= grep ': gone]' | awk '{print $1}' | xargs -I {} git branch -D {}" | |
# check if the specified branch has had a commit in the past 100 days and if so, report | |
# old = "!sh -c '[[ \"`git log $0/$1 --since 100.days -1 | wc -l`\" -eq 0 ]] && echo \"Will need to delete $0/$1\" && git push $0 --delete $1'" | |
old = "!sh -c '[[ \"`git log $0/$1 --since 100.days -1 | wc -l`\" -eq 0 ]] && echo \"Will need to delete $0/$1\"'" | |
# [siu = submodule init update] Runs submodule-initialisation and update after a fresh checkout RECURSIVE! | |
siu = "!git submodule update --init --recursive; git sf \"git siu\"" | |
# push all submodules | |
pushsub = sf "git push" | |
# pull all submodules | |
pullsub = sf "git pull" | |
# show diffs with colored words (red word is deleted, green word is added) | |
dcolor = diff --color-words | |
[init] | |
defaultBranch = main | |
# templatedir = /Users/joe/.git-template | |
[core] | |
pager = diff-so-fancy | less --tabs=4 -RFX | |
# Trying out the competing product called 'delta' installed via 'homebrew' | |
# pager = delta | |
#editor = code --wait | |
editor = vi | |
autocrlf = input | |
excludesfile = ~/.gitignore | |
commentchar = * | |
# hooksPath = /dev/null | |
[branch] | |
autosetupmerge = true | |
autosetuprebase = always | |
[color] | |
ui = true | |
diff = auto | |
status = auto | |
branch = auto | |
interactive = auto | |
pager = true | |
# Trying out the competing product called 'delta' installed via 'homebrew' | |
# [delta] | |
# # plus-color = "#012800" | |
# # minus-color = "#340001" | |
# # syntax-theme = Monokai Extended | |
# line-numbers = true | |
# features = unobtrusive-line-numbers decorations | |
# # whitespace-error-style = 22 reverse | |
# [delta "unobtrusive-line-numbers"] | |
# line-numbers = true | |
# line-numbers-minus-style = "#444444" | |
# line-numbers-zero-style = "#444444" | |
# line-numbers-plus-style = "#444444" | |
# line-numbers-left-format = "{nm:>4}┊" | |
# line-numbers-right-format = "{np:>4}│" | |
# line-numbers-left-style = blue | |
# line-numbers-right-style = blue | |
# [delta "decorations"] | |
# commit-decoration-style = bold yellow box ul | |
# file-style = bold yellow ul | |
# file-decoration-style = none | |
# hunk-header-decoration-style = yellow box | |
[diff] | |
compactionHeuristic = true | |
[fetch] | |
prune = true | |
[filter "lfs"] | |
required = true | |
clean = git-lfs clean -- %f | |
smudge = git-lfs smudge -- %f | |
process = git-lfs filter-process | |
[gc] | |
pruneexpire = now | |
[grep] | |
extendedRegexp = true | |
lineNumber = true | |
fullName = true | |
[help] | |
autocorrect = 1 | |
[merge] | |
defaultToUpstream = true | |
ff = only | |
renamelimit = 15000 | |
# conflictstyle = diff3 | |
[pager] | |
# log = diff-so-fancy | less --tabs=1,5 -RFX | |
show = diff-so-fancy | less --tabs=1,5 -RFX # windows | |
# Note: The '--pattern' switch sets some pre-search terms, but also scrolls to fill the whole console for single line change - which I dont like. | |
diff = diff-so-fancy | less --tabs=1,5 -RFX # --pattern '^(Date|added|deleted|modified): ' # windows | |
[interactive] | |
# diffFilter = (echo && diff-so-fancy) | |
# Trying out the competing product called 'delta' installed via 'homebrew' | |
# diffFilter = delta --color-only | |
[pack] | |
threads = 4 | |
[push] | |
default = tracking | |
followTags = true | |
[pull] | |
rebase = true | |
autoStash = true | |
[rebase] | |
# autoSquash = true | |
autoStash = true | |
[stash] | |
untracked = true | |
[status] | |
showUntrackedFiles = all | |
# Convert to 'true' in case you work with submodules - but, will have visible perf slowdown on windows | |
submodulesummary = false | |
[submodule] | |
fetchJobs = 4 | |
[tag] | |
sort = version:refname | |
[transfer] | |
fsckobjects = false | |
[color "diff"] | |
meta = yellow | |
frag = magenta bold | |
commit = yellow bold | |
old = red bold | |
new = green bold | |
whitespace = red reverse | |
[diff-so-fancy] | |
markEmptyLines = false | |
# changeHunkIndicators = false | |
# stripLeadingSymbols = false | |
# useUnicodeRuler = false | |
[rerere] | |
enabled = true | |
autoupdate = true | |
[advice] | |
detachedHead = true | |
[gui] | |
pruneduringfetch = true | |
matchtrackingbranch = true | |
warndetachedcommit = true | |
[checkout] | |
defaultRemote = origin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" syntax on | |
" set number | |
" set termguicolors | |
" let g:gruvbox_italic=1 | |
" let g:gruvbox_contrast_dark='high' | |
" colorscheme gruvbox | |
" ~/.vimrc | |
set nocompatible " be iMproved, required | |
" filetype off " required | |
" mouse navigation | |
set mouse=a | |
" highlighting | |
" set relativenumber | |
set number | |
set ruler | |
syntax on | |
set background=dark | |
set cursorline | |
set incsearch | |
set hlsearch | |
set ignorecase | |
set smartcase | |
set showmatch | |
:highlight search guifg=yellow guibg=darkred | |
" tabbing | |
set expandtab | |
set smarttab | |
set smartindent | |
set shiftwidth=2 | |
set tabstop=2 | |
set softtabstop=2 | |
" have command-line completion <Tab> (for filenames, help topics, option | |
" names) first list the available options and complete the longest common part, | |
" then have further <Tab>s cycle through the possibilities: | |
set wildmode=list:longest,full | |
" folding settings | |
set foldmethod=indent | |
set foldnestmax=10 | |
set nofoldenable | |
set foldlevel=1 | |
" All of your Plugins must be added before the following line | |
filetype plugin indent on " required | |
let g:solarized_termcolors=256 | |
" Strip trailing whitespace | |
function! <SID>StripTrailingWhitespaces() | |
" Preparation: save last search, and cursor position. | |
let _s=@/ | |
let l = line(".") | |
let c = col(".") | |
" Do the business: | |
%s/\s\+$//e | |
" Clean up: restore previous search history, and cursor position | |
let @/=_s | |
call cursor(l, c) | |
endfunction | |
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc. | |
# Initialization code that may require console input (password prompts, [y/n] | |
# confirmations, etc.) must go above this block; everything else may go below. | |
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then | |
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" | |
fi | |
# If you come from bash you might have to change your $PATH. | |
# export PATH=$HOME/bin:/usr/local/bin:$PATH | |
# Path to your oh-my-zsh installation. | |
export ZSH="$HOME/.oh-my-zsh" | |
# Set name of the theme to load --- if set to "random", it will | |
# load a random theme each time oh-my-zsh is loaded, in which case, | |
# to know which specific one was loaded, run: echo $RANDOM_THEME | |
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes | |
# ZSH_THEME="powerlevel10k/powerlevel10k" | |
# Set list of themes to pick from when loading at random | |
# Setting this variable when ZSH_THEME=random will cause zsh to load | |
# a theme from this variable instead of looking in $ZSH/themes/ | |
# If set to an empty array, this variable will have no effect. | |
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" ) | |
# Uncomment the following line to use case-sensitive completion. | |
# CASE_SENSITIVE="true" | |
# Uncomment the following line to use hyphen-insensitive completion. | |
# Case-sensitive completion must be off. _ and - will be interchangeable. | |
# HYPHEN_INSENSITIVE="true" | |
# Uncomment one of the following lines to change the auto-update behavior | |
# zstyle ':omz:update' mode disabled # disable automatic updates | |
# zstyle ':omz:update' mode auto # update automatically without asking | |
# zstyle ':omz:update' mode reminder # just remind me to update when it's time | |
# Uncomment the following line to change how often to auto-update (in days). | |
# zstyle ':omz:update' frequency 13 | |
# Uncomment the following line if pasting URLs and other text is messed up. | |
# DISABLE_MAGIC_FUNCTIONS="true" | |
# Uncomment the following line to disable colors in ls. | |
# DISABLE_LS_COLORS="true" | |
# Uncomment the following line to disable auto-setting terminal title. | |
# DISABLE_AUTO_TITLE="true" | |
# Uncomment the following line to enable command auto-correction. | |
# ENABLE_CORRECTION="true" | |
# Uncomment the following line to display red dots whilst waiting for completion. | |
# You can also set it to another string to have that shown instead of the default red dots. | |
# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f" | |
# Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765) | |
# COMPLETION_WAITING_DOTS="true" | |
# Uncomment the following line if you want to disable marking untracked files | |
# under VCS as dirty. This makes repository status check for large repositories | |
# much, much faster. | |
# DISABLE_UNTRACKED_FILES_DIRTY="true" | |
# Uncomment the following line if you want to change the command execution time | |
# stamp shown in the history command output. | |
# You can set one of the optional three formats: | |
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" | |
# or set a custom format using the strftime function format specifications, | |
# see 'man strftime' for details. | |
# HIST_STAMPS="mm/dd/yyyy" | |
# Would you like to use another custom folder than $ZSH/custom? | |
# ZSH_CUSTOM=/path/to/new-custom-folder | |
## Homebrew setup | |
eval "$(/opt/homebrew/bin/brew shellenv)" | |
LC_CTYPE=en_US.UTF-8 | |
LC_ALL=en_US.UTF-8 | |
# Which plugins would you like to load? | |
# Standard plugins can be found in $ZSH/plugins/ | |
# Custom plugins may be added to $ZSH_CUSTOM/plugins/ | |
# Example format: plugins=(rails git textmate ruby lighthouse) | |
# Add wisely, as too many plugins slow down shell startup. | |
plugins=( | |
git | |
gradle | |
mvn | |
terraform | |
zsh-syntax-highlighting | |
zsh-autosuggestions | |
zsh-docker-aliases | |
) | |
source $ZSH/oh-my-zsh.sh | |
# User configuration | |
# export MANPATH="/usr/local/man:$MANPATH" | |
# You may need to manually set your language environment | |
# export LANG=en_US.UTF-8 | |
# Preferred editor for local and remote sessions | |
# if [[ -n $SSH_CONNECTION ]]; then | |
# export EDITOR='vim' | |
# else | |
# export EDITOR='mvim' | |
# fi | |
# Compilation flags | |
# export ARCHFLAGS="-arch x86_64" | |
# Set personal aliases, overriding those provided by oh-my-zsh libs, | |
# plugins, and themes. Aliases can be placed here, though oh-my-zsh | |
# users are encouraged to define aliases within the ZSH_CUSTOM folder. | |
# For a full list of active aliases, run `alias`. | |
# | |
# Example aliases | |
# alias zshconfig="mate ~/.zshrc" | |
# alias ohmyzsh="mate ~/.oh-my-zsh" | |
## p10k setup | |
source /opt/homebrew/opt/powerlevel10k/powerlevel10k.zsh-theme | |
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh. | |
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh | |
## Auto jump setup | |
[ -f /opt/homebrew/etc/profile.d/autojump.sh ] && . /opt/homebrew/etc/profile.d/autojump.sh | |
## aws cli setup | |
complete -C aws_completer aws | |
alias awsp='source _awsp' | |
## anaconda python setup | |
__conda_setup="$('/opt/homebrew/anaconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)" | |
if [ $? -eq 0 ]; then | |
eval "$__conda_setup" | |
else | |
if [ -f "/opt/homebrew/anaconda3/etc/profile.d/conda.sh" ]; then | |
. "/opt/homebrew/anaconda3/etc/profile.d/conda.sh" | |
else | |
export PATH="/opt/homebrew/anaconda3/bin:$PATH" | |
fi | |
fi | |
unset __conda_setup | |
## .env setup | |
eval "$(direnv hook zsh)" | |
export DIRENV_LOG_FORMAT= | |
## Custom script so dont have to modify .zshrc | |
[[ -f ~/.zshrc.custom ]] && source ~/.zshrc.custom | |
## sdk man setup | |
#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!! | |
export SDKMAN_DIR="$HOME/.sdkman" | |
[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# vim:syntax=zsh | |
# vim:filetype=zsh | |
gall() { | |
find . -type d -depth 1 -exec git --git-dir={}/.git --work-tree={} ${*} \; | |
} | |
fingerprint() { | |
COUNT=`grep pam_tid /etc/pam.d/sudo | wc -l` | |
if [[ $COUNT -gt 0 ]]; then | |
echo "ALREADY PRESENT - Not adding again!!!" | |
else | |
echo "INCLUDING NEW LINE!!!" | |
sudo sed -i '' '2i\ | |
auth sufficient pam_tid.so\ | |
' /etc/pam.d/sudo | |
fi | |
} | |
alias cst='colima start -c 6 -m 10 --dns 1.1.1.1 --dns 8.8.8.8 && echo "Please approve for creating softlink to /var/run/docker.sock" && sudo ln -sf ${HOME}/.colima/default/docker.sock /var/run/docker.sock' | |
alias cso='colima stop' | |
export TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE='/var/run/docker.sock' | |
export DOCKER_HOST="unix://${HOME}/.colima/default/docker.sock" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/opt/homebrew/anaconda3/envs/clean-env/bin/python | |
""" | |
Refer: | |
- The docs: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_enable-console-custom-url.html | |
Usage: | |
- Save this script somewhere on your path (e.g. `vi /usr/local/bin/aws-console && chmod +x /usr/local/bin/aws-console`) | |
- Make AWS credentials available in one of the usual places where boto3 can find them (~/.aws/credentials, env var, etc.) | |
- Execute the script: `aws-console --profile my-profile` | |
- :tada: Your browser opens, and you are signed in into the AWS console | |
""" | |
import argparse | |
import datetime | |
import json | |
import os | |
import webbrowser | |
from os import path | |
from urllib import parse, request | |
import botocore.credentials | |
try: | |
import boto3 | |
from botocore.exceptions import ProfileNotFound | |
except ImportError: | |
print('Install boto3 by running `python3 -m pip install boto3`') | |
exit() | |
def arg_parser(): | |
parser = argparse.ArgumentParser( | |
description='Open the AWS console in your web browser, using your AWS CLI credentials') | |
parser.add_argument('--profile', | |
default=os.getenv("AWS_PROFILE", default="joe-admin-role"), | |
help='The AWS profile to create the pre-signed URL with') | |
parser.add_argument('--stdout', | |
action='store_true', | |
help='don\'t open the web browser, but echo the signin URL to stdout') | |
return parser | |
def json_encoder(obj): | |
"""JSON encoder that formats datetime as ISO8601 format.""" | |
if isinstance(obj, datetime.datetime): | |
return obj.isoformat() | |
else: | |
return obj | |
class JSONFileCache(object): | |
"""JSON file cache. | |
This provides a dict like interface that stores JSON serializable | |
objects. | |
The objects are serialized to JSON and stored in a file. These | |
values can be retrieved at a later time. | |
""" | |
CACHE_DIR = path.expanduser(path.join('~', '.aws', 'aws-console', 'cache')) | |
def __init__(self, working_dir=CACHE_DIR): | |
self._working_dir = working_dir | |
def __contains__(self, cache_key): | |
actual_key = self._convert_cache_key(cache_key) | |
return path.isfile(actual_key) | |
def __getitem__(self, cache_key): | |
"""Retrieve value from a cache key.""" | |
actual_key = self._convert_cache_key(cache_key) | |
try: | |
with open(actual_key) as f: | |
return json.load(f) | |
except (OSError, ValueError, IOError): | |
raise KeyError(cache_key) | |
def __setitem__(self, cache_key, value): | |
full_key = self._convert_cache_key(cache_key) | |
try: | |
file_content = json.dumps(value, default=json_encoder) | |
except (TypeError, ValueError): | |
raise ValueError("Value cannot be cached, must be " | |
"JSON serializable: %s" % value) | |
if not path.isdir(self._working_dir): | |
os.makedirs(self._working_dir) | |
with os.fdopen(os.open(full_key, | |
os.O_WRONLY | os.O_CREAT, 0o600), 'w') as f: | |
f.truncate() | |
f.write(file_content) | |
def _convert_cache_key(self, cache_key): | |
full_path = path.join(self._working_dir, cache_key + '.json') | |
return full_path | |
def aws_credentials(profile_name): | |
session = boto3.Session(profile_name=profile_name) | |
# Setting up a custom cache implementation like aws cli | |
cred_chain = session.session.get_component('credential_provider') | |
provider = cred_chain.get_provider('assume-role') | |
provider.cache = JSONFileCache() | |
creds = session.get_credentials() | |
if creds.token is None: | |
credentials = session.client('sts').get_session_token()['Credentials'] | |
creds = botocore.credentials.Credentials(credentials['AccessKeyId'], credentials['SecretAccessKey'], credentials['SessionToken']) | |
return creds, session.region_name | |
def aws_signin_token(access_key, secret_key, token) -> str: | |
url_credentials = dict(sessionId=access_key, sessionKey=secret_key, sessionToken=token) | |
credentials_encoded = parse.quote_plus(json.dumps(url_credentials)) | |
request_url = 'https://signin.aws.amazon.com/federation' \ | |
'?Action=getSigninToken' \ | |
f'&Session={credentials_encoded}' | |
with request.urlopen(request_url) as response: | |
if not response.status == 200: | |
raise Exception("Failed to get federation token") | |
return json.loads(response.read())["SigninToken"] | |
def aws_login_url(access_key, secret_key, token, region_name) -> str: | |
destination_url_encoded = parse.quote_plus("https://{}.console.aws.amazon.com/".format(region_name)) | |
signin_token_encoded = parse.quote_plus(aws_signin_token(access_key, secret_key, token)) | |
return 'https://us-east-1.signin.aws.amazon.com/federation' \ | |
'?Action=login' \ | |
'&Issuer=awscli' \ | |
f'&Destination={destination_url_encoded}' \ | |
f'&SigninToken={signin_token_encoded}' | |
def open_console(profile_name, echo_to_stdout): | |
creds, region_name = aws_credentials(profile_name) | |
login_request_url = aws_login_url(creds.access_key, creds.secret_key, creds.token, region_name) | |
with_logout_request_url = 'https://us-east-1.signin.aws.amazon.com/oauth' \ | |
'?Action=logout' \ | |
f'&redirect_uri={parse.quote_plus(login_request_url)}' | |
if echo_to_stdout: | |
print(with_logout_request_url) | |
else: | |
webbrowser.open(with_logout_request_url) | |
if __name__ == '__main__': | |
args = arg_parser().parse_args() | |
open_console(args.profile, args.stdout) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tap "homebrew/bundle" | |
tap "homebrew/cask" | |
tap "homebrew/core" | |
tap "romkatv/powerlevel10k" | |
tap "turbot/tap" | |
brew "zstd" | |
brew "jpeg-xl" | |
brew "python@3.11" | |
brew "autojump" | |
brew "docutils" | |
brew "awscli" | |
brew "bat" | |
brew "glib" | |
brew "libssh" | |
brew "qemu" | |
brew "lima" | |
brew "colima" | |
brew "diff-so-fancy" | |
brew "direnv" | |
brew "docker" | |
brew "docker-buildx" | |
brew "docker-compose" | |
brew "docker-credential-helper" | |
brew "gh" | |
brew "ghostscript" | |
brew "go" | |
brew "htop" | |
brew "jq" | |
brew "k9s" | |
brew "kompose" | |
brew "kubernetes-cli" | |
brew "libheif" | |
brew "nmap" | |
brew "node" | |
brew "osv-scanner" | |
brew "protobuf" | |
brew "ripgrep" | |
brew "saml2aws" | |
brew "telnet" | |
brew "terraform" | |
brew "tig" | |
brew "tldr" | |
brew "watch" | |
brew "romkatv/powerlevel10k/powerlevel10k" | |
cask "anaconda" | |
cask "brave-browser" | |
cask "dbeaver-community" | |
cask "dropbox" | |
cask "ferdium" | |
cask "flycut" | |
cask "google-chrome" | |
cask "intellij-idea" | |
cask "iterm2" | |
cask "keepassxc" | |
cask "keybase" | |
cask "logitech-g-hub" | |
cask "microsoft-remote-desktop" | |
cask "openvpn-connect" | |
cask "postman" | |
cask "session-manager-plugin" | |
cask "visual-studio-code" | |
cask "zoom" | |
vscode "GitHub.copilot" | |
vscode "github.vscode-github-actions" | |
vscode "k--kato.intellij-idea-keybindings" | |
vscode "ms-azuretools.vscode-docker" | |
vscode "ms-python.python" | |
vscode "ms-python.vscode-pylance" | |
vscode "ms-toolsai.jupyter" | |
vscode "ms-toolsai.jupyter-keymap" | |
vscode "ms-toolsai.jupyter-renderers" | |
vscode "ms-toolsai.vscode-jupyter-cell-tags" | |
vscode "ms-toolsai.vscode-jupyter-slideshow" | |
vscode "redhat.java" | |
vscode "scala-lang.scala" | |
vscode "VisualStudioExptTeam.intellicode-api-usage-examples" | |
vscode "VisualStudioExptTeam.vscodeintellicode" | |
vscode "vscjava.vscode-gradle" | |
vscode "vscjava.vscode-java-debug" | |
vscode "vscjava.vscode-java-dependency" | |
vscode "vscjava.vscode-java-pack" | |
vscode "vscjava.vscode-java-test" | |
vscode "vscjava.vscode-maven" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/opt/homebrew/anaconda3/envs/clean-env/bin/python | |
from random import randint | |
from tkinter import * | |
def database(): | |
return { | |
"BOY": { | |
"height": [[49.8842, 1.8931], | |
[54.7244, 1.9465], | |
[58.4249, 2.0005], | |
[61.4292, 2.0444], | |
[63.886, 2.0808], | |
[65.9026, 2.1115], | |
[67.6236, 2.1403], | |
[69.1645, 2.1711], | |
[70.5994, 2.2055], | |
[71.9687, 2.2433], | |
[73.2812, 2.2849], | |
[74.5388, 2.3293], | |
[75.7488, 2.3762], | |
[76.9186, 2.426], | |
[78.0497, 2.4773], | |
[79.1458, 2.5303], | |
[80.2113, 2.5844], | |
[81.2487, 2.6406], | |
[82.2587, 2.6973], | |
[83.2418, 2.7553], | |
[84.1996, 2.814], | |
[85.1348, 2.8742], | |
[86.0477, 2.9342], | |
[86.941, 2.9951], | |
[87.8161, 3.0551], | |
[87.972, 3.116], | |
[88.8065, 3.1757], | |
[89.6197, 3.2353], | |
[90.412, 3.2928], | |
[91.1828, 3.3501], | |
[91.9327, 3.4052], | |
[92.6631, 3.4591], | |
[93.3753, 3.5118], | |
[94.0711, 3.5625], | |
[94.7532, 3.612], | |
[95.4236, 3.6604], | |
[96.0835, 3.7069], | |
[96.7337, 3.7523], | |
[97.3749, 3.7976], | |
[98.0073, 3.8409], | |
[98.631, 3.8831], | |
[99.2459, 3.9242], | |
[99.8515, 3.9651], | |
[100.4485, 4.0039], | |
[101.0374, 4.0435], | |
[101.6186, 4.081], | |
[102.1933, 4.1194], | |
[102.7625, 4.1567], | |
[103.3273, 4.1941], | |
[103.8886, 4.2314], | |
[104.4473, 4.2677], | |
[105.0041, 4.3052], | |
[105.5596, 4.3417], | |
[106.1138, 4.3783], | |
[106.6668, 4.4149], | |
[107.2188, 4.4517], | |
[107.7697, 4.4886], | |
[108.3198, 4.5245], | |
[108.8689, 4.5616], | |
[109.417, 4.5977], | |
[109.9638, 4.6339]], | |
"weight": [[3.3464, 0.14602], | |
[4.4709, 0.13395], | |
[5.5675, 0.12385], | |
[6.3762, 0.11727], | |
[7.0023, 0.11316], | |
[7.5105, 0.1108], | |
[7.934, 0.10958], | |
[8.297, 0.10902], | |
[8.6151, 0.10882], | |
[8.9014, 0.10881], | |
[9.1649, 0.10891], | |
[9.4122, 0.10906], | |
[9.6479, 0.10925], | |
[9.8749, 0.10949], | |
[10.0953, 0.10976], | |
[10.3108, 0.11007], | |
[10.5228, 0.11041], | |
[10.7319, 0.11079], | |
[10.9385, 0.11119], | |
[11.143, 0.11164], | |
[11.3462, 0.11211], | |
[11.5486, 0.11261], | |
[11.7504, 0.11314], | |
[11.9514, 0.11369], | |
[12.1515, 0.11426], | |
[12.3502, 0.11485], | |
[12.5466, 0.11544], | |
[12.7401, 0.11604], | |
[12.9303, 0.11664], | |
[13.1169, 0.11723], | |
[13.3, 0.11781], | |
[13.4798, 0.11839], | |
[13.6567, 0.11896], | |
[13.8309, 0.11953], | |
[14.0031, 0.12008], | |
[14.1736, 0.12062], | |
[14.3429, 0.12116], | |
[14.5113, 0.12168], | |
[14.6791, 0.1222], | |
[14.8466, 0.12271], | |
[15.014, 0.12322], | |
[15.1813, 0.12373], | |
[15.3486, 0.12425], | |
[15.5158, 0.12478], | |
[15.6828, 0.12531], | |
[15.8497, 0.12586], | |
[16.0163, 0.12643], | |
[16.1827, 0.127], | |
[16.3489, 0.12759], | |
[16.515, 0.12819], | |
[16.6811, 0.1288], | |
[16.8471, 0.12943], | |
[17.0132, 0.13005], | |
[17.1792, 0.13069], | |
[17.3452, 0.13133], | |
[17.5111, 0.13197], | |
[17.6768, 0.13261], | |
[17.8422, 0.13325], | |
[18.0073, 0.13389], | |
[18.1722, 0.13453], | |
[18.3366, 0.13517]] | |
}, | |
"GIRL": { | |
"height": [[49.1477, 1.8627], | |
[53.6872, 1.9542], | |
[57.0673, 2.0362], | |
[59.8029, 2.1051], | |
[62.0899, 2.1645], | |
[64.0301, 2.2174], | |
[65.7311, 2.2664], | |
[67.2873, 2.3154], | |
[68.7498, 2.365], | |
[70.1435, 2.4157], | |
[71.4818, 2.4676], | |
[72.771, 2.5208], | |
[74.015, 2.575], | |
[75.2176, 2.6296], | |
[76.3817, 2.6841], | |
[77.5099, 2.7392], | |
[78.6055, 2.7944], | |
[79.671, 2.849], | |
[80.7079, 2.9039], | |
[81.7182, 2.9582], | |
[82.7036, 3.0129], | |
[83.6654, 3.0672], | |
[84.604, 3.1202], | |
[85.5202, 3.1737], | |
[86.4153, 3.2267], | |
[86.5904, 3.2783], | |
[87.4462, 3.33], | |
[88.283, 3.3812], | |
[89.1004, 3.4313], | |
[89.8991, 3.4809], | |
[90.6797, 3.5302], | |
[91.443, 3.5782], | |
[92.1906, 3.6259], | |
[92.9239, 3.6724], | |
[93.6444, 3.7186], | |
[94.3533, 3.7638], | |
[95.0515, 3.8078], | |
[95.7399, 3.8526], | |
[96.4187, 3.8963], | |
[97.0885, 3.9389], | |
[97.7493, 3.9813], | |
[98.4015, 4.0236], | |
[99.0448, 4.0658], | |
[99.6795, 4.1068], | |
[100.3058, 4.1476], | |
[100.9238, 4.1883], | |
[101.5337, 4.2279], | |
[102.136, 4.2683], | |
[102.7312, 4.3075], | |
[103.3197, 4.3456], | |
[103.9021, 4.3847], | |
[104.4786, 4.4226], | |
[105.0494, 4.4604], | |
[105.6148, 4.4981], | |
[106.1748, 4.5358], | |
[106.7295, 4.5734], | |
[107.2788, 4.6108], | |
[107.8227, 4.6472], | |
[108.3613, 4.6834], | |
[108.8948, 4.7195], | |
[109.4233, 4.7566]], | |
"weight": [[3.2322, 0.14171], | |
[4.1873, 0.13724], | |
[5.1282, 0.13], | |
[5.8458, 0.12619], | |
[6.4237, 0.12402], | |
[6.8985, 0.12274], | |
[7.297, 0.12204], | |
[7.6422, 0.12178], | |
[7.9487, 0.12181], | |
[8.2254, 0.12199], | |
[8.48, 0.12223], | |
[8.7192, 0.12247], | |
[8.9481, 0.12268], | |
[9.1699, 0.12283], | |
[9.387, 0.12294], | |
[9.6008, 0.12299], | |
[9.8124, 0.12303], | |
[10.0226, 0.12306], | |
[10.2315, 0.12309], | |
[10.4393, 0.12315], | |
[10.6464, 0.12323], | |
[10.8534, 0.12335], | |
[11.0608, 0.1235], | |
[11.2688, 0.12369], | |
[11.4775, 0.1239], | |
[11.6864, 0.12414], | |
[11.8947, 0.12441], | |
[12.1015, 0.12472], | |
[12.3059, 0.12506], | |
[12.5073, 0.12545], | |
[12.7055, 0.12587], | |
[12.9006, 0.12633], | |
[13.093, 0.12683], | |
[13.2837, 0.12737], | |
[13.4731, 0.12794], | |
[13.6618, 0.12855], | |
[13.8503, 0.12919], | |
[14.0385, 0.12988], | |
[14.2265, 0.13059], | |
[14.414, 0.13135], | |
[14.601, 0.13213], | |
[14.7873, 0.13293], | |
[14.9727, 0.13376], | |
[15.1573, 0.1346], | |
[15.341, 0.13545], | |
[15.524, 0.1363], | |
[15.7064, 0.13716], | |
[15.8882, 0.138], | |
[16.0697, 0.13884], | |
[16.2511, 0.13968], | |
[16.4322, 0.14051], | |
[16.6133, 0.14132], | |
[16.7942, 0.14213], | |
[16.9748, 0.14293], | |
[17.1551, 0.14371], | |
[17.3347, 0.14448], | |
[17.5136, 0.14525], | |
[17.6916, 0.146], | |
[17.8686, 0.14675], | |
[18.0445, 0.14748], | |
[18.2193, 0.14821]] | |
} | |
} | |
def take_input(): | |
data = database() | |
gui = Tk() | |
gui.geometry("600x300") | |
gui.title("WHO ideal height and weight finder") | |
gender_label = Label(gui, text="Gender: ", width=20, font=("bold", 15)) | |
gender_label.grid(row=0, columnspan=5, ipadx=2) | |
gender = StringVar(gui, "BOY") | |
gender_menu = OptionMenu(gui, gender, "BOY", "GIRL") | |
gender_menu.grid(row=0, column=7) | |
age = IntVar(gui) | |
age_year = IntVar(gui) | |
age_month = IntVar(gui) | |
random_height = DoubleVar(gui) | |
random_weight = DoubleVar(gui) | |
def clear(): | |
age.set("") | |
age_year.set("") | |
age_month.set("") | |
random_height.set("") | |
random_weight.set("") | |
clear() | |
age_label = Label(gui, text="Age: ", width=20, font=("bold", 15)) | |
age_label.grid(row=1, columnspan=5, ipadx=2) | |
age_field = Message(gui, textvariable=age) | |
age_field.grid(row=1, column=7) | |
age_year_label = Label(gui, text="Year: ", width=20, font=("bold", 15)) | |
age_year_label.grid(row=2, columnspan=5, ipadx=2) | |
age_year_entry = Entry(gui, textvariable=age_year) | |
age_year_entry.grid(row=2, column=7) | |
age_month_label = Label(gui, text="Month: ", width=20, font=("bold", 15)) | |
age_month_label.grid(row=3, columnspan=5, ipadx=2) | |
age_month_entry = Entry(gui, textvariable=age_month) | |
age_month_entry.grid(row=3, column=7) | |
def random(): | |
age.set(age_year.get() * 12 + age_month.get()) | |
gender_data = data.get(gender.get()) | |
height_mean = gender_data.get("height")[age.get()][0] | |
height_std = gender_data.get("height")[age.get()][1] | |
random_height.set(round(height_mean + (randint(-100, 100) * height_std / 100), 2)) | |
weight_mean = gender_data.get("weight")[age.get()][0] | |
weight_std = gender_data.get("weight")[age.get()][1] | |
random_weight.set(round(weight_mean + (randint(-100, 100) * weight_std / 100), 2)) | |
random_button = Button(gui, text='Random', fg='black', bg='red', command=random, height=1, width=7) | |
random_button.grid(row=4, column=7) | |
clear_button = Button(gui, text='(X)', fg='black', bg='red', command=clear, height=1, width=7) | |
clear_button.grid(row=4, column=3) | |
random_height_label = Label(gui, text="Height: ", width=20, font=("bold", 15)) | |
random_height_label.grid(row=6, columnspan=4, ipadx=2) | |
random_height_field = Message(gui, textvariable=random_height) | |
random_height_field.grid(row=6, column=6, columnspan=2) | |
random_weight_label = Label(gui, text="Weight: ", width=20, font=("bold", 15)) | |
random_weight_label.grid(row=7, columnspan=4, ipadx=2) | |
random_weight_field = Message(gui, textvariable=random_weight) | |
random_weight_field.grid(row=7, column=6, columnspan=2) | |
mainloop() | |
if __name__ == '__main__': | |
take_input() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment