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.gitThe 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.
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"
```Your one-stop shop for church and ministry supplies.
Automate your browser workflows effortlessly
IronCalc is a spreadsheet engine and ecosystem
Customer feedback management made simple
Enterprise workflow automation and service management platform
Automate your spreadsheet tasks with AI power