Skip to content

Instantly share code, notes, and snippets.

View praveenc's full-sized avatar
🎯
Focusing

Praveen Chamarthi praveenc

🎯
Focusing
  • United States
View GitHub Profile
@praveenc
praveenc / .tmux.conf
Created April 4, 2020 16:54
tmux conf
# change prefix command to C-z
set -g prefix C-z
unbind C-b
bind C-z last-window
bind z send-prefix
# setup | and - for window splitting
unbind %
bind | split-window -h
bind - split-window -v
#!/usr/bin/env bash
# Create a new directory and enter it
function mkd() {
mkdir -p "$@" && cd "$_";
}
# Change working directory to the top-most Finder window location
function cdf() { # short for `cdfinder`
cd "$(osascript -e 'tell app "Finder" to POSIX path of (insertion location as alias)')";
@praveenc
praveenc / .git_aliases
Created April 4, 2020 16:52
Git aliases
#cite 'about-alias'
#about-alias 'common git abbreviations'
# Aliases
alias gcl='git clone'
alias ga='git add'
alias gall='git add .'
alias gus='git reset HEAD'
alias gm="git merge"
alias g='git'
@praveenc
praveenc / .docker_aliases
Created April 4, 2020 16:48
Aliases for Docker
alias dkprune="docker image prune"
alias dki="docker images"
alias dkps="docker ps"
alias dkpsa="docker ps -a"
alias dkstop="docker stop"
alias dkrmi="docker rmi"
alias dkexec="docker exec"
alias dkc="docker-compose"
alias dkcu="docker-compose up"
alias dkcd="docker-compose down"
@praveenc
praveenc / assume-role.py
Last active April 3, 2020 19:48
STS assume role using boto3
def assume_role(arn, session_name):
"""aws sts assume-role --role-arn arn:aws:iam::00000000000000:role/example-role --role-session-name example-role"""
client = boto3.client('sts')
account_id = client.get_caller_identity()["Account"]
print(account_id)
response = client.assume_role(RoleArn=arn, RoleSessionName=session_name)
session = Session(aws_access_key_id=response['Credentials']['AccessKeyId'],
@praveenc
praveenc / s3-session-client-boto3.py
Created April 3, 2020 19:42
boto3 create a s3 session client
def setup_s3_client(job_data):
"""Creates an S3 client
Uses the credentials passed in the event by CodePipeline. These
credentials can be used to access the artifact bucket.
:param job_data: The job data structure
:return: An S3 client with the appropriate credentials
"""
@praveenc
praveenc / python_dot_dict.py
Created January 5, 2019 16:55
Python - Access dictionary with dot notation
#!/usr/bin/env python3
class dotdict(dict):
"""dot.notation access to dictionary attributes"""
__getattr__ = dict.get
__setattr__ = dict.__setitem__
__delattr__ = dict.__delitem__
mydict = {'val':'it works'}
nested_dict = {'val':'nested works too'}
mydict = dotdict(mydict)
#!/usr/bin/env python3
#coding=utf-8
# --------------------------------------------------------------------
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
#
@praveenc
praveenc / get-azure-bearertoken.ps1
Last active December 18, 2018 14:34
Following is a sample header for authenticating with Azure. Generate an authentication header, sometimes called a Bearer token, and provide the REST API URI to connect to with any parameters or a Request Body
# Login first with Connect-AzureRmAccount if not using Cloud Shell
$azContext = Get-AzureRmContext
$azProfile = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile
$profileClient = New-Object -TypeName Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient -ArgumentList ($azProfile)
$token = $profileClient.AcquireAccessToken($azContext.Subscription.TenantId)
$authHeader = @{
'Content-Type'='application/json'
'Authorization'='Bearer ' + $token.AccessToken
}
#!/bin/bash
# install dotnet core
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main" > /etc/apt/sources.list.d/dotnetdev.list'
sudo apt-get update
sudo apt-get install -y apt-transport-https jq vim
sudo apt-key adv --keyserver packages.microsoft.com --recv-keys 52E16F86FEE04B979B07E28DB02C46DF417A0893
sudo apt-get install -y dotnet-sdk-2.1.103 --allow-unauthenticated
sudo apt-get install -y dotnet-sharedframework-microsoft.netcore.app-1.1.2 --allow-unauthenticated