Notes, summaries, assignments, exams, and problems for Computers

Sort by
Subject
Level

Operating Systems: System Calls, Processes, and Forking

Classified in Computers

Written on in English with a size of 2.83 KB

Operating Systems: System Calls and File Descriptors

OS vs. User ModeRead vs. Write OperationsSpecial File Descriptors

System Calls and Kernel Mode

Public functions provided by the OS.

open(*pathname, Flags): Returns a file descriptor; returns -1 on error.

int main(int argc, char *argv[]) {
  int fd = open(argv[1], O_WRONLY | O_CREAT | O_EXCL, 0644);
  if (fd == -1) {
    printf("There was a problem creating \"%s\"!\n", argv[1]);
    return 1;
  }
  close(fd);
  return 0;
}

Handling Data Streams

read may not return all requested bytes; it returns the actual count read. It only returns 0 at the end of the file.

void copyContents(int sourceFD, int destinationFD) {
  char buffer[kCopyIncrement];
  while (true) {
    ssize_t bytesRead = read(sourceFD,
... Continue reading "Operating Systems: System Calls, Processes, and Forking" »

Assembly Language Programming: Code Analysis and Solutions

Posted by Anonymous and classified in Computers

Written on in English with a size of 4.63 KB

Assembly Language Code Analysis and Solutions

Section 1: Instruction Correctness Check

.data

calculate WORD 100
wVal DWORD 2

Instructions:

  1. mov bl, calculate
  2. mov ax, wVal

Question 1: Are the above two instructions correct? If not, justify your claim. [2 marks]

Answer:

Both instructions are incorrect.

  • For the mov operation, the operands must generally be of the same size.
  • In instruction 1, bl is 8 bits (1 byte), but calculate is defined as a WORD (16 bits or 2 bytes). The operand sizes do not match.
  • In instruction 2, ax is 16 bits (2 bytes), but wVal is defined as a DWORD (32 bits or 4 bytes). The operand sizes do not match.

Section 2: Loop Pseudo-code

Question 2: Write the pseudo-code for the loop that calculates the sum of the integers 3 + 2 + 1. [2 marks]

... Continue reading "Assembly Language Programming: Code Analysis and Solutions" »

Essential Kubectl Commands: The Ultimate Kubernetes Cheat Sheet

Posted by Anonymous and classified in Computers

Written on in English with a size of 7.76 KB

Key Takeaways

  • kubectl is the core tool for managing Kubernetes clusters, enabling you to inspect, deploy, troubleshoot, and scale workloads from the command line. Mastering flags like -n, -o, and --dry-run is essential.
  • Use a consistent workflow for debugging: getdescribelogs. This structured approach surfaces issues faster and reduces downtime.
  • Favor declarative over imperative commands by using YAML manifests with kubectl apply to promote version control and repeatability.

Kubernetes (K8s) is the industry standard for orchestrating containerized applications, but managing it can be complex. At the center of every Kubernetes workflow is kubectl, the command-line utility used to interact with clusters, deploy applications, and troubleshoot

... Continue reading "Essential Kubectl Commands: The Ultimate Kubernetes Cheat Sheet" »

Python Fundamentals: Strings, Lists, Math, and Plotting Examples

Posted by Anonymous and classified in Computers

Written on in English with a size of 6.74 KB

P1: Python String Manipulation Techniques

Demonstrating String Operations

s = "hello"
print(s.capitalize())
print(s.upper())
print(s.rjust(100))
print(s.center(100))
print(s.replace('l','(M)'))
print(s)
print("don't")

Indexing

a = 'symbiosis2024'
print(a[2])

Negative Indexing

print(a[-1])
print(a[-6])

Slicing

print(a[9:12])
print(a[9:])
print(a[9:-1])
print(a[:8])
print(a[-12:-1])

Stride [start index:end index:step size]

print(a[0:13:2])
print(a[0::2])

Concatenation

b = 'hello'
c = 'world'
d = b + c
print(d)
e = b + " " + c
print(e)

Repetition

f = a * 3
print(f)
g = "2024"
print(g * 2)
print(a + '2')

Reversing a String

print(a[::-1])

Split

h = "sspu"
print(h.split()) # Returns a list
i = "05/08/2024"
print(i.split("/"))
j = "14:20:25"
print(j.split("
... Continue reading "Python Fundamentals: Strings, Lists, Math, and Plotting Examples" »

Nmap, Netcat, and Metasploit Commands Cheat Sheet

Classified in Computers

Written on in English with a size of 7.67 KB

Nmap Options

-PE: Quickly check if host is up.

-sn: Disable port scanning (host discovery).

-n: Disables DNS resolution (checks IP online without looking up hostnames).

-O: OS detection.

-A: OS detection, Version detection, Script scanning, traceroute.

-sV: Service detection (banner info, version).

-vV: Provides verbose output.

-sC: Scan with default scripts for additional info gathering.

--min-rate=5000: Ensures scan sends at least 5k packets per second.

nmap --script smb-enum-shares.nse -p 445 (ip): List shares and their properties.


To see scripts starting with X: ls /path/X

To execute script with script tracing: sudo nmap -script=smb-os-discovery -script-trace target_ip

To enumerate the SMB share files: sudo nmap -script=smb-enum-shares target_ip

Vulnerability... Continue reading "Nmap, Netcat, and Metasploit Commands Cheat Sheet" »

Assembly Instruction Set Categories and Functions

Posted by Anonymous and classified in Computers

Written on in English with a size of 5.73 KB

🧾 Data Transfer Instructions

These instructions are used to move data between registers, memory, and I/O ports.

InstructionUse
MOVTransfer data between registers or memory locations
PUSH / POPPerform stack operations (store/retrieve data)
XCHGExchange contents of two operands
IN / OUTInput from or output to a port
LEALoad Effective Address
LDS / LESLoad Pointer and Segment Register
XLATTranslate byte using a lookup table

➕ Arithmetic Instructions

These instructions perform basic mathematical operations.

InstructionUse
ADD / SUBAddition / Subtraction
ADC / SBBAdd/Subtract with Carry/Borrow
INC / DECIncrement / Decrement a value
MUL / IMULUnsigned / Signed Multiplication
DIV / IDIVUnsigned / Signed Division
NEGTwo's Complement (Negation)
CMPCompare operands
... Continue reading "Assembly Instruction Set Categories and Functions" »

C Data Structures: Binary Trees, DFS, and Stack Logic

Classified in Computers

Written on in English with a size of 3.54 KB

7th Experiment: Binary Tree Construction

This experiment demonstrates the construction of a binary tree from an array and its in-order traversal.

#include <stdio.h>
#include <stdlib.h>

struct node {
  struct node* left;
  char data;
  struct node* right;
};

struct node* constructTree(int index);
void inorder(struct node* root);

char array[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', '\0', '\0', 'H' };
int leftcount[] = { 1, 3, 5, -1, 9, -1, -1, -1, -1, -1 };
int rightcount[] = { 2, 4, 6, -1, -1, -1, -1, -1, -1, -1 };

int main() {
  struct node* root = constructTree(0);
  printf("In-order Traversal: \n");
  inorder(root);
  return 0;
}

struct node* constructTree(int index) {
  struct node* temp = NULL;
  if (index != -1) {
    temp
... Continue reading "C Data Structures: Binary Trees, DFS, and Stack Logic" »

Cloud Machine Learning Workflow and Content Delivery Optimization

Posted by Anonymous and classified in Computers

Written on in English with a size of 3.81 KB

Steps for Training a Machine Learning Project in the Cloud

Definition: Cloud ML Project Training

Training an ML Project in the Cloud means utilizing cloud-based resources and services to build, train, and optimize a Machine Learning model.

The Seven Key Steps in Cloud ML Training

  1. Data Collection: Gather and upload the dataset to cloud storage.
  2. Data Preprocessing: Clean and prepare data using cloud notebooks or specialized processing services.
  3. Model Selection: Choose the appropriate algorithm or utilize a pre-built model architecture.
  4. Training: Use scalable cloud compute resources (GPUs/TPUs) for intensive model training.
  5. Evaluation: Test model accuracy and performance using validation data.
  6. Hyperparameter Tuning: Optimize model parameters for better
... Continue reading "Cloud Machine Learning Workflow and Content Delivery Optimization" »

Essential PHP Programming: Forms, Databases, and Sessions

Posted by Anonymous and classified in Computers

Written on in English with a size of 2.37 KB

PHP Form Validation

To create a PHP form and perform server-side validation for user input such as name, email, and password:

<?php
$name = $email = $password = "";
$nameErr = $emailErr = $passwordErr = "";

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Name Validation
    if (empty($_POST["name"])) { $nameErr = "Name is required"; } else { $name = $_POST["name"]; }
    // Email Validation
    if (empty($_POST["email"])) { $emailErr = "Email is required"; } else { $email = $_POST["email"];
        if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $emailErr = "Invalid email format"; } 
    }
    // Password Validation
    if (empty($_POST["password"])) { $passwordErr = "Password is required"; } else { $password = $_POST["password"];
... Continue reading "Essential PHP Programming: Forms, Databases, and Sessions" »

Android and iOS Mobile App Development Solutions

Posted by Anonymous and classified in Computers

Written on in English with a size of 11.74 KB

RecyclerView Features and GridView Implementation

1. List and explain any three features of RecyclerView. Develop an Android application to display any five programming languages in GridView.

  • View Recycling: Reuses views to improve performance and reduce memory usage.
  • ViewHolder Pattern: Stores item views to avoid repeated findViewById() calls.
  • Flexible Layout: Supports LinearLayoutManager, GridLayoutManager, and StaggeredGridLayoutManager.

Example: XML and Java

Java Code:

GridView gridView = findViewById(R.id.gridView);
String[] languages = {"C", "C++", "Java", "Python", "Kotlin"};
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, languages);
gridView.setAdapter(adapter);

API Types and Data Passing

... Continue reading "Android and iOS Mobile App Development Solutions" »