The first assignment for AUT's Advanced Programming course (Spring 2024), It includes a bash script for directory backups and logging, and a C++ module for matrix operations in the algebra namespace. Both tasks focus on enhancing automation, system administration, and programming skills.
git clone https://github.com/courseworks/AUT_AP_2024_Spring_HW1.gitThis skill implements two core programming tasks: a bash script for automated directory backups with comprehensive logging, and a C++ algebra namespace with matrix operations. The backup script accepts source and destination paths with optional compression levels, creates timestamped zip files, and generates detailed logs including file counts, timestamps, and system information. The algebra namespace provides template-based matrix creation and manipulation functions supporting zeros, ones, identity, and random initialization, plus display formatting using the C++20 format library. Students and automation engineers benefit from hands-on experience in system administration scripting and linear algebra programming.
Place backup_script.sh in the bash folder and make it executable with chmod +x. Run it with: ./backup_script.sh <source_path> <destination_path> [-c compression_level]. For the C++ component, implement the algebra namespace with create_matrix and display functions using the provided template signatures and C++20 format library.
Creating automated daily backup solutions with detailed audit logs
Implementing matrix operations for linear algebra computations
Learning bash shell scripting for system administration tasks
Building C++20 template-based numerical computing libraries
No install command available. Check the GitHub repository for manual installation instructions.
git clone https://github.com/courseworks/AUT_AP_2024_Spring_HW1Copy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Create a solution for AUT's Advanced Programming Spring 2024 Homework 1. The assignment includes two parts: a bash script for directory backups and logging, and a C++ module for matrix operations in the algebra namespace. Provide the complete code for both parts, with detailed comments explaining each section. Ensure the bash script handles errors gracefully and logs all operations to a specified file. The C++ module should include functions for matrix addition, subtraction, and multiplication, all within the algebra namespace.
```cpp
// C++ Matrix Operations Module
#include <iostream>
#include <vector>
namespace algebra {
// Matrix class definition
class Matrix {
public:
Matrix(int rows, int cols);
~Matrix();
// Matrix operations
Matrix add(const Matrix& other) const;
Matrix subtract(const Matrix& other) const;
Matrix multiply(const Matrix& other) const;
private:
int rows;
int cols;
double** data;
};
// Constructor implementation
Matrix::Matrix(int r, int c) : rows(r), cols(c) {
data = new double*[rows];
for (int i = 0; i < rows; ++i) {
data[i] = new double[cols]();
}
}
// Destructor implementation
Matrix::~Matrix() {
for (int i = 0; i < rows; ++i) {
delete[] data[i];
}
delete[] data;
}
// Matrix addition implementation
Matrix Matrix::add(const Matrix& other) const {
if (rows != other.rows || cols != other.cols) {
throw std::invalid_argument("Matrix dimensions do not match");
}
Matrix result(rows, cols);
for (int i = 0; i < rows; ++i) {
for (int j = 0; j < cols; ++j) {
result.data[i][j] = data[i][j] + other.data[i][j];
}
}
return result;
}
// Similar implementations for subtract and multiply
}
int main() {
// Example usage
algebra::Matrix m1(2, 2);
algebra::Matrix m2(2, 2);
algebra::Matrix m3 = m1.add(m2);
return 0;
}
```
```bash
#!/bin/bash
# Directory Backup and Logging Script
# Configuration
BACKUP_DIR="/path/to/backup"
LOG_FILE="/var/log/backup.log"
SOURCE_DIRS=("/path/to/source1" "/path/to/source2")
# Logging function
log() {
echo "[$(date +'%Y-%m-%d %H:%M:%S')] $1" >> "$LOG_FILE"
}
# Backup function
backup() {
local dir=$1
local timestamp=$(date +%Y%m%d_%H%M%S)
local backup_file="$BACKUP_DIR/backup_${timestamp}.tar.gz"
log "Starting backup of $dir"
if tar -czf "$backup_file" "$dir" 2>> "$LOG_FILE"; then
log "Backup of $dir completed successfully"
else
log "Error: Backup of $dir failed"
return 1
fi
}
# Main script
log "Backup script started"
for dir in "${SOURCE_DIRS[@]}"; do
if [ -d "$dir" ]; then
backup "$dir"
else
log "Error: Source directory $dir does not exist"
fi
done
log "Backup script finished"
```Automate your browser workflows effortlessly
Get more done every day with Microsoft Teams – powered by AI
Automate security compliance and monitor real-time security posture seamlessly.
Automate your spreadsheet tasks with AI power
Agentic AI Workflow platform
Connected workspace for docs, wikis, and projects
Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan