teleren/devto huggingface dataset:
Random Code Inspiration Volume 2
Tags: webdev, opensource
Published: 2023-09-30 20:28:17

## Image shrinker

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

[image-shrinker](https://image-shrinker.com/) is a simple, easy to use open source tool for shrinking images. Under the hood it uses [pngquant](https://pngquant.org/), [mozjpg](https://github.com/mozilla/mozjpeg), [SVGO](https://github.com/svg/svgo), and [gifsicle](https://github.com/kohler/gifsicle). You can also install these tools individually if you need to compress some images. I often use `pngquant `after exporting PNGs for web projects from Figma or similar tools. I literally run it like this:

```bash
pngquant *.png
mkdir compressed
mv *-fs8.png compressed
rm *.png
mv compressed/*-fs8.png ./
```
I am sure there are options or a shorter method, but this is how I do it for real 😅. I also like to keep the `-fs8.png` in the filenames so I know I already compressed them.

## trianglify.io

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

The credits of image-shrinker mention a tool for generating poly-backgrounds. The link was broken but I found this and had my fair share of fun with it.

[https://trianglify.io/](https://trianglify.io/)

## SVG porn

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

Most of you probably know this site, but I mention it because it was valuable to me again this week. Did you know that the maintainer curates all SVG code? If you need a clean SVG for a company logo, this is the place that will make you happy.
[https://svgporn.com/](https://svgporn.com/)

## 3D Game Shaders For Beginners

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

If you are interested in creating shaders (and also if not), this guide is for you. Free premium quality content, be ready to get amazed! 100% Wow guarantee. Seriously, this guy deserves a medal (and the 16k [probably not even bought] Github stars).

[https://lettier.github.io/3d-game-shaders-for-beginners/index.html](https://lettier.github.io/3d-game-shaders-for-beginners/index.html)

He also made [Gifcurry](https://lettier.github.io/gifcurry/) which looks cool but I didn't try it because I am on Windows right now, but I will.

## AI feedback loop generates psychedelic visuals

I did analog video feedback visuals back in the days and was searching if someone does somthing like this with AI nowadays. And I found this on YouTube, I love it, it's really mesmerizing. 

{% embed https://www.youtube.com/watch?v=a8T497RKHR4 %}
Dealing with Data
Tags: data, dataculture
Published: 2023-09-30 20:24:21

Hello, everybody!

My name is Catherine and I'm a very opinionated data specialist.

In my 15 years of work experience I've seen data that comes in all shapes and flavours: 
- search engine databases, 
- web logs, 
- app logs, 
- geo tracking, 
- cars' engine sensors, 
- images, 
- geological models,
- food nutrition values,
- custom oil-barrel sensors made by a research institute deep in Siberia

What is even more important, I worked in teams that come in different shapes and flavours — from tech-giant company with 10K+ employees to 2-people startup. Problems that I saw as a standalone issue in my first project, I can see now as a global pattern that many teams are facing and replicating. And I'm dying to talk about them.

So, here to come: personal observations, practical tips&tricks, career-building edifications and debatable concerns. Welcome onboard, and I hope you would join into the conversation.
Node.js Elegance: Deploying a Secure Backend with PM2 and Add SSL Certificate
Published: 2023-09-30 20:01:21


# Overview

Hosting a Node.js backend on a server is a crucial step towards making your application accessible to users. In this guide, we'll walk through the process of deploying a Node.js backend using PM2, a process manager for Node.js applications. Additionally, we'll enable SSL encryption to enhance the security of your deployment.

## Prerequisites

Before you begin, ensure that your Node.js project is production-ready, and any necessary database configurations are in place. Also, make sure Node.js is installed on your server.

## Step 1: Install PM2

On your server, install PM2 globally using npm:

```bash
npm install -g pm2
```

## Step 2: Start Your Node.js Application

Navigate to your project directory and start your Node.js application using PM2:

```bash
pm2 start server.js --name custom_name
```

Replace `server.js` with your actual entry file and choose a meaningful custom name.

## Step 3: Check Application Status

To ensure your application is running, use the following command:

```bash
pm2 list
```

This will display a list of running PM2 processes, including the one you just started.

## Step 4: Enable SSL Certificate

To add SSL encryption, follow these steps:

1. Clone the script for setting up Nginx proxy with SSL:

   ```bash
   wget https://raw.githubusercontent.com/thepwnexperts/advance-things/04c78015ad05c1e0be07dc82592740ac2a308217/linux/vps/nginx-proxy/localhost/nginx-proxy-with-ssl.sh
   ```

2. Change script permissions:

   ```bash
   chmod +x ./nginx-proxy-with-ssl.sh
   ```

3. Restart Nginx:

   ```bash
   service nginx restart
   ```

4. Run the script:

   ```bash
   ./nginx-proxy-with-ssl.sh
   ```

5. Follow the prompts to register your domain name.

6. After successful completion, exit the shell.

## Conclusion

Congratulations! You've successfully deployed your Node.js backend using PM2 and enabled SSL encryption for added security. Your application is now accessible via HTTPS, providing a secure connection for your users.

Feel free to customize these steps based on your specific project requirements. Happy coding!

---
Choosing the Right Programming Language: Finding the Best Solution for Your Challenges
Published: 2023-09-30 19:50:11

Many beginners often wonder: what is the best programming language to learn? However, the answer is not so straightforward, as it largely depends on the area in which you want to specialize and the types of problems you want to solve. Each programming language is suitable for solving different types of problems. Therefore, instead of thinking about a 'best' language for programming, it's more important to consider which language is most suitable for solving a specific problem.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xl8iep437u6qkyzpigd8.png)
Data Science for Beginners: 2023 - 2024 Complete Roadmap.
Tags: python, datascience, roadmap
Published: 2023-09-30 19:49:50

Hello there, fellow data enthusiast! I'm thrilled that your curiosity and interest in data science led you to my article. Now, let me ask you a question: Why data science? For me, it was a winding journey through the tech world until I discovered my passion for handling data. Little did I know that data science would become my calling. It's an exhilarating field, but it does require a healthy dose of curiosity and a gentle nudge to truly excel.

But enough with the chitchat; let's dive right in!

Is there a roadmap to navigate the vast landscape of data science? You bet there is!

Just as in life, every journey has its path, and data science is no exception. Before embarking on this exciting journey, there are a few crucial things you need to know. Neglect them, and you might find your interest waning faster than you'd expect.

Imagine yourself on an exciting road trip with data as your reliable co-pilot in the field of data science. Hold on tight as we explore some crucial stops on the path to data-driven triumph.

1. Learning Python/ R Programming Languages
2. Getting Around in Statistics
3. SQL Querying Techniques
4. Data Visualization 
5.Uncovering the Mysteries of Machine Learning
6.Cloud computing 

There are a few things to consider before going on this quest. Develop a strong sense of curiosity and a strong drive to learn.
As for the rest, consider it part of the thrilling adventure, waiting to be discovered as you navigate this exciting road.
Unlocking Success: Google's Career Workshops for Interview Preparation
Tags: google, google25
Published: 2023-09-30 19:49:50



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/915eavgxmbgl6katn9c7.jpeg)


**Introduction:**

Embarking on a career journey at Google is a dream for many aspiring tech professionals. To turn this dream into reality, one must navigate Google's rigorous interview process. Fortunately, Google doesn't just hire; it also helps you prepare. In this blog post, we'll delve into Google's Career Workshops for Interview Preparation, where Google Software Engineers share their expertise, insights, and practice questions to help you ace your next technical interview.

**Mastering Technical Interviews:**

Google's technical interviews are known for their complexity and high standards. The Interview Prep Workshops are designed to demystify this process. Seasoned Google Software Engineers lead these workshops, offering participants a behind-the-scenes look at what to expect during the interview.

**Key Takeaways:**

Insider Knowledge: Google engineers provide invaluable insights into the interview process. They share firsthand experiences, shedding light on what interviewers are looking for and how to approach challenging technical questions.

_Tips and Tricks:_ These workshops are a treasure trove of tips and tricks. From problem-solving strategies to time management techniques, participants gain a toolkit for success.

Practice Makes Perfect: Alongside advice, participants get hands-on experience with practice questions. These questions are carefully selected to mimic the complexity and style of Google's interviews, allowing you to hone your problem-solving skills.

_Navigating Google's Culture:_

Google places a strong emphasis on its values and mission. To fit seamlessly into the company culture, you need to understand and align with these principles. The Hypothetical Questions Interview & Resume Review workshop addresses this aspect of preparation.

**Key Takeaways:**

Google's Values and Mission: Participants learn about Google's core values and mission. Understanding these principles is vital for crafting responses to situational questions during interviews.

Situational Awareness: The workshop guides candidates on how to approach situational questions effectively. You'll learn how to draw from your experiences to provide authentic and compelling answers.

Resume Review: Your resume is your first impression on Google's recruiters. The workshop provides insights into crafting a resume that reflects your skills, experiences, and alignment with Google's values.

_Conclusion:_

Google's Career Workshops for Interview Preparation offer an invaluable opportunity for anyone aspiring to join this tech giant. These workshops empower you with the knowledge, skills, and confidence needed to excel in technical interviews and align with Google's culture.
Flat Map in JavaScript
Published: 2023-09-30 19:38:01

Flat Map in javascript is a great technique which you can learn here. Flat map essentially conbines techniques of map and filter Array method into one. I will suggest you to use flatMap() over combination of filter() and map().

FlatMap takes single pass and doesn’t produce intermediate array but filter ()and map() combination produces an intermediate array.

// using filterAndMap
console.time("filterAndMap")
const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

const squaredOddNumbers = numbers
    .filter(num => num % 2 !== 0)
    .map(num => num * num)

console.log(squaredOddNumbers); // [1, 9, 25, 49, 81]
console.timeEnd("filterAndMap")
Mastering AWS Lambda: DIY Projects to Hone Your Serverless Skills
Tags: lambda, aws, development, devops
Published: 2023-09-30 19:31:54

**Introduction**

AWS Lambda is the gateway to serverless nirvana, offering a scalable and cost-effective way to build and run applications. In this article, we’ll explore a series of do-it-yourself (DIY) projects that will sharpen your Lambda skills, deepen your understanding, and prepare you for real-world serverless challenges. Master AWS Lambda with following DIY projects.

**Table of Contents**

**1: Serverless Image Resizer**

- **Overview:** Create a Lambda function that automatically resizes images uploaded to an S3 bucket.
- **Skills Gained:** Event-driven Lambda, S3 triggers, image processing with Lambda.
- **Reference:** [link](https://codesolutionshub.com/2023/09/29/automate-image-resizing-in-aws-s3-with-serverless-computing/)

**2: Real-time Data Processing with Lambda and Kinesis**

- **Overview:** Build a real-time data processing pipeline using Lambda functions and Amazon Kinesis.
- **Skills Gained:** Event-driven architecture, data streaming, Lambda-Kinesis integration.

**3: Serverless Chat Application**

- **Overview:** Develop a serverless chat application using Lambda, API Gateway, and DynamoDB.
- **Skills Gained:** Building serverless APIs, real-time communication, DynamoDB integration.

**4: Automated File Backup to S3**

- **Overview:** Create a Lambda function to automate the backup of files from one S3 bucket to another.
- **Skills Gained:** Scheduled Lambda execution, S3 bucket management, data transfer.

**5: Serverless Contact Form**

- **Overview:** Build a serverless contact form that sends emails using Lambda and Amazon SES.
- **Skills Gained:** Email sending with Lambda, serverless web forms, SES integration.

**6: Serverless Data Aggregator**

- **Overview:** Develop a data aggregator that collects and processes data from various sources using Lambda.
- **Skills Gained:** Data aggregation, Lambda as ETL (Extract, Transform, Load) tool.

**7: Custom Alexa Skill**

- **Overview:** Create a custom Alexa skill using AWS Lambda to extend voice capabilities.
- **Skills Gained:** Voice application development, Alexa Skills Kit integration.

**Conclusion**

Congratulations, you’ve embarked on a journey to master AWS Lambda through hands-on projects. By completing these DIY projects, you’ll not only gain practical experience but also have a portfolio of serverless applications that demonstrate your skills to potential employers or clients.

Remember that the best way to learn is by doing. Dive into these projects, experiment, and adapt them to your unique needs. As you tackle real-world serverless challenges, you’ll become a Lambda expert, ready to take on any serverless project that comes your way.

So, roll up your sleeves, fire up your AWS console, and let’s start building with Lambda. Your serverless journey begins now!

Checkout more [here](https://codesolutionshub.com?utm_source=dev_to&utm_campaign=dev_to_lambda_diy).
If you're a developer and care about code quality, here are some tips for you
Published: 2023-09-30 19:29:37

Ever had that nagging feeling when looking at someone else's code, realizing they missed some basic concepts? To sidestep that, when you're coding, make sure you're following these principles:

💻 **Readable Code**: Write so that your peers can easily understand. Remember: we often spend more time reading code than writing it. Don't be the one who confuses everyone.

⏱ **Variable and Function Naming**: Pick clear and descriptive names. If a variable signifies a duration, "duration" is way clearer than just "d". Steer clear of ambiguity.

🙅🏾‍♂️ **Small and Focused Functions**: Keep your functions short with a single purpose. They'll be more comprehensible, easy to test, and reusable.

Regarding function arguments, less truly is more. Ideally, go without; but when necessary, cap it at three. No one's a fan of convoluted functions, but yes, there are always exceptions.

Steer clear of functions with unpredictable side effects. A function should deliver exactly what it promises.

On the topic of classes, adhere to the single responsibility principle. It'll save you headaches down the road.

Avoid unnecessary comments. Your code should speak for itself. If you're explaining too much in comments, you might need to rethink something.

Proper error handling is a must. Stay true to best practices and avoid vague returns. Your team will be grateful.

Leaving behind dead (unused) code? It's akin to a messy room. Keep your coding space neat.

✅ Uniform formatting is akin to maintaining a professional demeanor, much like adhering to a dress code.

Never doubt that the caliber of your code mirrors your prowess as a developer. Stand tall, champion quality, and let your professionalism shine through.
Say "Hello" to Byte Sized K8s
Published: 2023-09-30 19:26:00


I'm excited to announce the start of a new side project, in which I'm creating "byte sized" videos that explain specific Kubernetes topics in 10 minutes or less. 

If you're thinking of getting started with K8s, but don't have time to dig into a textbook, check out this video series. 

Here are the first two installments:


![Byte Sized K8s: Containers](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vputmpdpicsrhfliba57.png)
[Byte Sized K8s: Containers](https://www.youtube.com/watch?v=YrQ9C4J2v6E)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xb0azjye7wuwnxd1b077.png)
[Byte Sized K8s: Pods](https://www.youtube.com/watch?v=9pyi6aCjTf4) 

Thanks for reading, and happy developing!!!
MongoDB: Effortless Installation and Setup on Arch based Linux
Tags: mongodb, database, nosql, setup
Published: 2023-09-30 19:18:58


# Installing and Setting Up MongoDB on Arch Linux

MongoDB is a popular NoSQL database, and setting it up on Arch Linux is a straightforward process. This guide will walk you through the installation steps, including the necessary dependencies and configurations.

## Step 1: Install OpenSSL

Begin by installing OpenSSL, a prerequisite for MongoDB:

```bash
sudo pacman -S openssl
```

## Step 2: Install mongosh

Next, you'll need to install `mongosh`, the official MongoDB Shell. Clone the `mongosh-bin` repository from the Arch User Repository (AUR):

```bash
git clone https://aur.archlinux.org/mongosh-bin.git
```

Navigate into the cloned directory and build and install `mongosh`:

```bash
cd mongosh-bin
makepkg -si
```

## Step 3: Install MongoDB

Now, you can proceed to install MongoDB itself. Clone the `mongodb-bin` repository from the AUR:

```bash
git clone https://aur.archlinux.org/mongodb-bin.git
```

Navigate into the cloned directory and build and install MongoDB:

```bash
cd mongodb-bin
makepkg -si
```

This step may take a few minutes.

## Step 4: Start MongoDB Service

After successfully installing MongoDB, start the MongoDB service:

```bash
sudo systemctl start mongodb
```

## Step 5: Access MongoDB Shell

To access the MongoDB shell, simply type:

```bash
mongosh
```

Congratulations! You've successfully installed and set up MongoDB on your Arch Linux system. You can now begin working with MongoDB databases using the powerful `mongosh` shell.

---
Good Luck See you next time...
Day 5 Railway Reservation in js
Tags: webdev, javascript, programming
Published: 2023-09-30 19:17:07

```
let totalBooking = 10
let upper = 5
let middle = 3
let lower = 2
let totalReserv = 5

let bookedSeats = []
let reservSeats = []
let waitingSeats = []

const booking = (name, type) => {
    Pobj = { name, type } // Setting the object
    if (bookedSeats.length < totalBooking) { // check wheather all seats are booked
        let istype = bookedSeats.filter((data) => data.type === type) // filter the type for upper,lower , middle
        // check weather the type present in the booking
        let isavai = type === "upper" ? istype.length < upper :
            type === "middle" ? istype.length < middle :
                istype.length < lower

        if (isavai) { // if available pushed to the booking seat
            bookedSeats.push(Pobj)
        }
        else if ( //if not available moved to the reservation 
            (!isavai) && (reservSeats.length < totalReserv)) {
            console.log(`${type} seat type is not avialable ${name} you have moved to reservation`)
            reservSeats.push(Pobj)
        }
        else { // if reservation filled moved to waiting
            waitingSeats.push(Pobj)
        }
    }
    else if (
        (bookedSeats.length === totalBooking) && (reservSeats.length < totalReserv)) {
        console.log(`${type} seat type is not avialable ${name} you have moved to reservation`)
        reservSeats.push(Pobj)
    }
    else {
        waitingSeats.push(Pobj)
    }

}

const cancelBooking = (name, type) => {

    filterdata = bookedSeats.filter((data) => data.name !== name) // filter the value that does not contains the name
    cancelledData = bookedSeats.find(data => data.name === name) // taking out the data of deleting object
    bookedSeats = [...filterdata] // set the current filtered array as new array
    let waitingtypedata = reservSeats.filter((data) => {
        return data.type === cancelledData.type
    }) // getting the array which contains only the cancelled type
    result = waitingtypedata.pop() //  getting the first array from the list of selected type array
    bookedSeats.push(result) // joinig to the booked array
    reserFilterdata = reservSeats.filter((data) => data.name !== result.name)
    reservSeats = [...reserFilterdata] // setting the new reserv array as reserve array

}


booking("Dev", "upper")
booking("Jon Pandian", "upper")
booking("Vijay kumar", "upper")
booking("John wick", "upper")
booking("Tony Stark", "upper")
booking("Peter", "upper")
booking("Rakesh", "lower")
booking("Josap kurumila", "lower")
booking("Dr Octobus", "middle")
booking("Optimus Prime", "middle")
booking("Tanos", "middle")
booking("Joker", "middle")

cancelBooking("Jon Pandian", "upper")


console.log("Booked seates", bookedSeats)
console.log("Reerved seates", reservSeats)
console.log("Waiting seates", waitingSeats)

```
Online Code Editors
Tags: code, editor
Published: 2023-09-30 18:38:34

With **online IDEs**, you don't need any fancy setup and you can easily collaborate with your team **for free**.

Here are **7 great tools** you can use online!

- [JSFiddle](https://jsfiddle.net)
- [CodeSanbox](https://codesanbox.io)
- [CodePen](https://codepen.io)
- [StackBlitz](https://stackblitz.com)
- [Gitpod](https://gitpod.io)
- [CodeAnywhere](https://codeanywhere.com)
- [Replit](https://replit.com)
Scribe not extracting docblocks
Published: 2023-09-30 18:31:36

Scribe can use PHP docblocks for generating documentation. On a newer Laravel project this no longer worked and initially I thought it might be related to a newer version of Scribe as we didn't have that version in other projects where we were using an older version of Scribe. But a downgrade was causing conflicts, so I couldn't evaluate this. However, it seemed odd that apart from one Github issue, nobody was complaining. So that pointed towards a configuration issue, but I couldn't see anything different inside the scribe config file.

Finally, after debugging the GetFromDocBlocks strategy class, my colleague came across the fact that the getDocComment method is a PHP reflection method. This led to a Google search where we found this Stackoverflow post: https://stackoverflow.com/questions/42087433/reflectionmethod-getdoccomment-doesnt-seem-to-work-on-php-5-5

It turns out, that for this project we were using OpCache, but had the configuration `opcache.save_comments` set to false. After changing the setting `opcache.save_comments=1` and rebuilding the Docker container, Scribe worked as expected! 

This one was slightly tricky to debug and credit goes to my colleague who patiently debugged the issue with me.