<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Sparky-code</title>
    <description>The latest articles on Forem by Sparky-code (@sparkycode).</description>
    <link>https://forem.com/sparkycode</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F802614%2F8a1a3adb-f2b8-4153-be7d-49727b71de08.jpg</url>
      <title>Forem: Sparky-code</title>
      <link>https://forem.com/sparkycode</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/sparkycode"/>
    <language>en</language>
    <item>
      <title>Understanding Internet Content Providers (ICP) and ICP Licenses in China</title>
      <dc:creator>Sparky-code</dc:creator>
      <pubDate>Thu, 16 May 2024 18:06:21 +0000</pubDate>
      <link>https://forem.com/sparkycode/understanding-internet-content-providers-icp-and-icp-licenses-in-china-4f8o</link>
      <guid>https://forem.com/sparkycode/understanding-internet-content-providers-icp-and-icp-licenses-in-china-4f8o</guid>
      <description>&lt;p&gt;An Internet Content Provider (ICP) is a company or organization that provides information or services over the Internet. This includes websites, blogs, online stores, and any other type of digital content. ICPs are pivotal in shaping the web landscape, offering everything from news and entertainment to e-commerce and educational resources.&lt;br&gt;
The Role of ICPs&lt;/p&gt;

&lt;p&gt;ICPs create, manage, and distribute content that users access via the internet. They can be media companies, e-commerce platforms, educational websites, or any entity that publishes content online. The main role of an ICP is to produce engaging, informative, or useful content for their target audience, driving traffic and engagement to their online platforms.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is an ICP License?
&lt;/h3&gt;

&lt;p&gt;An ICP License is a permit issued by a government authority that allows a company to operate as an Internet Content Provider. In China, the Ministry of Industry and Information Technology (MIIT) oversees the issuance of ICP Licenses. This license is mandatory for any website hosted in China that provides commercial services. &lt;a href="https://developers.cloudflare.com/china-network/concepts/icp/"&gt;See cloudflares documentation on this&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The Origin and Importance of ICP Licenses in China
&lt;/h3&gt;

&lt;p&gt;China's regulation of the internet is unique and stringent compared to many other countries. The requirement for an ICP License was established to ensure that the government could monitor and control the vast amount of content accessible online, maintaining social stability and protecting national security.&lt;/p&gt;

&lt;p&gt;The ICP licensing system was introduced as part of China's broader internet governance framework, which includes the Great Firewall — a combination of legislative actions and technologies enforced by the Chinese government to regulate the internet domestically. This system allows the government to block access to certain foreign websites, monitor internet traffic, and filter content that is deemed inappropriate or harmful.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why is an ICP License Important?
&lt;/h3&gt;

&lt;p&gt;For businesses, obtaining an ICP License is crucial for operating legally within China's digital landscape. Without this license, websites can be blocked or shut down by the authorities. This regulation helps the Chinese government maintain control over the information flowing within its borders and ensures that all online content aligns with national policies and standards.&lt;/p&gt;

&lt;p&gt;Internet Content Providers and the necessity of ICP Licenses in China highlights the intersection of technology, governance, and commerce in the digital age. For companies aiming to enter the Chinese market, navigating these regulations is essential for success and compliance. &lt;/p&gt;

&lt;p&gt;As the internet continues to evolve, the role and regulations of ICPs will likewise adapt and evolve, reflecting the dynamic nature of digital content and international relations.&lt;/p&gt;




&lt;p&gt;In practice, service providers aiming to do business in China must meticulously manage their traffic and networks to comply with local regulations. This involves optimizing their content delivery networks (CDNs) to ensure fast and reliable access for users within China. Providers often partner with local CDN providers to reduce latency and enhance performance.&lt;/p&gt;

&lt;p&gt;Additionally, they must implement robust data management practices to ensure that user data is stored within China's borders, adhering to data localization laws. Regular audits and updates to security protocols are necessary to safeguard against cyber threats and maintain compliance with China's cybersecurity laws. By effectively managing these aspects, service providers can operate smoothly and maintain a positive relationship with Chinese regulatory bodies.&lt;/p&gt;

</description>
      <category>networking</category>
      <category>china</category>
      <category>cdn</category>
      <category>internet</category>
    </item>
    <item>
      <title>What is IPVS?</title>
      <dc:creator>Sparky-code</dc:creator>
      <pubDate>Wed, 03 Apr 2024 00:11:05 +0000</pubDate>
      <link>https://forem.com/sparkycode/what-is-ipvs-1lm9</link>
      <guid>https://forem.com/sparkycode/what-is-ipvs-1lm9</guid>
      <description>&lt;p&gt;IPVS (Internet Protocol Virtual Server) is a high-performance load balancer included in the Linux kernel. It efficiently distributes network traffic across multiple servers, preventing bottlenecks and ensuring reliability. IPVS supports various load balancing algorithms, such as round-robin and least connections, and handles protocols like TCP, UDP, and SCTP. It's particularly suited for high-traffic environments, capable of managing tens of thousands of connections per second.&lt;/p&gt;

&lt;p&gt;A standard implementation of IPVS in an L4 (Layer 4) scenario involves setting up IPVS to manage TCP or UDP traffic. For example, consider a web server cluster with three servers. IPVS can be configured to distribute incoming HTTP requests (TCP protocol) among these servers using the least connections algorithm. This ensures that the server with the fewest active connections receives the next request, balancing the load and optimizing resource utilization.&lt;/p&gt;

&lt;p&gt;Overall, IPVS provides transparent, high-performance load balancing, seamlessly redirecting user requests to backend servers and integrating with other Linux networking components for added functionality.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>networking</category>
      <category>traffic</category>
    </item>
    <item>
      <title>Huffman Coding</title>
      <dc:creator>Sparky-code</dc:creator>
      <pubDate>Wed, 18 Oct 2023 23:25:48 +0000</pubDate>
      <link>https://forem.com/sparkycode/huffman-coding-5nd</link>
      <guid>https://forem.com/sparkycode/huffman-coding-5nd</guid>
      <description>&lt;h2&gt;
  
  
  Unraveling Complexity
&lt;/h2&gt;

&lt;p&gt;In the vast world of data compression, where every bit matters, &lt;a href="https://en.wikipedia.org/wiki/Huffman_coding"&gt;Huffman coding&lt;/a&gt; emerges as a valuable mechanic. This elegant algorithm, developed by David A. Huffman in 1952, has become a cornerstone in the realm of lossless data compression. &lt;/p&gt;

&lt;p&gt;Its brilliance lies in its &lt;em&gt;ability to assign variable-length codes to different characters&lt;/em&gt;, ensuring that more frequent characters receive shorter codes, ultimately reducing the overall size of the encoded data. Huffman coding is like a tailored wardrobe for your data, where each character gets a code that suits its frequency, creating a &lt;em&gt;compact and efficient representation.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Let's dive into this with a simple example. Consider the phrase "HUFFMAN".&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In standard ASCII encoding, each character would be represented by 8 bits. However, with Huffman coding, we can create a more compact representation. First, we calculate the frequency of each character: H (1), U (1), F (2), M (1), A (1), N (1). &lt;/p&gt;

&lt;p&gt;Now, we build a binary tree, merging the least frequent characters at each step. After constructing the tree, the codes are assigned: F (00), H (010), U (011), M (100), A (101), N (110). Encoding "HUFFMAN" using these codes results in the binary sequence 010011001010110, a significant compression from the original 8 bits per character.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now, let's explore a real-world application. Consider an image file where certain colors are more prevalent than others. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;By applying Huffman coding to represent these colors, we can significantly reduce the file size without compromising image quality. This compression technique is widely used in image formats like JPEG, showcasing how Huffman coding is not just a theoretical concept but a practical solution for optimizing data storage and transmission across various domains.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://medium.com/makepad/huffman-coding-compression-algorithm-d68b098f768b"&gt;Check out another article on this topic for a more visual description&lt;/a&gt;&lt;/p&gt;

</description>
      <category>datastructures</category>
      <category>algorithms</category>
      <category>codenewbie</category>
      <category>programming</category>
    </item>
    <item>
      <title>What is ACID?</title>
      <dc:creator>Sparky-code</dc:creator>
      <pubDate>Wed, 17 May 2023 00:28:57 +0000</pubDate>
      <link>https://forem.com/sparkycode/what-is-acid-4254</link>
      <guid>https://forem.com/sparkycode/what-is-acid-4254</guid>
      <description>&lt;p&gt;&lt;strong&gt;ACID&lt;/strong&gt; is an acronym that stands for Atomicity, Consistency, Isolation, and Durability. It is a set of properties that guarantee reliable and consistent transactions in a database management system. ACID ensures that a database transaction is processed in a reliable and predictable way, even in the presence of system failures or concurrent access by multiple users.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Atomicity&lt;/strong&gt; means the property of a transaction is treated as a single, indivisible unit of work. It means that either all the operations in the transaction are completed successfully, or none of them are. If any operation in the transaction fails, the entire transaction is rolled back, and the database is left in its original state.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Consistency&lt;/strong&gt; means that a transaction brings the database from one valid state to another valid state. This means that the transaction should preserve the integrity of the data and ensure that all constraints, rules, and relationships are maintained throughout the transaction.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Isolation&lt;/strong&gt; means that multiple transactions can execute concurrently without interfering with each other. Each transaction must be executed as if it is the only transaction being executed at that moment. This is achieved through a variety of concurrency control techniques, such as locking and transaction isolation levels.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Durability&lt;/strong&gt; means that once a transaction has been committed, its changes are permanent and will survive any subsequent system failures, such as power outages or hardware failures. This is achieved through techniques such as write-ahead logging and transaction checkpoints.&lt;/p&gt;

&lt;p&gt;By providing &lt;strong&gt;atomicity&lt;/strong&gt;, &lt;strong&gt;consistency&lt;/strong&gt;, &lt;strong&gt;isolation&lt;/strong&gt;, and &lt;strong&gt;durability&lt;/strong&gt;, ACID transactions guarantee that the database will be left in a valid and reliable state, even when things don't go according to plan.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>What are IPv4 &amp; IPv6?</title>
      <dc:creator>Sparky-code</dc:creator>
      <pubDate>Thu, 11 May 2023 19:12:19 +0000</pubDate>
      <link>https://forem.com/sparkycode/what-are-ipv4-ipv6-epi</link>
      <guid>https://forem.com/sparkycode/what-are-ipv4-ipv6-epi</guid>
      <description>&lt;p&gt;&lt;strong&gt;IP, or Internet Protocol&lt;/strong&gt;, is a set of rules that enables devices to communicate with each other over the internet. &lt;em&gt;An IP address is a unique identifier assigned to each device connected to the internet&lt;/em&gt;, similar to a phone number or a street address.&lt;/p&gt;

&lt;p&gt;IP addresses are essential components in computer networking that enable devices to communicate over the internet. There are two types of IP addresses: IPv4 and IPv6. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;IPv4&lt;/strong&gt; is the older of the two and  consists of &lt;strong&gt;32 bits&lt;/strong&gt; represented by four numbers separated by dots (e.g., 192.168.0.1). &lt;/p&gt;

&lt;p&gt;This allows for a total of around &lt;em&gt;4.3 billion unique IP addresses&lt;/em&gt;. As the number of internet-connected devices continues to grow, IPv4 addresses are becoming insufficient.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;IPv6&lt;/strong&gt; was introduced in response to this. IPv6 addresses use &lt;strong&gt;128 bits&lt;/strong&gt; represented by &lt;em&gt;eight groups of four hexadecimal digits&lt;/em&gt; separated by colons (e.g., 2001:0db8:85a3:0000:0000:8a2e:0370:7334). &lt;/p&gt;

&lt;p&gt;This offers a staggering &lt;em&gt;340 undecillion unique IP addresses&lt;/em&gt;, ensuring that every device on earth can have trillions of unique IP addresses. Although the adoption of IPv6 has been slow, its importance in providing sufficient IP addresses to accommodate the increasing number of internet-connected devices cannot be overstated.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/sparkycode/what-is-cidr-139f"&gt;CIDR, or Classless Inter-Domain Routing&lt;/a&gt;, is a complimentary mechanism that allows network administrators to allocate IP addresses more efficiently. It enables the creation of smaller subnetworks, reducing the number of unique IP addresses required to connect devices to the internet. By using CIDR, network administrators can effectively manage IP address allocation, reducing the number of unused or wasted IP addresses.&lt;/p&gt;

&lt;p&gt;IPv6 is becoming increasingly necessary due to the limitation of IPv4 in providing enough unique IP addresses for the growing number of internet-connected devices. CIDR is a valuable mechanism that can be used in managing IP address allocation, ensuring efficient use of IP addresses.&lt;/p&gt;

&lt;p&gt;What is your IP address? &lt;a href="https://whatismyipaddress.com/"&gt;Find out here&lt;/a&gt;&lt;br&gt;
Fing is a great tool (&lt;a href="https://play.google.com/store/apps/details?id=com.overlook.android.fing&amp;amp;hl=en_US&amp;amp;gl=US&amp;amp;pli=1"&gt;Android&lt;/a&gt;, &lt;a href="https://apps.apple.com/us/app/fing-network-scanner/id430921107"&gt;Apple&lt;/a&gt;) to learn more about your home network and the conversations happening across it.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>sre</category>
      <category>networking</category>
    </item>
    <item>
      <title>What is Data?</title>
      <dc:creator>Sparky-code</dc:creator>
      <pubDate>Tue, 09 May 2023 22:47:48 +0000</pubDate>
      <link>https://forem.com/sparkycode/what-is-data-1a23</link>
      <guid>https://forem.com/sparkycode/what-is-data-1a23</guid>
      <description>&lt;p&gt;There are three categories of data: structured, semi-structured, and unstructured. Each type of data has its own characteristics and use cases, understanding the differences between them is crucial for effective data management and analysis.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Structured data&lt;/strong&gt; is organized and easily searchable. It is typically stored in &lt;em&gt;relational databases&lt;/em&gt;, and its format is well-defined with pre-determined columns, data types, and relationships. &lt;/p&gt;

&lt;p&gt;Examples include data from &lt;em&gt;enterprise resource planning (ERP) systems&lt;/em&gt;, &lt;em&gt;customer relationship management (CRM) databases&lt;/em&gt;, and &lt;em&gt;financial records&lt;/em&gt;. Structured data can be easily queried and analyzed using &lt;strong&gt;SQL&lt;/strong&gt; and other database tools. An example of Structured Data:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import sqlite3

# Connect to the database
conn = sqlite3.connect('example.db')

# Create a table with structured data
conn.execute('''CREATE TABLE employees
             (id INT PRIMARY KEY NOT NULL,
             name TEXT NOT NULL,
             age INT NOT NULL);''')

# Insert data into the table
conn.execute("INSERT INTO employees (id, name, age) VALUES (1, 'John Doe', 25)")
conn.execute("INSERT INTO employees (id, name, age) VALUES (2, 'Jane Smith', 30)")

# Query the data from the table
cursor = conn.execute("SELECT * FROM employees")
for row in cursor:
    print("ID = ", row[0])
    print("Name = ", row[1])
    print("Age = ", row[2])

# Close the database connection
conn.close()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;A structured database table with pre-defined columns for id, name, and age. We insert data into the table and query it using SQL.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;&lt;strong&gt;Semi-structured data&lt;/strong&gt; falls somewhere between structured and unstructured data. It has a defined structure, but it's not as rigid as structured data. &lt;/p&gt;

&lt;p&gt;Semi-structured data &lt;em&gt;often includes metadata and tags&lt;/em&gt; that provide additional context. Examples include &lt;strong&gt;XML&lt;/strong&gt; and &lt;strong&gt;JSON&lt;/strong&gt; files, which are commonly used to exchange data between web applications.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import json

# Define a JSON object with semi-structured data
employee = {
  "id": 1,
  "name": "John Doe",
  "age": 25,
  "department": {
    "name": "Engineering",
    "manager": "Jane Smith"
  }
}

# Convert the JSON object to a string
employee_json = json.dumps(employee)

# Print the JSON string
print(employee_json)

# Convert the JSON string back to a Python object
employee_dict = json.loads(employee_json)

# Access the data in the Python object
print(employee_dict['id'])
print(employee_dict['name'])
print(employee_dict['age'])
print(employee_dict['department']['name'])
print(employee_dict['department']['manager'])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;we define a JSON object with semi-structured data that includes a nested department object. We convert the object to a JSON string and back to a Python object, accessing the data using dictionary keys.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;&lt;strong&gt;Unstructured data lacks any predefined structure&lt;/strong&gt;. It's the most challenging type of data to work with because &lt;em&gt;it includes text, images, and multimedia files&lt;/em&gt; that don't fit neatly into a database schema.&lt;/p&gt;

&lt;p&gt;Examples include emails, social media posts, images, and videos. Unstructured data can be challenging to analyze using traditional data analysis tools, but advancements in natural language processing &lt;a href="https://www.ibm.com/topics/natural-language-processing"&gt;NLP&lt;/a&gt; and machine learning algorithms are making it easier to derive insights from unstructured data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import pytesseract
from PIL import Image

# Open an image file with unstructured data
image = Image.open('example.png')

# Use Tesseract OCR to extract text from the image
text = pytesseract.image_to_string(image)

# Print the extracted text
print(text)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;we open an image file with unstructured data and use Tesseract OCR to extract text from the image. The extracted text doesn't have a pre-defined structure and is challenging to analyze without advanced NLP techniques.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;Each datatype have their unique characteristics and uses. Programmers and organizations can better manage and analyze their data by understanding the usecases, costs and benefits of each datatype, leading to more informed decision-making and better business outcomes. &lt;/p&gt;

&lt;p&gt;A great resource to explore for learning about working with within the Azure ecosystem is the &lt;a href="https://learn.microsoft.com/en-us/certifications/azure-data-fundamentals/"&gt;Microsoft Certificate: Azure Data fundamentals&lt;/a&gt;. It looks like this course is even &lt;a href="https://techcommunity.microsoft.com/t5/educator-developer-blog/how-to-get-a-microsoft-certification-for-free-as-a-student/ba-p/3584897"&gt;freely available for students&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Something I happened across today to add context to how the industry is thinking about data and datatypes in &lt;a href="https://a16z.simplecast.com/episodes/from-promise-to-reality-inside-a16zs-data-and-ai-forum"&gt;the ongoing conversation around AI&lt;/a&gt;&lt;/p&gt;

</description>
      <category>database</category>
      <category>data</category>
      <category>sre</category>
      <category>programming</category>
    </item>
    <item>
      <title>What is CIDR?</title>
      <dc:creator>Sparky-code</dc:creator>
      <pubDate>Wed, 26 Apr 2023 19:09:25 +0000</pubDate>
      <link>https://forem.com/sparkycode/what-is-cidr-139f</link>
      <guid>https://forem.com/sparkycode/what-is-cidr-139f</guid>
      <description>&lt;p&gt;CIDR (Classless Inter-Domain Routing) is a method of assigning &lt;a href="https://dev.to/sparkycode/what-are-ipv4-ipv6-epi"&gt;IP addresses&lt;/a&gt; that allows for more efficient use of available address space. In the past, IP addresses were assigned using one of three classes: Class A, Class B, or Class C. These classes were determined by the first few bits of the IP address, and each class had a fixed number of network and host bits.&lt;/p&gt;

&lt;p&gt;CIDR, on the other hand, does away with the concept of classes altogether. Instead, CIDR assigns IP addresses using a notation that specifies both the network address and the number of significant bits in the host address. For example, the CIDR notation 192.168.0.0/24 indicates that the first 24 bits of the IP address (corresponding to the first three octets) represent the network portion of the address, while the last 8 bits represent the host portion.&lt;/p&gt;

&lt;p&gt;CIDR allows for more flexible use of available address space because it allows for variable-length subnet masks. In other words, instead of being limited to the fixed network and host bits defined by a classful IP address, CIDR allows for any number of bits to be used for the network portion of the address. This means that networks can be subdivided into smaller subnets, which can be more efficiently allocated to different devices or users.&lt;/p&gt;

&lt;p&gt;CIDR has become the standard method for IP address assignment on the Internet, as it allows for more efficient use of available address space and better scalability. It has also simplified network management by allowing for more flexible subnetting and easier route aggregation. However, CIDR does require more careful planning and configuration than classful addressing, as assigning incorrect subnet masks can lead to routing issues and other problems.&lt;/p&gt;

&lt;p&gt;Sounds simple right? I added a couple of examples to illustrate this in practice.&lt;/p&gt;

&lt;p&gt;Example 1: Suppose an organization has been allocated the IP address range 10.0.0.0/8. This means that the first 8 bits of the IP address (i.e., the first octet) represent the network portion of the address, while the remaining 24 bits represent the host portion. This organization can then subdivide this address space into smaller subnets using a subnet mask of their choice. For example, they might use the subnet 10.1.0.0/16 to represent a subnet with 16 bits of network address and 16 bits of host address, allowing for up to 65,534 hosts on this subnet.&lt;/p&gt;

&lt;p&gt;Example 2: An Internet Service Provider (ISP) might be assigned the IP address range 200.100.50.0/22. This means that the first 22 bits of the IP address (i.e., the first three octets and the first 2 bits of the fourth octet) represent the network portion of the address, while the remaining 10 bits represent the host portion. The ISP can then allocate portions of this address space to their customers, using a smaller subnet mask to divide the address space further. For example, they might allocate the subnet 200.100.52.0/23 to a customer, allowing for up to 510 hosts on this subnet.&lt;/p&gt;






&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import ipaddress

# Allocate a /24 network address to a department with 10 devices
network_address = ipaddress.IPv4Network('192.168.1.0/24')
department_subnet = network_address.subnets(prefixlen_diff=3)

# Allocate a /27 subnet address to the department
department_address = next(department_subnet)
print(department_address)

# Allocate unique IP addresses to each device in the department
devices = [ipaddress.IPv4Address(str(department_address.network_address + i)) for i in range(10)]
print(devices)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;A basic example of how you might script this process&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>subnetting</category>
      <category>networkmanagement</category>
      <category>scalability</category>
      <category>sre</category>
    </item>
    <item>
      <title>What is pkill?</title>
      <dc:creator>Sparky-code</dc:creator>
      <pubDate>Tue, 25 Apr 2023 16:24:23 +0000</pubDate>
      <link>https://forem.com/sparkycode/what-is-pkill-48bd</link>
      <guid>https://forem.com/sparkycode/what-is-pkill-48bd</guid>
      <description>&lt;p&gt;The &lt;code&gt;pkill&lt;/code&gt; command is a command-line utility that is used to terminate processes on Unix or Linux systems. It is an extremely powerful and efficient tool for system administrators and users alike. &lt;/p&gt;

&lt;p&gt;It allows them to quickly and easily terminate processes by name, ID, or attribute, send different signals to processes, and search for processes based on their attributes. A must-have tool for system administration and working with Unix or Linux systems.&lt;/p&gt;

&lt;p&gt;One of the most common uses of the &lt;code&gt;pkill&lt;/code&gt; command is to terminate processes by name. Enter the command + the name of the process to terminate. For example, if you want to terminate a process named ‘firefox’, you would enter&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pkill firefox&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You can also use wildcards to match processes with similar names. E.g. For all processes with names starting with “chrome”.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pkill -f "chrome*"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The ‘pkill’ command also allows you to send different signals to processes, including &lt;code&gt;SIGTERM&lt;/code&gt; (default), &lt;code&gt;SIGKILL&lt;/code&gt;, or &lt;code&gt;SIGINT&lt;/code&gt;. The &lt;code&gt;SIGTERM&lt;/code&gt; signal requests that the process terminate gracefully, while the &lt;code&gt;SIGKILL&lt;/code&gt; and &lt;code&gt;SIGINT&lt;/code&gt; signals force the process to terminate immediately.&lt;/p&gt;

&lt;p&gt;You can search for processes based on attributes. Search for processes running as a particular user, by specifying the user's name as a parameter.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pkill -U username&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You can terminate processes based on their CPU usage. E.g. To terminate the process owned by the specified user that has the highest CPU usage.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pkill -u username -o %cpu -n 1&lt;/code&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`-u` specifies the username of the user whose processes you want to terminate.
`-o %cpu` orders the processes by their CPU usage, with the highest usage first.
`-n 1` specifies that only the process with the highest CPU usage should be terminated. The '-n' flag takes a numerical value for how many processes should be terminated. In this case, only the process with the highest CPU usage (i.e., the one with the rank of '1') will be terminated.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;For more details on signals and defaults: &lt;a href="https://linuxize.com/post/pkill-command-in-linux/"&gt;Check this out&lt;/a&gt;&lt;/p&gt;

</description>
      <category>unix</category>
      <category>security</category>
      <category>sre</category>
      <category>systemsdministration</category>
    </item>
    <item>
      <title>What is Chmod?</title>
      <dc:creator>Sparky-code</dc:creator>
      <pubDate>Wed, 19 Apr 2023 18:00:12 +0000</pubDate>
      <link>https://forem.com/sparkycode/what-is-chmod-54p7</link>
      <guid>https://forem.com/sparkycode/what-is-chmod-54p7</guid>
      <description>&lt;p&gt;chmod is a command-line utility that enables users to change the access permissions of files and directories on Unix-based systems. Unix file permissions model includes &lt;em&gt;read&lt;/em&gt;, &lt;em&gt;write&lt;/em&gt;, and &lt;em&gt;execute permissions&lt;/em&gt;, and these permissions can be granted or denied to three categories of users, namely the &lt;em&gt;owner of the file&lt;/em&gt;, the &lt;em&gt;owner's group&lt;/em&gt;, and all &lt;em&gt;other users&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;To use &lt;code&gt;chmod&lt;/code&gt;, users can specify the permissions they want to change, the user category they want to change, and the file or directory they want to modify. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;chmod [options] mode file&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Here, mode represents the permissions you want to set, and file represents the file or directory you want to modify. The options can be used to specify additional settings, such as recursive mode for modifying permissions of all files and subdirectories under a given directory.&lt;/p&gt;

&lt;p&gt;For example, to grant the owner of a file read, write, and execute permissions while denying all other users any permissions, one can use the following command: &lt;code&gt;chmod 700 filename&lt;/code&gt;. This sets the file permissions to &lt;code&gt;rwx------&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;7&lt;/code&gt; in &lt;code&gt;700&lt;/code&gt; represents the owner's permissions, which are read, write, and execute (rwx). The &lt;code&gt;0&lt;/code&gt; represents the permissions for the group and all other users, which are none.&lt;/p&gt;

&lt;p&gt;Using &lt;code&gt;chmod&lt;/code&gt; requires caution as changing permissions incorrectly can compromise system security and data loss. It is crucial to have a good understanding of file permissions and associated risks. &lt;code&gt;Chmod&lt;/code&gt; helps maintain data security and streamline file management by restricting unauthorized access to files and directories. It is a powerful tool for managing file permissions on Unix-based systems, and using it effectively can help maintain data security and integrity.&lt;/p&gt;

</description>
      <category>unix</category>
      <category>security</category>
      <category>permissions</category>
      <category>sre</category>
    </item>
    <item>
      <title>Adventures in SRE.Land</title>
      <dc:creator>Sparky-code</dc:creator>
      <pubDate>Fri, 07 Apr 2023 23:22:34 +0000</pubDate>
      <link>https://forem.com/sparkycode/adventures-in-sreland-380m</link>
      <guid>https://forem.com/sparkycode/adventures-in-sreland-380m</guid>
      <description>&lt;p&gt;Learning to learn the things I didn't know I needed to learn.&lt;br&gt;
I'm a early-career SRE. I was inspired to get into this field by a fascination with the environments around me and building tools to understand an ever changing world. &lt;/p&gt;

&lt;p&gt;Through the course of my first job I've tried to track tools, technologies and concepts that I've come across that are key to being successful in my role. I wanted to break down these ad hoc notes into something more digestible that would serve as many of my favorite resources do, to be 'the resource I wish I had when I was learning this'. I hope you find this to be an accurate description as these posts come out and welcome feedback and insights from your own experiences. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;commit -m&lt;/code&gt;&lt;/p&gt;

</description>
      <category>sre</category>
      <category>engineer</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
