teleren/devto huggingface dataset:
Cloudflare pages direct upload with stable preview urls
Tags: typescript, node, githubactions, cloudflare
Published: 2023-10-02 14:00:42

I switched all my projects to Monorepos this year, and I use Cloudlfare Pages intensively for hosting static websites. There is one small problem with Cloudlfare's Github integration: you can only connect one project per repository. In a monorepo where I provide pages like a landing page, documentation and an app, this is a problem.

It's good that you can also upload the assets directly. The problem with that: you lose some nice benefits:

- Stable preview URL
- PR comment with the links

And those are already quite nice benefits ;) So I started to rebuild the benefits myself. With the help of Wrangler and the Cloudflare API it is not difficult to achieve everything.

To get a stable URL I originally assumed that I would just get an updated stable URL with the help of the branch name.

```bash
npm i -g wrangler
cd ${{ env.ROOT_DIRECTORY }}
CF_PUBLISH_OUTPUT=$(wrangler pages deploy ${{ env.DIST_DIRECTORY }} --project-name=${{ env.CLOUDFLARE_PAGES_PROJECT_NAME }} --branch="${{ steps.extract_branch.outputs.branch }}" --commit-dirty=true --commit-hash=${{ steps.meta.outputs.sha_short }} | grep complete)
echo "cf_deployments=$CF_PUBLISH_OUTPUT" >> "$GITHUB_OUTPUT"
```

Unfortunately, after a few test runs, I found that this is not the case. I didn't deal with it further at this point, but tried to take an alternative approach:

- Search all deployments to a branch on every run.
- Delete all deployments
- Upload new assets

For reading and deleting deployments I wrote a small TypesScript program that I run in the CI pipeline.

Read out all previous branch deployments:

```typescript
public async getDeployments(options?: { branch?: string }) {
    const { branch } = options || {}
    const { accountId, projectName, apiToken } = this.config

    const response = await fetch(
      `https://api.cloudflare.com/client/v4/accounts/${accountId}/pages/projects/${projectName}/deployments`,
      {
        headers: {
          Authorization: `Bearer ${apiToken}`,
        },
      },
    ).then((res) => res.json())

    let deployments = response.result

    if (branch) {
      deployments = deployments.filter(
        (deployment) =>
          deployment.deployment_trigger?.metadata?.branch === branch,
      )
    }

    return deployments
}
```

Deleting a deployment:

```typescript
public async deleteDeployment(id: string) {
    const { accountId, projectName, apiToken } = this.config
    await fetch(
      `https://api.cloudflare.com/client/v4/accounts/${accountId}/pages/projects/${projectName}/deployments/${id}?force=true`,
      {
        method: 'DELETE',
        headers: {
          Authorization: `Bearer ${apiToken}`,
        },
      },
    ).then((res) => res.json())
}
```

The approach has another advantage: deployments that are no longer current are always cleaned up, since I am no longer interested in them anyway.
Explorando o Multitarefa com Threads em Java
Tags: java, braziliandevs, beginners, threads
Published: 2023-10-02 13:49:35

## O que são Threads em Java? 🧵

Em Java, uma thread é como um pequeno assistente que ajuda o programa a fazer várias coisas ao mesmo tempo. Imagine que você está cozinhando em sua cozinha (seu programa) e precisa ferver água, cortar legumes e mexer o molho simultaneamente. As threads são como chefs auxiliares que realizam essas tarefas separadamente.

**Exemplo de Threads em Java** ☕🍳

Vamos criar um exemplo onde precisamos fazer duas coisas ao mesmo tempo: fazer café e preparar ovos.

![Image t](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7qw4adj9qieat60utw8l.png)

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

Neste exemplo, temos duas threads: uma para fazer café e outra para preparar ovos. Elas começam a trabalhar simultaneamente e, no final, temos nosso café da manhã pronto!

## Conclusão 🎉

As threads em Java permitem que você execute várias tarefas ao mesmo tempo, tornando seu programa mais eficiente. É como ter chefs auxiliares em sua cozinha, cada um fazendo uma tarefa diferente. Lembre-se de coordenar bem suas threads para evitar confusão na cozinha do seu programa! 😉👨‍🍳👩‍🍳

Repositório com a trilha de java: https://github.com/antoniorws/basic-java

LinkedIn: https://www.linkedin.com/in/antonio-rodrigo-wanderley-serra/
GitHub: https://github.com/antoniorws
Music Monday — What are you listening to? (Our Parents' Faves Edition)
Tags: watercooler, music, discuss
Published: 2023-10-02 13:45:18

_cover image source: [Giphy](https://giphy.com/gifs/portlandia-season-2-episode-4-xT1R9KGaDS1ai1ciWY)_

**Alright, so this time around we're gonna share those tunes most loved by our parents. Perhaps they passed on their love for music from an earlier decade? Maybe they challenged you early on with obscure jazz, old-timey bluegrass, or classical and you grew to love it. Or perhaps they shared music with you that you absolutely can't stand even today... lay it on me, I'm here to commiserate (and/or politely disagree 😋). By the way, "parents" is a loose term... whoever helped bring you up and left a musical mark on your life is fair game here. Looking forward to listening to y'all's suggestions!** 🥁

![A scene from Mrs. Doubtfire... Robin Williams plays a rambunctious father who is throwing a birthday party for his son. In this scene, we see a wild party where he is dancing on the table with his son and another kid, while a pony walks into the framed shot and is clearly visible inside the house. It looks like a super fun party with no rules and Robin Williams looks like a big kid, not a typical dad.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1rxfj0h0cg229jcsaixw.gif)

***

## How we do 

In this weekly series, folks can chime in and drop links to whatever it is they've been listening to recently + browse others suggestions. You can follow the suggested genre if you'd like, but don't feel confined to it; you're free to suggest whatever you wanna. 🙌  

If you're interested in having other discussions about music, consider following the aptly named [#music discussions](https://dev.to/music-discussions) organization.

{% embed https://dev.to/music-discussions %}  

***

If you can't tell I'm running low on ideas... if you have any thoughts on a genre you'd like me to cover or perhaps return to, don't hesitate to let me know about it. 😅 _Note: you can embed a link to your song using the following syntax `{% embed https://... %}`. This should work for most common platforms!_

Now, lemme hear what ya got! 👂🎶
Day 1: LLMs & Codecademy - A Fresh Start in AI
Tags: ai, datascience, machinelearning, beginners
Published: 2023-10-02 13:42:30


_"Sucking at something is the first step towards being sorta good at something."_ - **JAKE the DOG (Adventure Time)**


![Image description](https://media.tenor.com/otMBEMDbv94AAAAC/john-travolta-where-am-i.gif)

The Confusing Beginning:

Stepping into the vast realm of Artificial Intelligence (AI), I found myself at a crossroads—overwhelmed yet excited, with a ton of resources at my fingertips and no idea where to begin. YouTube promised a "simple AI project," but the jargons and the underlying concepts lost me midway.

The Structured Approach:

I decided to shift gears. Coursera and Codecademy have been old friends, so I turned to them for clarity.

Google Cloud on Coursera: I've opted for the course on LLMs, starting with 'Introduction to Large Language Models'. Aim? To demystify LLMs and grasp the potential use-cases.
Machine Learning/AI Engineer Career Path on Codecademy: This is where I'll bridge the gaps in my Machine Learning basics. And the cherry on top? Codecademy aids in building a portfolio with tangible projects.

Looking Ahead:

While this is a promising start, I'm cautious. The infamous "tutorial hell" looms large, and I'm determined to avoid it. My strategy is simple: learn just enough to build, iterate, and then move on to the next challenge.

Day 1 down. A world of possibilities awaits. I'll keep you updated on my progress, missteps, and learnings. Stay tuned!

On to Day 2!
Data Science for Beginners: 2023/2024 Complete Road Map
Tags: datascience, data, analytics
Published: 2023-10-02 13:38:25


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/05vegiph8q9chlmohsgr.jpg)**Data Science:** Data science is an interdisciplinary field that uses scientific methods, algorithms, combines expertise in statistics, programming, domain knowledge, and data visualization to solve complex problems and make data-driven decisions. Data scientists collect, clean, analyze, and interpret data to uncover valuable information that can be used for various purposes, such as improving business strategies, making predictions, and understanding trends.

**SQL (Structured Query Language)20 DAYS:** SQL is a programming language used to manage and query databases. In data science, it's vital for tasks like retrieving specific data, cleaning and transforming data, and integrating data from various sources. SQL is essential for structured data analysis.

a) Tutorials - https://lnkd.in/epAFJzJB
b) Projects - https://lnkd.in/eq9jqcBq

**Python 20 DAYS:** Python is a versatile programming language widely used in data science. It offers libraries like Pandas and NumPy for data manipulation, scikit-learn, TensorFlow, and PyTorch for machine learning, and Matplotlib and Seaborn for data visualization. Python integrates well with SQL for data analysis, making it popular among data scientists.

a) Tutorials - https://lnkd.in/eh4gTQQ2
b) Projects-https://lnkd.in/emzcrzTX

**Power BI:** Power BI, developed by Microsoft, is a tool for data visualization, reporting, and interactive dashboards. Data scientists use it to create engaging reports and dashboards that communicate data insights effectively. Power BI connects to different data sources, simplifies data transformation, and enables easy sharing of reports with stakeholders.

a) https://lnkd.in/d5DPYusc

Create a comprehensive data science portfolio over the next 6-12 months by working on a variety of projects from different sources, including Kaggle competitions and personal initiatives.

In Conclusion, data science is the interdisciplinary field of extracting insights from data. SQL is used for managing and querying databases, Python is a versatile language for data tasks, and Power BI is for creating impactful data visualizations and reports. These tools are frequently used together by data scientists to extract, analyze, and communicate insights from data.
Programming the TBOD out of “Slope”
Tags: gamedev, watercooler
Published: 2023-10-02 13:35:33

So, everybody knows the game “Slope” right? Green and black everything, where you are a ball and trying not to hit any of the red and black blocks of DEATH, etc.? Now does anybody know these things? 
![Triple blocks of death](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x9f4yn8c4ragsrjookl1.jpeg) I call them the Triple Blocks of Death (TBOD, as in the title). They are so annoying. Now, I am going to fork slope and remove them. First I have to find the code, on Github where everything is, and then find the triple block and remove them. Not too bad, right? Right?
Math bot captcha solving
Tags: captchasolving
Published: 2023-10-02 13:19:32

[2captcha.com](https://2captcha.com/?from=10075179) is a captcha solving service that can help solve math bot captchas. The purpose of captchas is to prevent automated bots from accessing or spamming websites. Captchas usually contain a distorted text within an image, but math bot captchas require the user to solve a simple math problem to gain access to a website. 

The process of solving a math bot captcha using 2Captcha is as follows: we take the captcha image from the page and send it to the 2Captcha service, where an employee solves it by solving the math problem, then the answer is returned to us, which must be entered in the appropriate field to solve the captcha. 

**Here are the steps to solve a math bot captcha using 2Captcha:**

1. Take the captcha image from the page.
2. Send the captcha image to the 2Captcha service.
3. Wait for the result, which will be the answer to the math problem.
4. Enter the answer in the appropriate field to solve the captcha.

2Captcha's API works via a two-step process where you submit CAPTCHA data in and then poll for results with the returned request ID. The price for solving captchas varies depending on the type of captcha and the number of captchas you need to solve. For normal, basic captchas, you can earn anywhere between $0.25 and $0.60 for every 1,000 captchas you solve. 

In conclusion, 2Captcha is a captcha solving service that can help solve math bot captchas. To solve a math bot captcha, you need to take the captcha image from the page and send it to the 2Captcha service. The recognition price varies depending on the type of captcha and the number of captchas you need to solve.
🚀 Rev up Your JavaScript: 19 Performance-Boosting Tips to Avoid Code Slowdowns 🚀
Published: 2023-10-02 13:14:47


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

Are you tired of dealing with slow and sluggish JavaScript code? As developers, we all strive for code that’s not only functional but also performs at its best. In the world of web development, JavaScript plays a pivotal role, and optimizing it is key to delivering a seamless user experience.

Here are 19 common JavaScript mistakes that can slow down your code, along with tips on how to avoid them:

❌ Not Using Proper Data Structures: Choosing the right data structure can significantly impact performance.

⏳ Blocking the Main Thread: Long-running synchronous operations can freeze your application.

🤯 Memory Leaks: Failing to manage memory can lead to performance issues.

🔄 Excessive DOM Manipulation: Frequent DOM updates can be resource-intensive.

⚡Not Caching Selectors: Repeatedly searching the DOM can be slow.

💥 Overusing Global Variables: Global variables can lead to scope-related issues.

🔁 Inefficient Loops: Optimize loops to prevent unnecessary iterations.

🧩 Ignoring Asynchronous Code: Not utilizing asynchronous code when needed can lead to bottlenecks.

📦 Not Minifying Your Code: Large files take longer to load.

🐢 Heavy Animations: Complex animations can slow down rendering.

🤔 Ignoring Event Delegation: Registering too many event listeners can hinder performance.

📄 Large File Loads: Avoid unnecessary requests and minify your assets.

🔄 Inefficient Array Methods: Opt for the right array methods to avoid excessive iteration.

⏱️ Ignoring Debouncing/Throttling: Uncontrolled function calls can flood your app.

🧐 Not Using Web Workers: Offload heavy tasks to web workers to prevent UI lag.

📌 Ignoring Critical Rendering Path: Optimize rendering for faster load times.

🌐 Not Using a CDN: Content delivery networks can speed up asset delivery.

🚿 Uncleared Intervals/Timeouts: Orphaned timers can cause memory leaks.

📈 Not Profiling Your Code: Regularly analyze your code for performance bottlenecks.

By avoiding these common mistakes and embracing best practices, you can supercharge your JavaScript code and deliver a faster, more responsive user experience. 🚀

What other JavaScript performance tips do you swear by? Share your thoughts in the comments below! 👇
Utilize Software That Adapts And Grows To Strengthen Your Business - Big Entities
Published: 2023-10-02 13:12:28

Custom Development
For the best custom software development services, pick [BigEntities](https://www.bigentities.com/). We are experts in developing software solutions that are suited to your company's needs thanks to our ten years of experience. Delivering scalable, creative, and effective applications is the main goal of our talented development team. We offer complete solutions, from improving client experiences to streamlining procedures. Transparency, adaptability, and prompt delivery are all guaranteed by our agile methodology. Join forces with us to take advantage of cutting-edge technology and affordable solutions. With [big entities](https://www.bigentities.com/) realize your vision and maintain your competitive edge in the digital sphere.


In today's business landscape, custom software development is crucial. Custom software, as opposed to off-the-shelf options, is painstakingly built to fit the unique requirements and procedures of each firm. By streamlining processes and getting rid of extraneous features or restrictions that are sometimes found in generic software, this level of customisation improves productivity. In addition, by offering special features or functionalities that set firms distinct, custom software enables them to achieve a competitive edge. Due to its scalability, the solution expands with the business, guaranteeing its long-term usefulness and affordability. Custom software is not merely significant; it is the best option for consumers who appreciate specialized solutions that promote success thanks to devoted support, strong security, and an easy user experience.
Ruff: A Python Linter built with Rust
Tags: python, ruff, rust, linter
Published: 2023-10-03 16:51:43

---
title: Ruff: A Python Linter built with Rust
published: true
date: 2023-10-02 13:05:43 UTC
tags: #python #ruff #rust #linter
canonical_url: https://carlosmv.hashnode.dev/ruff-a-python-linter-built-with-rust
---

Ruff is a Python linter built with Rust, and is extremely fast in comparison with other linters(10-100x faster) in the Python ecosystem, according to its documentation.

One of the things that make Ruff different from the alternative tools, it is faster and has more functionality behind a single interface.

### What is a linter?

According to this page in [Wikipedia](https://en.wikipedia.org/wiki/Lint_(software)), a linter is a tool that analyzes the source code to flag programming errors, bugs, stylistic errors and suspicious constructs.

So, when we are writing a program, we can use a linter to check if there is an error or a bug. Also, when we are contributing to a code base, we use a linter to check if we are writing the code with stylistic errors.

This tool allows us to write idiomatic code, more consistent with the code base and with fewer errors and bugs.

### Requirements

- Pip installed

### Installation

```
pip install ruff

```

### Usage

The examples are very simple, we are going to write a function in a Python file, import a module without using it, and run Ruff to see its output in the console.

```
import os 

def say_hello():
    print('Hello')

say_hello()

```

Now, in the console, we run the command `ruff check <python file>`

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695864381676/ee5a4f03-01df-4cfd-8ff9-87a65c030a7b.png)

If we use the command `ruff --fix <python file>`, ruff fixes the problem for us.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695864510446/427093f4-5690-4174-8a9e-daa9fb6cc2d5.png)

Next, we declare a variable, without using it. And use an undeclared variable.

```
def say_hello():
    message = "hello"
    print(messag)

```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695864771026/7d9b3a56-fbdc-4500-9556-da98070edc53.png)

If there are no problems with the code, then, ruff will not show any message.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695864875534/4ae3dc1b-fb9d-41c2-89c1-1f7eaeca64e3.png)

### Conclusion

I had the opportunity to try Ruff in an open-source project that I'm contributing to, and it was my first time using a linter. The project uses it before the code is pushed to a branch. But now, every time I make a modification or add a piece of code I run Ruff, is so fast and allows me to catch any error or bug before I run the program.

### References

[Ruff Documentation](https://docs.astral.sh/ruff/)

[Ruff README](https://github.com/astral-sh/ruff)

[Linter](https://en.wikipedia.org/wiki/Lint_(software))
Folding button animation on hover
Tags: freecodez, react, html, blog
Published: 2023-10-02 12:31:16

Hey there, You are most welcome to this article. I hope you will enjoy this article. If you like this article then please share this article with your friends and colleagues. If you have any questions or suggestions regarding this article then please comment down below.

**Folding button animation on hover**

![Folding button animation on hover](https://res.cloudinary.com/freecodez/image/upload/v1696249870/images/aud3wlfrgaobogxu3rsb.webp)

For full source code visit : [https://freecodez.com/post/tk90g4l](https://freecodez.com/post/tk90g4l)

For more such articles visit : [https://freecodez.com](https://freecodez.com/all)
Open-Closed Principle in React
Tags: react, typescript, javascript, learning
Published: 2023-10-02 12:23:36

## Open-Closed Principle

> _Software entities should be open for extension, but closed for modification._

![Open-closed gif](https://media.tenor.com/Kjs1TtCLkVoAAAAC/open-closed.gif)

**Open for extension** means that you should be able to add new functionality or features to a React component without having to change its existing code.

**Closed for modification** Once a React component is designed and implemented, you should avoid making direct changes to its source code whenever possible.

```typescript
const Book = ({ title, image, type, onClickFree, onClickPremium }: IBook) => {
  const handleReadPremium = () => {
    // Some logic
    onClickPremium();
  };

  const handleReadFree = () => {
    // Some logic
    onClickFree();
  };
  return (
    <div>
      <img src={image} />
      <p>{title}</p>
      {type === "Premium" && (
        <button onClick={handleReadPremium}>Add to cart +</button>
      )}
      {type === "Free" && <button onClick={handleReadFree}>Read</button>}
    </div>
  );
};
```

The code above violates this principle as there is a type check to render out a specific feature.

If there is a new book type, then there would be a further modification of this component as well. Let's fix it!

```typescript
const Book = ({ title, image, children }: IBook) => {
  return (
    <div>
      <img src={image} />
      <p>{title}</p>
      {children}
    </div>
  );
};
```

We get rid of the unecessary codes and create a new props which is `children` so the other component can extend this component by passing it as a children.

```typescript
// We extend Book component to create a new component
const PremiumBook = ({ title, image, onClick }: IBook) => {
  return (
    <Book title={title} image={image}>
      <button onClick={onClick}>Add to cart +</button>
    </Book>
  );
};

const FreeBook = ({ title, image, onClick }: IBook) => {
  return (
    <Book title={title} image={image}>
      <button onClick={onClick}>Read</button>
    </Book>
  );
};
```

This way, your Book component will be **Open** for extension and **Closed** for modification👍

## What's next?

Let's not stop here since there are 3 more principles left to learn in SOLID which I will cover in the next article so stay tuned.
South Miami Roofing
Published: 2023-10-02 12:23:23


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

South Miami Roofing is your go-to roofing company in Miami, Florida. We take care of the re-roof, roof repair, and maintenance of your metal, tile, flat, and shingle roof.


Location: 6800 SW 40th St STE#668, Miami, FL 33155, United States


Monday
6 AM–7 PM

Tuesday
6 AM–7 PM

Wednesday
6 AM–7 PM

Thursday
6 AM–7 PM

Friday
6 AM–7 PM

Saturday
6 AM–7 PM

Sunday
Closed

website: [southmiamiroofing.com](https://southmiamiroofing.com/)


+1 305-242-0039``
Call phone number


PMMW+25 Miami, Florida, USA