ZeroMQ in Node.js: Examples & Patterns
ZeroMQ in Node.js: Practical Examples
This document provides practical examples of using ZeroMQ (zeromq) in Node.js. It covers several common messaging patterns, including Publish/Subscribe, Push/Pull, Router/Dealer, and Request/Reply. Each example is presented with corrected code and explanations.
Publish/Subscribe Pattern (Pub/Sub)
This example demonstrates a publisher sending messages on different topics, and a subscriber listening to a specific topic (“Politica”).
const zmq = require('zeromq') Read More
Java HashMap Implementation: Code and Explanation
Java HashMap Implementation
This document provides a detailed implementation of a HashMap in Java.
public class HashMap<K, V> implements Map<K, V> {
private int capacidad;
private int numElem;
private Lista<Map.Par<K, V>>[] arrayMapa;
public HashMap(int cap) throws IllegalArgumentException {
if (cap < 0) {
throw new IllegalArgumentException("NUMERO NEGATIVO");
} else {
this.capacidad = cap;
this.numElem Read More
Understanding IP Address Spaces and Common Ports
Understanding IP Address Spaces
Private IPv4 Address Spaces
The following table lists the private IPv4 address spaces:
| Address Block | Description |
| 127.0.0.0/8 | Loopback |
| 192.168.0.0/16 | Private Network |
| 10.0.0.0/8 | Private Network |
| 100.64.0.0/10 | Shared address space[4] carrier-grade NAT. |
| 172.16.0.0/12 | Private Network (172.16.0.0–172.31.255.255) |
Special Use IPv4 Addresses
These addresses are reserved for specific purposes:
| Address Block | Description |
| 224.0.0.0/4 | IP multicast.[10] (Former Class D network.) |
| 240.0.0.0/4 | Reserved |
Communication Channels and Technologies
Communication Channels
A communication channel routes messages from sender to receiver. Channels can be guided (e.g., copper wires, optical fiber) or unguided (e.g., air, vacuum).
Types of Communication Channels
- Dedicated Links: Establish an exclusive channel between two interlocutors.
- Point-to-Point: One sender and one receiver.
- Multipoint: Multiple callers at either end.
- Shared Networks: Callers connect to a network node to contact others.
- Dissemination (Broadcast): Transmitter sends data to multiple
Java Code Examples: Backpack & Maximum Subarray
Backpack Problem Implementation in Java
This code implements a solution to the Backpack problem using a depth-first search approach. The Alforja class represents the backpack and its contents.
public class Alforja implements Solution {
private ArrayList<Integer> pesos;
private ArrayList<Integer> valors;
private ArrayList<Integer> alforja;
public static int MAXPES = 0;
public Alforja() {
pesos = new ArrayList<>();
valors = new ArrayList& Read More
Satellite Communication and Radio Wave Fundamentals
Iridium Satellite Constellation
Iridium is the name of a constellation of 66 communications satellites orbiting the Earth in 6 low Earth orbits (LEO), each consisting of 11 evenly spaced satellites. Its name comes from the element Iridium, which has an atomic number of 77, equivalent to the number of satellites in the constellation, including its original design.
Radio Wave Fundamentals
Frequency
Frequency is a measure that is generally used to indicate the number of repetitions of any phenomenon or
Read More