Skip to content

Commit

Permalink
Update .functions
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinav-nath authored Aug 8, 2023
1 parent 9d94289 commit a76176e
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions dev-setup/.functions
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,85 @@ kscale() { k scale deployment "$1" --replicas="$2"; }

# enter into pod's bash shell
kbash() { kubectl -it exec "$1" bash; }

# Function to convert from feet to inches
f2i() {
if [ $# -lt 1 ]; then
echo "Error: Missing parameters. Usage: f2i <feet> [<inches>]"
return 1
fi

feet=$1
inches=${2:-0} # If in not provided, default to 0

total_inches=$((feet * 12 + inches))
echo "$feet ft $inches in = $total_inches in"
}

# Function to convert from in to centimeters
i2c() {
if [ $# -lt 1 ]; then
echo "Error: Missing parameter. Usage: i2c <inches>"
return 1
fi

inches=$1
centimeters=$(bc <<< "scale=2; $inches * 2.54")
echo "$inches in = $centimeters cm"
}

# Function to convert from centimeters to inches
c2i() {
if [ $# -lt 1 ]; then
echo "Error: Missing parameter. Usage: c2i <centimeters>"
return 1
fi

centimeters=$1
inches=$(bc <<< "scale=2; $centimeters / 2.54")
echo "$centimeters cm = $inches in"
}

# Function to convert from inches to feet
i2f() {
if [ $# -lt 1 ]; then
echo "Error: Missing parameter. Usage: i2f <inches>"
return 1
fi

inches=$1
feet=$((inches / 12))
remaining_inches=$((inches % 12))
echo "$inches in = $feet ft $remaining_inches in"
}

# Function to convert from feet to centimeters
f2c() {
if [ $# -lt 1 ]; then
echo "Error: Missing parameters. Usage: f2c <feet> [<inches>]"
return 1
fi

feet=$1
inches=${2:-0} # If in not provided, default to 0

total_inches=$((feet * 12 + inches))
centimeters=$(bc <<< "scale=2; $total_inches * 2.54")
echo "$feet ft $inches in = $centimeters cm"
}

# Function to convert from centimeters to feet and inches
c2f() {
if [ $# -lt 1 ]; then
echo "Error: Missing parameter. Usage: c2f <centimeters>"
return 1
fi

centimeters=$1
total_inches=$(bc <<< "scale=2; $centimeters / 2.54")

feet=$((total_inches / 12))
remaining_inches=$((total_inches % 12))

echo "$centimeters cms = $feet ft and $remaining_inches in"
}

0 comments on commit a76176e

Please sign in to comment.