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

Sort by
Subject
Level

Cybersecurity Threat Landscape: Actors, Vectors, and Defenses

Posted by Anonymous and classified in Computers

Written on in English with a size of 9.76 KB

🔎 Threat Actors & Their Attack Paths

Who is attacking?

Threat Actors are the people or groups launching attacks. Mnemonic: “NO HIS” (Nation-State, Organized Crime, Hacktivists, Insiders, Script Kiddies).

Actor TypeMotivationTactics
Nation-State (APT Groups)Espionage, warfareAdvanced, persistent attacks
Organized CrimeFinancial gainRansomware, phishing
HacktivistsSocial justice, ideologyWebsite defacement, data leaks
InsidersRevenge, profitData theft, sabotage
Script KiddiesFun, fameLow-skill attacks using existing tools

How do threats reach systems?

Threat Vectors are the attack paths used by threat actors. Mnemonic: “MFWDVN” (Messages, Files, Websites, Devices, Vendors, Networks).

Attack PathExampleHow It Works
Message-BasedPhishing, smishingTrick
... Continue reading "Cybersecurity Threat Landscape: Actors, Vectors, and Defenses" »

Essential C Programming Examples and Algorithms

Posted by Anonymous and classified in Computers

Written on in English with a size of 72.94 KB

wfSCE5je3rPDgAAAABJRU5ErkJggg==

Leap Year

#include <stdio.h>
int main() {
    int y;
    scanf("%d", &y);
    if ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0)
        printf("Leap Year");
    else
        printf("Not Leap Year");
    return 0;
}

Simple Calculator Using Switch

#include <stdio.h>
int main() {
    char op;
    float a, b;
    scanf(" %c %f %f", &op, &a, &b);
    switch (op) {
        case '+': printf("%.2f", a + b); break;
        case '-': printf("%.2f", a - b); break;
        case '*': printf("%.2f", a * b); break;
        case '/':
            if (b != 0)
                printf("%.2f", a / b);
            else
                printf("Error");
            break;
        default: printf("Invalid Operator");
    }
    return
... Continue reading "Essential C Programming Examples and Algorithms" »

Ec lab

Posted by Anonymous and classified in Computers

Written on in English with a size of 3.19 KB

Postfix evaluation 

#include<stdio.H>
int stack[20];
int top = -1;

void push(int x)
{
    stack[++top] = x;
}

int pop()
{
    return stack[top--];
}

int main()
{
    char exp[20];
    char *e;
    int n1,n2,n3,num;
    printf("Enter the expression :: ");
    scanf("%s",exp);
    e = exp;
    while(*e != '\0')
    {
        if(isdigit(*e))
        {
            num = *e - 48;
            push(num);
        }
        else
        {
            n1 = pop();
            n2 = pop();
            switch(*e)
            {
            case '+':
            {
                n3 = n1 + n2;
                break;
            }
            case '-':
            {
 ... Continue reading "Ec lab" »

C++ Concepts: Exception Handling to Friend Functions

Classified in Computers

Written on in English with a size of 3.16 KB

Exception Handling

#include <iostream>
#include <stdexcept>
using namespace std;
int main() {
    try {
        int numerator = 10;
        int denominator = 0;
        int res;
        if (denominator == 0) {
            throw runtime_error("Division by zero not allowed!");
        }
        res = numerator / denominator;
        cout << "Result after division: " << res << endl;
    }
    catch (const exception& e) {
        cout << "Exception " << e.what() << endl;
    }
    return 0;
}

Operator Overloading

#include <iostream>
using namespace std;
class Test {
private:
    int num;
public:
    Test(): num(8){}
    void operator ++() {
        num = num + 2;
    }
    void Print() {
... Continue reading "C++ Concepts: Exception Handling to Friend Functions" »

FCFS and SJF CPU Scheduling C Program Example

Posted by Anonymous and classified in Computers

Written on in English with a size of 3.03 KB

FCFS and SJF CPU Scheduling C Program Example

Corrected and formatted C source code for FCFS and SJF scheduling.

FCFS Scheduling C Implementation

#include <stdio.h>

int FCFS() {
    int bt[15], n, i, wt[15];
    float twt = 0, tat = 0, att, awt;
    printf("\nTHE FCFS SCHEDULING\n");
    printf("Enter the number of processes: ");
    scanf("%d", &n);
    printf("Enter burst time of all the processes:\n");
    for (i = 0; i < n; i++) {
        printf("P%d: ", i + 1);
        scanf("%d", &bt[i]);
    }

    wt[0] = 0;
    // for calculating waiting time of each process
    for (i = 1; i < n; i++)
        wt[i] = bt[i - 1] + wt[i - 1];

    printf("ProcessID\tBurstTime\tWaitingTime\tTurn Around Time\n");
    for (i = 0; i <
... Continue reading "FCFS and SJF CPU Scheduling C Program Example" »

CUDA Matrix Multiplication: Shared Memory

Classified in Computers

Written on in English with a size of 3.23 KB

CUDA Matrix Multiplication Using Shared Memory

This code demonstrates matrix multiplication in CUDA, leveraging shared memory for optimization. It includes two examples: a kernel using shared memory and a host-side implementation using the Thrust library.

CUDA Kernel with Shared Memory

The following CUDA kernel performs matrix multiplication using shared memory to optimize data access:


__global__ void matMulShared(int *A, int *B, int *C, int rowsA, int colsA, int colsB) {
    __shared__ int tile_A[TILE_SIZE][TILE_SIZE], tile_B[TILE_SIZE][TILE_SIZE];
    int row = blockIdx.y * TILE_SIZE + threadIdx.y, col = blockIdx.x * TILE_SIZE + threadIdx.x, temp = 0;
    for (int i = 0; i < (colsA + TILE_SIZE - 1) / TILE_SIZE; ++i) {
        if (row <
... Continue reading "CUDA Matrix Multiplication: Shared Memory" »

Essential PHP Programming Examples for Beginners

Posted by Anonymous and classified in Computers

Written on in English with a size of 1.26 KB

Addition of Two Numbers

<?php
if(isset($_POST['n1']) && isset($_POST['n2'])){
    $n1 = $_POST['n1'];
    $n2 = $_POST['n2'];
    $res = $n1 + $n2;
    echo "<h3>User Input Numbers:</h3>";
    echo "First Number = $n1 <br>";
    echo "Second Number = $n2 <br>";
    echo "Sum = $res";
}
?>

Enter Two Numbers:





PHP Conditional, Loops and Arrays Example

<?php
echo "<h3>Loop Example (1 to 5):</h3>";
for($i=1;$i<=5;$i++){
    echo "Number: $i <br>";
}
echo "<h3>Array Example:</h3>";
$fruits = array("Apple","Banana","Mango","Orange");
foreach($fruits as $f){
    echo "$f<br>";
}
?>

Student Registration Form

Name:

Email:

Gender:
Male
Female

Subjects:
Math
Science
English

Course:

... Continue reading "Essential PHP Programming Examples for Beginners" »

JDBC Drivers, JSP Tags, and ResultSet Implementation

Posted by Anonymous and classified in Computers

Written on in English with a size of 2.86 KB

JDBC Driver Types

Type 1: JDBC-ODBC Bridge

  • Converts JDBC calls to ODBC
  • ❌ Slow, platform dependent, and obsolete

Type 2: Native API Driver

  • Uses database-specific native libraries
  • ⚠️ Faster than Type 1 but platform dependent

Type 3: Network Protocol Driver

  • Uses middleware server to connect
  • 🌐 Platform independent but slower due to network

Type 4: Thin Driver

  • Directly connects to database using pure Java
  • ✅ Fast, platform independent, and most used

Tags in JSP

1. Directive Tags

  • Provide instructions to the JSP container
  • Syntax: <%@ ... %>
  • Example: page, include, taglib

2. Scripting Tags

  • Scriptlet Tag: Write Java code <% ... %>
  • Expression Tag: Display output <%= ... %>
  • Declaration Tag: Declare variables or methods <%! ... %>

3. Action

... Continue reading "JDBC Drivers, JSP Tags, and ResultSet Implementation" »

Python Logic for Sequences and Base Conversions

Classified in Computers

Written on in English with a size of 3.82 KB

Tile Sequence Validation Logic

The following function determines if a sequence of tiles is valid by checking their compatibility and adjusting their orientation if necessary.

def is_valid_sequence(seq: list[Tile]) -> bool:
    if len(seq) < 2:
        res = True
    else:
        if not are_compatible(seq[0], seq[1]):
            seq[0] = seq[0][1], seq[0][0]
        i = 1
        while i < len(seq) and are_compatible(seq[i - 1], seq[i]):
            if seq[i - 1][1] != seq[i][0]:
                seq[i] = seq[i][1], seq[i][0]
            i += 1
        res = i == len(seq)
    return res

Square-Free Number Verification

This function checks if a positive integer is square-free, meaning no prime factor has an exponent greater than one.

def
... Continue reading "Python Logic for Sequences and Base Conversions" »

Essential Network Packet Filtering Syntax Reference

Posted by Anonymous and classified in Computers

Written on in English with a size of 12.41 KB

Basic Protocol Filters

Use these filters to quickly isolate traffic based on common protocols:

  • arp (Address Resolution Protocol)
  • dns (Domain Name System)
  • http (Hypertext Transfer Protocol)
  • https (HTTP Secure)
  • icmp (Internet Control Message Protocol)
  • ip (Internet Protocol)
  • ipv6 (Internet Protocol Version 6)
  • ntp (Network Time Protocol)
  • smtp (Simple Mail Transfer Protocol)
  • ftp (File Transfer Protocol)
  • ssh (Secure Shell)
  • tls (Transport Layer Security)
  • udp (User Datagram Protocol)
  • tcp (Transmission Control Protocol)
  • dhcp (Dynamic Host Configuration Protocol)
  • bootp (Bootstrap Protocol)
  • radius (Remote Authentication Dial-In User Service)
  • snmp (Simple Network Management Protocol)
  • kerberos
  • smb (Server Message Block)
  • nbns (NetBIOS Name Service)
  • nbss (NetBIOS Session Service)
... Continue reading "Essential Network Packet Filtering Syntax Reference" »