teleren/devto huggingface dataset:
How to Build a RegEx Engine in Python (Part 5: Parser conclusion)
Tags: programming, python, regex, tutorial
Published: 2022-12-12 23:17:38

In this article, we’ll dig rapidly through the code of the parser, which will produce the AST we discussed in the previous article in output.

This will hopefully be the last piece about the parser, and then we’ll move on to the engine and the juicy part, the backtracking system.

So, the parser is contained in the Pyrser class, as we already saw in Part 3, which has the method parse, that takes as input a regular expression in the form of a string, and gives us the corresponding AST in output.

## Pyrser structure
![`Pyrser` structure.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tq93hon22kg3hy8bchai.png)
> `Pyrser` structure.

We already spoke about the various functions and what is their purpose in previous articles.  
Now we will look closer to the code of some of them. I will not explain what each line does, this isn’t the purpose of this series of articles, but I will rather express some final thoughts after.  
If you’re not super interested in the code, feel free to skip reading through it.

### Parse Regex Sequence
![`parse_re_seq` code.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fr37zvwlbnygqklg7d4t.png)
> `parse_re_seq` code.

### Parse Group
![`parse_group` code.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/afa3lcrkctuchlezvjpp.png)
> `parse_group` code.

### Parse Element
![`parse_el` code.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lih3843aceojmy7ahali.png)
> `parse_el` code.

## Final Words

In conclusion, the parser was not as hard to code as hard to debug.  
When I first coded it I did it quickly and without having a perfectly clear idea in mind of what I wanted in output.

In fact, the  `parse_re`  function is indeed a leftover of an error:

-   in the beginning, the  `^`  and  `$`  symbols were meant to be “absolute”, meaning that once typed, they would have been applied to every single regex in the sequence
-   This meant that a regex such as `^a|b$` returned false on test string `cb`, while it should return true because that `b` must be at the beginning isn’t specified in the second regex, but this original implementation maintained the “match start” from the other one
-   This happened because at the beginning I thought that should be the “right” behavior, and I created the RE node of the AST just for this purpose.

I later realized that this behavior was confusing and didn’t make any sense, so I had to figure out a way to change it, possibly maintaining the RE node, because the engine was already coded and using it.

In the end,  `parse_re`  remained, completely emptied of any behavior, useless, for the sake of compatibility with the — already working — engine.

Apart from this, the parser and the AST does a really good job overall, and coding a TDRDP parser isn’t so hard once you figured out a good grammar, which is no joke for non-trivial projects.
The way Pause doesn't index files.
Published: 2022-12-12 23:09:36

The way Pause doesn't index files.

## Using no_index

```
no_index => {
  file      => [ 'My/Module.pm' ],
  directory => [ 'My/Private' ],
  package   => [ 'My::Module::Secret' ],
  namespace => [ 'My::Module::Sample' ],
}
```

## Putting files into inc, t, xt directories.

```
inc
t
xt
```

## See also

See the following documents.

<a href="https://metacpan.org/pod/CPAN::Meta::Spec#no_index">CPAN::Meta::Spec - no_index</a>

<a href="https://metacpan.org/pod/CPAN::Meta::Spec#Indexing-distributions-a-la-PAUSE">CPAN::Meta::Spec - Indexing distributions a la PAUSE</a>

## Note

<a href="https://pause.perl.org/">Pause</a> is the site to upload Perl distributions to CPAN.
Day 661 : This Year
Tags: hiphop, code, coding, lifelongdev
Published: 2022-12-12 22:58:44

_liner notes_:
- Saturday : Got some pretty bad news on Friday. Heard that a person I've seen around the Orlando HIPHOP scene and known for over 10 years passed away. So we a tribute show to them and played a bunch of their tracks. The recording of this week's show is at https://kNOwBETTERHIPHOP.com

![Radio show episode image of a flyer for Donations to the family of Crescendo with a black and white profile picture of him with the words Dec 10th 2022 RIP Crescendo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cshaffpgw1q2ti98e5zp.jpg)

- Sunday : Did my study sessions at https://untilit.works Worked on the final part my latest side project. Got it working, did my laundry and cut my hair.

- Professional : Today is the first day back off work. Mostly spent the day to catch up and work on some things.

- Personal : So I launched my latest side project https://WhatsThat.in. Posted it up on Twitter and got some good feedback. Got to speak with some folks from companies that I used to make the project and got some interesting things to try out.

![Ridgway, CO, United States landscape with tall trees with yellow and green leaves on hills with snow capped mountains in the distance](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/peycz4kjrceffym6oz6o.jpg)

Going to try and implement the suggestion that someone from a company I used for my latest project. The way I did it works, but I would like it to work better. haha Also going to watch the new episode of "Bleach". I saw it was trending on Twitter. haha. Can't believe that this year is almost over!

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube xiDnuRylHMU %}
AZ-400: Plan work flow and feedback cycles
Published: 2022-12-12 22:45:16

[Choose a process flow or process template to work in Azure Boards](https://learn.microsoft.com/en-us/azure/devops/boards/work-items/guidance/choose-process?view=azure-devops&tabs=agile-process)

**[Waterfall Development](https://kruschecompany.com/waterfall-software-development-methodology)**

1. Requirements analysis
2. Design
3. Coding/Implementation
4. Testing
5. Deployment
6. Maintenance

- Slow to offer feedback, as the solution may not be developed until weeks, months, or even years after the requirements analysis

**[Agile Development](https://kruschecompany.com/agile-software-development/)**

- Compresses the steps of waterfall development into shorter bursts (typically "sprints") with a focus on smaller changes with more rapid feedback and iteration

**CI/CD**

- Continuous integration/continuous deployment
- Making frequent, small, reversible changes to code
- Automating build, test, and deployment steps

**Source Control**
- Useful for tracking changes to code
- Also referred to as version control
- Facilitates collaboration on projects, particularly large-scale projects with many developers

**General Best Practices**
- Commit code changes early and often to keep them small
- Automate code checks, builds, tests, and deployments as much as possible
- Continuously monitor application health and performance through various tools and metrics 
- Set up monitoring alerts and automate triage when possible
Tips and Tricks to style your React App
Tags: react, beginners, css, tutorial
Published: 2022-12-12 21:13:13

Styling your project is one of the most difficult things to do especially when you are just starting in your career and want to build a nice portfolio.

Here you will find some tips and tricks that can help you to build a project that looks professional.

**1. Define the **

Colors: primary and secondary colors, typography layout on colored backgrounds, primary colors for highlights, link and button colors, etc.
Typography: the size of the main titles (H1-H5), the size of the body text, quotes, spacing between titles and body text, typography color and background colors where the text can appear.
Grid: determining the spacing inside the elements, styles.
Graphics: drawing the key icons that will represent the main content. The color of icons and graphics.
Ephemeral Containers
Tags: kubernetes, devops, ephemeral, distroless
Published: 2022-12-12 21:12:00

In this blog I want to talk about ephemeral containers.

Ephemeral containers: a special type of container that runs temporarily in an existing Pod to accomplish user-initiated actions such as troubleshooting. You use ephemeral containers to inspect services rather than to build applications.

Ephemeral containers are useful for debugging and for interactive troubleshooting when kubectl exec is insufficient because a container has crashed or a container image doesn't include debugging utilities.

Ephemeral containers share process namespaces and resources with the pod. They are especially useful for lightweight distroless containers.

Ephemeral container: 

- live until exit
- never auto restarts
- does not have ports, livenessProbe, readinessProbe
- immutable - resources setting not allowed

Deploy PostgreSQL in Kubernetes:

[See my blog](https://dev.to/dm8ry/how-to-deploy-postgresql-db-server-and-pgadmin-in-kubernetes-a-how-to-guide-5fm0)

Make sure the PostgreSQL pod is running:

```
kubectl get pods
NAME                        READY   STATUS    RESTARTS       AGE
postgres-5c7d8b656d-xj5b2   1/1     Running   1 (7m2s ago)   45h
```

Get container name(s), image for each pod in the k8s cluster:

```
kubectl get pods -o=custom-columns=PodName:.metadata.name,Containers:.spec.containers[*].name,Image:.spec.containers[*].image

PodName                     Containers                  Image
postgres-5c7d8b656d-xj5b2   postgres                    postgres:latest
```

Here is example how to run ephemeral container with a busybox shell to debug our pod postgres-5c7d8b656d-xj5b

```
kubectl debug -it postgres-5c7d8b656d-xj5b2 --image=busybox --target=postgres
```

This command adds a new busybox container and attaches to it. The --target parameter targets the process namespace of another container. 

Now we can see processes from the “original” pod that are sharing the same namespace.

```
/ # ps aux
PID   USER     TIME  COMMAND
    1 999       0:00 postgres
   26 999       0:00 postgres: checkpointer
   27 999       0:00 postgres: background writer
   29 999       0:00 postgres: walwriter
   30 999       0:00 postgres: autovacuum launcher
   31 999       0:00 postgres: logical replication launcher
   46 root      0:00 sh
   52 root      0:00 ps aux
   …
```

The ephemeral container is running in the same network context as the “original” container. It allows us to inspect what is going on inside of this pod from its network perspective, run ping, etc.

```
/ # ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: seq=0 ttl=114 time=16.472 ms
64 bytes from 8.8.8.8: seq=1 ttl=114 time=16.484 ms
…
```

Here is example how to run ephemeral container with a ubuntu injected to debug our pod postgres-5c7d8b656d-xj5b

```
kubectl debug -it postgres-5c7d8b656d-xj5b2 --image=ubuntu --target=postgres

apt-get update

apt-get install -y tcpdump
```
Build own Kubernetes  - Mid Sum up
Tags: kubernetes, go, linux, programming
Published: 2022-12-12 20:58:13

In this post, I will go into what we implemented so far from an architectural design perspective, how Kubernetes actually works from the inside and what will do going forward. 

---
## What we have done so far?

So Until this point, we implemented a basic creation of pods, nodes, services, and inner and outer networks of the nodes.
The flow is as followed:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6115rqm9mb28rm9qj0kx.png)

So the client with the own-kubernetes CLI creates a node, and the node is created with Docker. Then the client sends an HTTP request to the IP and port of the node to create a pod and with that all of its networking.

---
## How Kubernetes works from the inside?
So in Kubernetes, the design is that the master node (in our case our environment) has an etcd DB which is a key-value DB that is the source of truth of the cluster, and every interaction with the etcd is with the Kubernetes API.
The following flow is taken from the book Kubernetes in Action by Marko Luksa, highly recommended for anyone that wants to learn everything about Kubernetes and its inside:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lt9fmvt4zbbpu6b3knpp.png)

So the way Kubernetes works is as the chart above, let's say we want to create a single Pod:
the kubectl makes a request to the Kubernetes API (usually some kubectl apply)
1. the API server saves the new pod spec in etcd
2. the scheduler gets a notification for a new Pod addition to the etcd without node assign and assigns a new node (with some decision conditions I will not get into)
3. the kubelet inside the node it was assigned to is getting a notification and creating the new pod.

There is also a another component that called controller manager, used to get the actual state of a resource to the desired state, usely update and delete resource and get also notification for every etcd change.

---
## What we will do next?
So Kubernetes design is parted into components that avoid coupling, whereas our design is highly coupled and moving forward will probably be a monolith.
Our design will stay that way, we store the created resources in the etcd, but we will not work as decoupled components that are getting notifications, because I want this series to focus on getting a POC of minimal functionality of a working Kubernetes.
It was important to me to make this article before we move forward for you to realize the design we are doing is not a match to the Kubernetes design (but can be with extra work).
5 projects to learn Spring Boot as a Beginner
Tags: java, beginners
Published: 2022-12-12 20:38:48

Are you a budding coder interested in learning the beloved Spring Boot? It’s a great idea to learn the popular framework that is used by many large enterprises today. It’s a particularly useful framework for Java developers and can help you create stand-alone applications quickly and easily.

If you’re a beginner to Spring Boot, there are some great projects that you can take on to help you become more familiar with the framework. Here are five great projects to get you started:

**1. Create a Simple Spring Boot Application.** This is a great project for beginners to start with as it will help you get familiar with the basics of the framework. You’ll be able to learn the basics such as setting up a web application, configuring databases and more.

**2. Build a RESTful Web Service.** This project will teach you how to create a web service using the Spring Boot framework. You’ll learn how to define endpoints and how to communicate with them using the HTTP protocol.

**3. Work with Spring Boot Security.** This project will help you learn how to secure your application using Spring Boot. You’ll learn how to configure authentication and authorization, as well as how to use Spring Security to protect your application.

**4. Create a Spring Boot Microservice.** This project will introduce you to the world of microservices and how to use them in your application. You’ll learn how to build a simple microservice using the Spring Boot framework, as well as how to deploy it to a cloud provider.

**5. Build an Event-Driven Application.** This project will teach you the basics of event-driven architecture and how to use it with Spring Boot. You’ll learn how to create an event-driven application that can respond to events and take appropriate actions.

These five projects are great for getting started with Spring Boot. They will help you become more familiar with the framework and get you ready to start building real-world applications with it. Good luck on your coding journey!
Client-side image compression with Firebase and Compressor.js
Tags: firebase, webdev, javascript, compression
Published: 2022-12-12 20:37:13

- This article is an inspiration from [Client-side image compression with Supabase Storage](https://dev.to/mikeesto/client-side-image-compression-with-supabase-storage-1193) by **Michael Esteban**


To upload an image to Firebase using compressor.js, you can use the following steps:

1. Install the compressor.js library using npm: npm install compressor.js.

2. Import the library in your JavaScript file: import compressor from 'compressor.js';.

3. Use the compressor object to compress the image file. For example:

```js
const fileInput = document.getElementById('file-input');
const file = fileInput.files[0];

compressor.compress(file, options).then((compressedFile) => {
  // The image is now compressed and ready for upload.  
  // step 4 code here.
});
```
4. Use the Firebase Storage API to upload the compressed image to your Firebase project. You will need to provide your Firebase project's storage bucket URL and a reference to the file you want to upload. For example:

```js
// Get a reference to the storage service, which is used to create references in your storage bucket
// Create a storage reference from our storage service
const storageRef = firebase.storage().ref();
// Create a reference to the file we want to upload
const fileRef = storageRef.child('images/my-image.jpg');

// Use the `put` method to upload the file to Firebase
fileRef.put(compressedFile).then((snapshot) => {
  // The image has been successfully uploaded to Firebase.
  console.log('Uploaded a file!');
});
```

In this example, '_compressedFile_' is the file that you want to upload to Firebase. This code will upload the file to the images directory in your Firebase storage bucket.
How did you find your niche in tech?
Tags: discuss
Published: 2022-12-12 20:18:29

There are a lot of specialties working in technology. When I was in my coding bootcamp we learned a lot of things really fast. I figured that once I got a job, I would be able to focus on fewer tools and get better with them. That hasn't happened yet and I'm not sure how to go about finding where I fit and can grow in tech.
How to use the Pandas library in Python
Tags: python, programming, beginners
Published: 2022-12-12 20:10:47

Pandas is a popular Python library for data manipulation and analysis. It is built on top of the NumPy library and provides easy-to-use data structures and data analysis tools for working with numerical, tabular, and time series data.

Here are some examples of how to use the Pandas library in Python:

- Import the Pandas library:

```
import pandas as pd
```
- Read a CSV file into a Pandas DataFrame:

```
df = pd.read_csv("data.csv")
```
- View the first few rows of the DataFrame:

```
df.head()
```
- Select a column from the DataFrame:

```
df["column_name"]
```
- Filter the DataFrame to only include rows with certain values in a column:

```
df[df["column_name"] == "value"]
```
- Calculate the mean of a column:

```
df["column_name"].mean()
```
- Plot the values in a column using matplotlib:

```
import matplotlib.pyplot as plt

plt.plot(df["column_name"])
plt.show()
```

These are just a few examples of how to use Pandas for data manipulation and analysis. For more information, you can refer to the Pandas documentation: 

[Link](https://pandas.pydata.org/docs/)
What is the difference between http1 and http2 ?
Tags: http, webdev
Published: 2022-12-12 19:57:39

**What is the difference between HTTP and HTTP2?**

To answer this question. First, we need to know the relationship between http and tcp protocol. 

TCP manages the data stream, whereas HTTP describes what the data in the stream contains. So that means that we need to establish a new tcp connection between our browser and the destination web-server each time we want to perform a HTTP request.

**So what is the problem with that?**

The problem is that each browser has a limited number of connections to a server ( 6-10 connections based on the browser ) and doing a new request over one of those connections has to wait for the ones to complete before it can fire it off.

And here, HTTP/2 appears trying to find a solution for HOL blocking by  introducing multiplexing (It does that by tagging each request) so that you can issue new requests over the same connection without having to wait for the previous ones to complete. 

HTTP/2 does however still suffer from another kind of HOL, namely on the TCP level. One lost packet in the TCP stream makes all streams wait until that packet is re-transmitted and received. This HOL is being addressed with the QUIC protocol.

**What is QUIC?**

QUIC is a "TCP-like" protocol implemented over UDP where each stream is independent so that a lost packet only halts the particular stream to which the lost packet belongs, while the other streams can go on.

HTTP/3 is being done over QUIC instead of TCP and TLS.
Freelance Work. What to do?
Tags: career, codenewbie, programming, productivity
Published: 2022-12-12 19:57:36

I am a 20 something year old South African male. I'm down in the dumps. Stuck in a country that doesn't give enough entry work for newly graduated people like myself. Remote work itself is difficult when you come from a country like mine because of loadshedding (Google for more info💀). 

To sum all of that up, it isn't sunshine and roses for people from my neck of the woods. I want to change that. I want myself and people like to stop having to struggle. And I'm going to need all your help to circumvent all the unnecessary hurdles.

What're your most recommended tips and advice to becoming a full-fledged and independent freelance developer? What advice would you give for someone who is starting out? Which sites work best for remote work? In all aspects of code. From Web development, to bot development, to data science. 

Thank you for your participation and know that you're helping so many people❤️
How to build a basic face detector using Python
Tags: python, beginners, opensource
Published: 2022-12-12 19:37:54

To build a basic face detector using python, you can use a pre-trained Haar cascade classifier. A Haar cascade classifier is a machine learning object detection algorithm used to identify objects in images or video. It is trained to detect specific features, such as faces, in an image.

Here is an example of how to use a pre-trained Haar cascade classifier to detect faces in an image using the OpenCV library in python:

```
import cv2

# Load the Haar cascade classifier
classifier = cv2.CascadeClassifier("haarcascade_frontalface_default.xml")

# Load the input image
image = cv2.imread("input.jpg")

# Convert the image to grayscale
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

# Detect faces in the grayscale image
faces = classifier.detectMultiScale(gray_image)

# Loop through the detected faces
for (x, y, w, h) in faces:
    # Draw a rectangle around the face
    cv2.rectangle(image, (x, y), (x + w, y + h), (255, 0, 0), 2)

# Save the output image
cv2.imwrite("output.jpg", image)
```
This code will load the input image, convert it to grayscale, detect faces in the grayscale image using the Haar cascade classifier, and draw rectangles around the detected faces in the original image. The resulting image will be saved with the detected faces highlighted.
Firework Simulator v2
Tags: codepen, showdev
Published: 2022-12-12 19:32:11

<p>Fireworks fan here. This simulation of various firework effects offers variety and an attempt at realism.</p>

<p>Be sure to check out the settings menu (cog icon on top right) for more features and controls.</p>

<hr>

<h2>🎆 Major v2  Update! 🎆</h2>

<hr>

<p>A lot has changed since I originally posted this in 2017:</p>

<ul>
<li>Sound effects!</li>
<li>New star distribution algorithm for more realistic bursts</li>
<li>New shell types</li>
<li>Proper fullscreen control</li>
<li>Custom scaling control, allows larger shells to be viewed on small screens.</li>
<li>
<em>Many</em> other enhancements and tweaks</li>
</ul>

<p>There is a <a href="https://codepen.io/MillerTime/pen/BVvPdB">snapshot of v1</a> for comparison.</p>

<hr>

<p><strong>Extra fun:</strong> Control slow motion  by dragging near the bottom of screen!</p>

<p><strong>Desktop keyboard shortcuts:</strong></p>

<ul>
<li>
<strong>P</strong> - pause</li>
<li>
<strong>O</strong> - settings</li>
</ul>

{% codepen https://codepen.io/MillerTime/pen/XgpNwb %}