Notes, summaries, assignments, exams, and exercises for Computer science for University

Mastering JavaScript Regular Expressions

Computer science5.38 KB

JavaScript Regular Expressions: An Introduction

This concise and clear introduction to Regular Expressions (RegExp) in JavaScript covers their usage, modifiers, patterns, methods, and string integration.

Regular Expressions are powerful patterns used to match, search, and manipulate strings. In JavaScript, regular expressions are objects used with string methods to perform pattern matching.


RegExp Syntax Fundamentals

You can define a regular expression using literal notation:

const pattern = /expression/modifiers;

Or by using the RegExp constructor:

const pattern = new RegExp("expression", "modifiers");

RegExp Modifiers (Flags) Explained

Modifiers change how a Regular Expression behaves:

ModifierDescription
gGlobal match (find all matches, not just the
...
Continue reading "Mastering JavaScript Regular Expressions" »

Python Best Practices: Style, Concepts, and Comprehensions

Computer science386.58 KB

Python Coding Style: PEP 8

PEP 8: Indentation: Use 4 spaces. Line Length: Limit to 79 characters. Imports: Import on separate lines. Naming: Follow naming conventions. Comments: Explain non-obvious code. Whitespace: Use blank lines judiciously. Function Arguments: Use spaces after commas. Annotations: Follow type annotation guidelines.

Documentation: Use docstrings. Vertical Whitespace: Separate code logically. Imports Formatting: Organize import statements. Avoid Wildcard Imports: Be explicit. Consistency: Maintain consistency in style.

Four Core Programming Concepts

Four Big Programming Concepts: Abstraction and encapsulation, Parameterization, Iteration (loops), Expressions (calculations).

Understanding NamedTuple

NamedTuple: Named Fields: namedtuple...

Continue reading "Python Best Practices: Style, Concepts, and Comprehensions" »

Database Security, AutoML, and Data Lake Table Joining

Computer science3.65 KB

Acid Rain: Concurrency-Related Attacks in Database-Backed Web Applications

Motivation:

  • 12 popular self-hosted e-commerce applications (deployed over 2M websites, representing over 50% of all e-commerce websites)
  • 22 critical ACIDRain attacks identified and verified
  • Flexcoin -> Bankrupted

Problem Definition:

An application is vulnerable if:

  • Anomalies Possible: Under concurrent API access, the application may exhibit behaviors (i.e., anomalies) that could not have arisen under serial execution.
  • Sensitive Invariants: The anomalies arising from concurrent access lead to violations of application invariants.

Solution:

  • Execute API calls against a live application and database to generate a (possibly sequential) trace of database activity.
  • Analyze the trace
...
Continue reading "Database Security, AutoML, and Data Lake Table Joining" »

Relational Database Concepts: Keys, Views, and SQL

Computer science14.08 KB

Relational Keys

Superkey: Set of attributes with all those needed to ID a particular row. Candidate key: Minimal superkey; removing any attribute means it is no longer a superkey; can be multiple per relation; "UNIQUE". Strict: Candidate key + at least 1 extra attribute. Primary: Default candidate key, reference for foreign keys; automatically unique; "PRIMARY KEY". Foreign: "Logical pointer" in a dependent relation that refers to the candidate key in the parent relation (not always primary). Natural: Represent conceptual uniqueness constraints external to the DB, e.g., name, address. Artificial: Introduced solely for the DB, no external meaning, e.g., auto-generated ID; single attribute, simple data type. Surrogate: If artificial is used as
...
Continue reading "Relational Database Concepts: Keys, Views, and SQL" »

Understanding Interrupts in Computer Systems

Computer science2.49 KB

a) Advantage of Interrupts for Peripheral Devices

Explain the advantage of using interrupts as a technique for handling peripheral devices and relate it to computer performance. (10)

Answer

Interrupts offer a significant advantage because the processor doesn't need to constantly poll peripherals to check for data readiness. Instead, the peripheral alerts the processor when it's ready. This allows the processor to focus on other tasks while waiting for the peripheral, thus increasing overall computer performance.

b) Multiple Choice Questions on Interrupts

With regard to interrupts, check only what is correct in the following statements. (8) Explain why the last statement has been marked as correct. (7) Total 15 points

1.

To be considered an interrupt,...

Continue reading "Understanding Interrupts in Computer Systems" »

Essential Linux Commands & File System Structure

Computer science7.16 KB

Linux File System Structure: An archive of Linux is associated with 3 parts: superblock, inode table, and data blocks.

Network Ports: To see the ports assigned to services.

Display Active TCP/IP Connections: netstat -a

User Management:

  • Create password: passwd (user)
  • Add user to group: usermod -g group_name
  • Disable: 60001
  • Enable: 60002

Practical Commands:

Add User: adduser

  1. Change folder privileges: chmod
  2. Check privileges: ls -de (see if you changed privileges)
  1. Create a user: useradd newuser
    passwd newuser
  2. Create a directory: The command mkdir is used to create directories:
    mkdir mydirectory
  3. Create a report: ps -aux >> reporte.txt
  4. Directories associated with the user: -d dirname
  5. Changing permission: chmod 744 file.txt /file.txt
  6. Change owner: chown
    Entering
...
Continue reading "Essential Linux Commands & File System Structure" »

Data Link Protocols, ATM, and Routing Optimization

Computer science1.8 KB

Data Link Protocols

LAPB, LAPF, and LAPD

These are Data Link protocols:

  • LAPB (Link Access Procedure, Balanced): A subset of HDLC, providing asynchronous balanced mode (ABM) for point-to-point links between user systems and packet-switching network nodes.
  • LAPF (Link Access Procedure for Frame-Mode Bearer Services): Includes a control protocol (similar to HDLC) and a core protocol (subset of the control protocol). LAPF control uses ABM and 7-bit sequence numbers. LAPF core has flag, address, information, and FCS fields, but no control field.
  • LAPD (Link Access Procedure, D-Channel): Provides data link control over the ISDN D channel. Uses ABM, 7-bit sequence numbers, a 16-bit CRC FCS, and a two-part address field for device and logical user identification.
...
Continue reading "Data Link Protocols, ATM, and Routing Optimization" »

Understanding Operating Systems: Definition and Functions

Computer science2.12 KB

Operating Systems

What are operating systems? This question can be answered at several levels.

Firstly, an operating system is a program, or a set of programs. Operating systems vary in size from very small to very large, but all are pieces of software. In the past, almost all operating systems were written in a low-level language. Currently, many operating systems are partly or completely written in a high-level language.

Secondly, an operating system is, by virtue of its name, a system. It is a collection of parts working together towards some common goals. The goals or objectives of an operating system may be regarded as the manager of these resources.

Thirdly, a computer may be regarded as a set of devices, or resources, which provide a number...

Continue reading "Understanding Operating Systems: Definition and Functions" »

Core Principles of Assemblers and Operating Systems

Computer science86.56 KB

Assembly Language Fundamentals

Assembly language is a low-level language that uses mnemonic instructions instead of binary code. The assembler translates these instructions into machine language. Assembly language instructions are categorized into three types:

  • Imperative Statements (IS): These are executable instructions that perform actual CPU operations and generate machine code. Examples include STOP, ADD, SUB, MULT, MOVER, MOVEM, COMP, BC, DIV, READ, and PRINT. For example, MOVER AREG, NUM moves data to a register, ADD AREG, ='5' adds a literal value, and MOVEM AREG, RESULT stores the result in memory.
  • Declarative Statements (DL): These are used to define data and reserve storage. DC (Define Constant) allocates memory and stores a constant
...
Continue reading "Core Principles of Assemblers and Operating Systems" »

Cache Mapping, Virtual Memory and I/O Techniques in Computer Architecture

Computer science27.48 KB

Q1. Cache Mapping Techniques

Cache memory is a small, fast memory placed between the CPU and main memory to speed up memory access. Mapping techniques determine how blocks from main memory are mapped to cache lines.

Three Types of Cache Mapping

1. Direct Mapping

In direct mapping, each block of main memory maps to exactly one specific cache line. The cache line number is determined by the formula:

Cache Line Number = (Block Address) mod (Number of Cache Lines)

Address format: The memory address is divided into three fields:

  • Tag: Identifies which block is currently stored.
  • Index: Identifies the cache line number.
  • Block offset: Identifies the word within the block.

Advantages:

  • Simple and easy to implement
  • Fast access time
  • Low-cost hardware

Disadvantages:

  • High
...
Continue reading "Cache Mapping, Virtual Memory and I/O Techniques in Computer Architecture" »