Skip to content

Instantly share code, notes, and snippets.

View akhan4u's full-sized avatar
☘️
Gratitude

Amaan Khan akhan4u

☘️
Gratitude
View GitHub Profile
@akhan4u
akhan4u / expr_syntax.md
Created February 9, 2023 14:57
Expr Syntax and bash equivalent
EXPR Syntax Bash Equiv Meaning
SEE NOTE 1 "${ARG1:-$ARG2}" ARG1 if it is neither null nor 0, otherwise ARG2
ARG1 & ARG2
@akhan4u
akhan4u / kubectl_export.sh
Last active December 10, 2022 05:31
Export Kubernetes namespace to Disk 💾
# Prerequisites:
# [GNU Parallel](https://www.gnu.org/software/parallel/)
# [kubectl-neat](https://github.com/itaysk/kubectl-neat)
# [mikefarah/yq](https://github.com/mikefarah/yq)
#
# Usage:
# - Copy and paste the below into your active shell session. Alternatively, add to your shell initialization scripts.
# - kubectl_export <namespace>
# The folder structure will be created: <namespace>/<kind>/<resource_name>.yaml
#
@akhan4u
akhan4u / LearnGoIn5mins.md
Created August 11, 2022 08:33 — forked from prologic/LearnGoIn5mins.md
Learn Go in ~5mins
@akhan4u
akhan4u / myscript.sh
Created June 28, 2022 10:08
Shell scripting for beginners
#! /bin/bash
# ECHO COMMAND
# echo Hello World!
# VARIABLES
# Uppercase by convention
# Letters, numbers, underscores
NAME="Bob"
# echo "My name is $NAME"
@akhan4u
akhan4u / cloudformation pre-commit
Created October 20, 2020 13:29
Git pre-commit hook for linting and validating Cloudformation templates.
#!/bin/sh
# Only Run If Any Cloudformation Template Is Modified And Checks Linting Of The Template
#------------------
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'
#------------------
FILES=$(git diff --cached --name-only --diff-filter=ACMR "*.yml" "*.yaml" | sed 's| |\\ |g')
@akhan4u
akhan4u / learning_linux.md
Last active May 6, 2024 01:02
Useful websites for Learning Linux
  1. Guided Self learning (https://linuxjourney.com)
  2. Best one liners for linux command line (https://www.commandlinefu.com/commands/browse)
  3. Find files in linux from command line (https://linuxize.com/post/how-to-find-files-in-linux-using-the-command-line)
  4. Improve your typing speed on the command line with this awesome tool! (https://github.com/balzss/cli-typer)
  5. An interactive cheatsheet tool for the command-line (https://github.com/denisidoro/navi)
  6. Customize your shell environment to next level (https://github.com/alebcay/awesome-shell)
  7. I find it useful to learn new things with the self learning courses offered by github (https://lab.github.com)
  8. A static analysis tool for shell scripts (https://github.com/koalaman/shellcheck)
  9. A good collection of bash snippets if you are starting to learn about shell scripts in linux (https://github.com/alexanderepstein/Bash-Snippets)
  10. Linux workshop 10 days (https://linuxessentials.netlify.app)
@akhan4u
akhan4u / file.py
Last active May 25, 2021 08:15
s3 replication cross region within same AWS account
import boto3, os, botocore, traceback
from botocore.exceptions import ClientError
s3 = boto3.client('s3')
# READ VALUES FROM ENVIRONMENT VARIABLES
source_s3_bucket = os.environ['source_s3_bucket']
#kms_keyid = os.environ['Kms_Keyid']
@akhan4u
akhan4u / install_nvidia-docker2.sh
Last active April 3, 2019 18:55
Install nvidia-docker2 and docker-ce on Ubuntu 18.04
#!/bin/bash
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
echo -e "Installing nvidia-docker2 for $distribution"
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | \
sudo apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | \
@akhan4u
akhan4u / check_gpu_state
Created April 3, 2019 18:31
Verify the setup of nvidia drivers for GPU.
root@gpu-01:~# python
Python 3.6.8 |Anaconda custom (64-bit)| (default, Dec 30 2018, 01:22:34)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from tensorflow.python.client import device_lib
>>> print(device_lib.list_local_devices())
2019-04-03 19:09:01.537417: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
2019-04-03 19:09:02.180944: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:898] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2019-04-03 19:09:02.181307: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1344] Found device 0 with properties:
name: GeForce RTX 2080 Ti major: 7 minor: 5 memoryClockRate(GHz): 1.545