Skip to content

Instantly share code, notes, and snippets.

View nirdosh17's full-sized avatar

Nirdosh Gautam nirdosh17

View GitHub Profile
@nirdosh17
nirdosh17 / import_amplify_env.sh
Created January 3, 2025 17:15
Import amplify environment from cloud to local
#!/bin/bash
set -e
IFS='|'
ENV_NAME="nirdosh"
echo "importing environment '$ENV_NAME'..."
ENV_CONFIGS=$(amplify env get --name $ENV_NAME --json | jq -c '.awscloudformation | {Region, DeploymentBucketName, UnauthRoleName, StackName, StackId, AuthRoleName, UnauthRoleArn, AuthRoleArn}')
@nirdosh17
nirdosh17 / neovim.md
Last active July 26, 2024 15:53
Neovim commands

Leader key

Create subcommands based on this key. e.g. If leader is space key, <space> + sf displays UI to search files.

Editing file contents

Using cursors

up/down/left/right cursor do exactly as they are named. Alternatively, you cna also use:

 k (up) 

VIM 101

  • Create or open file: vi <filename>
  • Normal mode: ESC | Insert mode: iΒ | Command mode: : In normal mode, we can execute Vim commands to search, and transform text. In Insert mode, we can edit the file content.
  • Write and quit:Β :wq
  • Select lines: Press v to start visual selection. Select lines with arrow keys.
  • Copy with y | Paste with pΒ 
  • Delete or cut line: dΒ 
  • Repeat last action:Β . Press dot as many times as you want to repeat the command (e.g. indent)
  • Search: / E.g. /nodePort
@nirdosh17
nirdosh17 / ckad.md
Last active February 28, 2024 04:12
Kubernetes useful commands for CKAD exam
  • Container commands:
    • Always use command: ['sh', '-c', 'command'] for safety.
    • Do not put your command and parameters in a single string: command: ['cowsay Welcome to CKAD!']
      • The whole string 'cowsay Welcome to CKAD!' is considered as a command which will throw error
    • Common bash script with loop:
      # writes output of command to a file
      while true; do date >> /opt/time/time-check.log; sleep 2 ;done
@nirdosh17
nirdosh17 / oss.md
Created February 25, 2024 17:41
A comprehensive list of Open Source Softwares for end-to-end company operations
  • ERP to manage company operations
  • Project Planning
  • Documentation
  • Communication/Messaging/Chat
  • Product/Tech
  • Orchestration (container & more):
@nirdosh17
nirdosh17 / docker-compose.yaml
Last active January 30, 2020 05:01
Start Microsoft SQL server using Docker and connect it with Azure Data Studio
# -------- Usage -----------
# 1. Download this file and save as docker-compose.yaml
# 1. Go to the downloads folder and run command: docker-compose up
# To close the server: Either do 'CTRL + C' OR 'docker-compose down'
# 2. Open Azure data studio
# 3. Create new connection with following settings:
# Connection Type: Microsoft SQL Server
# Server: localhost,1433
# Authentication Type: SQL Login
# User name: SA
@nirdosh17
nirdosh17 / change_screenshot_dir_mac.sh
Created November 19, 2019 15:34
Change Mac's default screenshots storage localtion
defaults write com.apple.screencapture location /Users/nirdoshgautam/Screenshots
@nirdosh17
nirdosh17 / netcat_messaging
Last active September 26, 2019 04:31
Netcat send data to a machine in network
1. Receiver
1.1 Print out receiver IP. We need this IP in step 2.
❯❯❯ ipconfig getifaddr en0
1.2 Run this command in the receiving computer listen to the port 4444 and print out msg:
❯❯❯ nc -vl 4444
If you want to save msg to a file:
❯❯❯ nc -vl 4444 > received_msg.txt
#!/bin/bash
function progress_bar() {
if [ $1 -eq 0 ];then
comp_p=0
else
COMPLETED=$(($COMPLETED+$STEPS))
comp_p=$(jq -n $1/$ITEM_COUNT*100)
comp_p=$(echo ${comp_p%.*})
fi
@nirdosh17
nirdosh17 / cluster_info.sh
Last active September 4, 2019 10:09
Shows ECR image tags which currently deployed to ECS clusters
#! /bin/bash
# -------------------- Usage ---------------------
# Opt 1. Download the script locally and run:
# ❯❯❯ curl -s https://gist.githubusercontent.com/nirdosh17/72f7ed77412002aaa38548831fc688b5/raw -o ~/cluster_info.sh && chmod +x ~/cluster_info.sh && ./cluster_info.sh
# Opt 2. If you don't want to download the script locally, run from URL:
# ❯❯❯ bash <(curl -s https://gist.githubusercontent.com/nirdosh17/72f7ed77412002aaa38548831fc688b5/raw)
# You can also pass the ENV LABEL:
# ❯❯❯ ENV_LABEL=nirdosh bash <(curl -s https://gist.githubusercontent.com/nirdosh17/72f7ed77412002aaa38548831fc688b5/raw)