teleren/devto huggingface dataset:
Understanding the Magic of Logarithms in Binary Search
Published: 2024-03-09 15:17:46

Hey community! 👋 Today, let's demystify the magic behind the efficiency of algorithms **like binary search**. Ever wondered why we say binary search has a time complexity of **O(log N)**? 

Let's break it down in simple terms.

Imagine you have a row of boxes, and you want to find a particular item in one of them. Now, let's use binary search to make this process super efficient.

Step 1: Start with 16 boxes.

```
📦📦📦📦📦📦📦📦📦📦📦📦📦📦📦📦
```

Step 2: Each time, divide the number of remaining boxes by 2.

```
📦📦📦📦📦📦📦📦   📦📦📦📦📦📦📦📦
```

Step 3: Repeat until you have only one box left.

```
        📦📦📦📦📦📦📦📦   📦📦📦📦📦📦📦📦
Step 1:           📦📦📦📦   📦📦📦📦
Step 2:                📦📦   📦📦
Step 3:                   📦   📦
Step 4:                      📦
```

Here's the cool part: The number of steps it takes to go from 16 boxes to 1 box is surprisingly related to the concept of logarithms!

Mathematically, we can represent this as:
![img](http://www.sciweavers.org/tex2img.php?eq=N%20%2A%20%280.5%29%5E%7Bsteps%7D%20%3D%201&bc=White&fc=Black&im=jpg&fs=12&ff=arev&edit=0)

In the case of our 16 boxes example, it becomes:
![img](http://www.sciweavers.org/tex2img.php?eq=16%20%2A%20%280.5%29%5E%7Bsteps%7D%20%3D%201&bc=White&fc=Black&im=jpg&fs=12&ff=arev&edit=0)

Now, let's use logarithms to solve for the number of steps. Taking the base-2 logarithm of both sides gives us:
![img](http://www.sciweavers.org/tex2img.php?eq=Log_%7B2%7DN%20%3D%20steps&bc=White&fc=Black&im=jpg&fs=12&ff=arev&edit=0)

So, in this example:
![img](http://www.sciweavers.org/tex2img.php?eq=Log_%7B2%7D16%20%3D%20steps&bc=White&fc=Black&im=jpg&fs=12&ff=arev&edit=0)

Steps in this case equals to **4**..

Voila! The number of steps it takes to find an item in our binary search is logarithmic with respect to the number of elements (N) we started with. Hence, the time complexity of binary search is O(log N).

Understanding this concept can help us appreciate the efficiency of algorithms that reduce the search space by half in each step. 

Happy searching! 🔍💡 #AlgorithmMagic #BinarySearch #LogarithmsExplained
Full Backend Project Setup And Structure in NodeJS Part - 1
Tags: node, backenddevelopment, fullstack, javascript
Published: 2024-03-09 14:38:11

First of all setup backend project:

1. Create a folder and open in any code editor like: VsCode

> Open Terminal and run this code:

```
npm init -y
```

- Lets Setup Project Folder Structure and files

> create importants folder like:

```
.
└── root/
    ├── public/
    │   └── temp
    ├── src/
    │   ├── app.js
    │   ├── index.js
    │   ├── constants.js
    │   ├── controllers/
    │   │   └── index.js
    │   ├── middlewares/
    │   │   └── index.js
    │   ├── routes/
    │   │   └── index.js
    │   ├── utils/
    │   │   └── index.js
    │   ├── db/
    │   │   └── index.js
    │   └── models/
    │       └── index.js
    ├── .env
    ├── .env.sample
    ├── .gitignore
    ├── .prettierrc
    └── .pretterignore
```
After this you need to install some **NPM packages*** like
`Nodemon and Pretttier`

Open your terminal from root directory and run the following code:

```
npm i -D nodemon prettier
```

after successfully installed goto `package.json` file and update it with the following code snippet:

```
{
  "name": "node",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "type": "module",
  "scripts": {
    "dev": "nodemon src/index.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "nodemon": "^3.1.0",
    "prettier": "^3.2.5"
  }
}

```

then add your [gitignore](https://mrkandreev.name/snippets/gitignore-generator/) and [prettier](https://prettier.io/docs/en/ignore.html) setup

Read [part -2](https://dev.to/shaon07/full-backend-project-connect-mongodb-atlas-in-nodejs-part-2-5ep)
Manage Network Connections
Tags: linux, programming
Published: 2024-03-09 14:15:38


##  Table of Contents

1. What is network manager
2. What is nmcli/nmtui
3. What is a network device 
4. What is a connection
5. How to view device status
6. How to view active connection
7. How to add/remove a connection



### What is Network Manager ? 

Network manager is a daemon in the Linux Kernnel that manages the device, connection etc. and keep them active. By default the network is handled by the system'd networkd and netplan but if NetworkManager is installed, it will take control of all networking. 

Configuration of Network manger is present at : `/etc/NetworkManager/NetworkManager.conf`

### What is nmcli/nmtui

So nmcli is command line tool that is used to control NetworkManager. nmcli command can also be used to manage the network device and network connection. Nmtui does the same work but in the graphical way.


### What is a network device

Network Device is a hardware that allow you to communicate i.e. switch, hub, router, NIC ( Network interface card ) etc. 

Here we are going to refer mostly network interface which is nothing but the software side of these hardware so that we can manage them. 

To view the active network interface use : `ifconfig -a`


### What is a network connection 

A network connection is a connection between two network devices that are connected on the same network.

### How to view device status

We can use `nmcli device status` to view the device status. 


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

It would view us the current state of the device and the active connection on it if any. 

### How to view active connection

To view all connection we can use `nmcli connection show` and to get to only active connection we can add flag `--active`

![image](https://hackmd.io/_uploads/HJwKg15pa.png)

### How to add/remove a connection

To add a new connection we can use 
`nmcli connection add type <ethernet|wifi> ifname <device name> conn-name <connection name> <setting>.<property> <value>`

![image](https://hackmd.io/_uploads/ByfZr1c66.png)


Here we checked our devices that are present then we added a test-connection and verified that it was added. 

To remove this connection we can simply use
`nmcli connecion delete <conn-name>`

![image](https://hackmd.io/_uploads/B1ovSJcaT.png)
Argument of type 'HTMLInputElement' is not assignable to parameter of type 'SetStateAction<string>' TypeScript Error
Tags: react, programming, typescript, javascript
Published: 2024-03-09 14:08:01


![Code error](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1lgbshemc3ohlibv58xl.png)
![Error message](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hdu5fnfuzvoijwwobd2q.png)

How to fix it
1. It is a change event (ChangeEvent) not a mouse event. Therefore it should be
```function handleEmailChange(e: React.ChangeEvent) ```
2. There is no need for the target as HTMLInputElement. Rather, it should be 
```function handleEmailChange(e: React.ChangeEvent<HTMLInputElememt>) ```
Portfolio Website / Bible App - Devlog #8
Tags: webdev, beginners, learning, frontend
Published: 2024-03-09 13:59:38

Worked on:
Backend - Saving References to MySQL DB instead of a local DAO service,
Frontend - Quiz feature which will call backend and display references randomly and next button to view the next one.

To do:
Styling - text size, etc.. and overall polishing.
Responsiveness
Finish Portfolio site
Deploy client and api servers.
Maximizing Success: Unveiling the Power of Strategic Sales and Marketing Integration
Published: 2024-03-09 13:50:57

In the dynamic landscape of business, sales and marketing play pivotal roles in driving growth and enhancing brand visibility. A seamless synergy between these two functions is imperative for sustained success.

1. Market Research: Begin by conducting thorough market research to identify trends and consumer needs.

2. Target Audience Definition: Clearly define your target audience, ensuring that your marketing efforts align with the interests of potential customers.

3. Compelling Content Creation: Develop captivating content that resonates with your audience, incorporating the identified keywords to enhance SEO.

4. Integrated Campaigns: Implement integrated campaigns that seamlessly blend [sales and marketing](https://talktoeqconsultants.com/) strategies for a cohesive customer experience.

5. Data-Driven Decision-Making: Utilize data analytics to make informed decisions, refining both sales and marketing approaches based on real-time insights.

6. Personalized Outreach: Tailor your outreach efforts to individual preferences, enhancing the likelihood of conversion.

7. Social Media Engagement: Leverage the power of social media platforms to amplify your brand's reach and engage with potential customers.

8. Continuous Optimization: Regularly evaluate and optimize your sales and marketing strategies to stay agile in the ever-evolving business landscape.

By strategically aligning and executing these key steps, businesses can unlock the full potential of their sales and marketing efforts, fostering sustainable growth and a competitive edge in the market.
tourgroup-js: traverse Dom natively in chain
Tags: webdev, javascript
Published: 2024-03-09 13:37:00

In Beta, feel free to suggest improvements.

## Introduction
In the past, different browsers supported standard syntax differently. To create websites that work across platforms, we had to consider these differences. We used tricks or libraries like [jQuery](https://jquery.com/) to solve this problem. But now, modern browsers support most standard syntax, so we don't need to worry about it. As suggested by [You may not need jQuery](http://youmightnotneedjquery.com/), we can achieve the same effects using native syntax. However, native syntax can be cumbersome, so we need tools like tourgroup-js.

Native syntax is fastest, but it's complex and doesn't support chaining. jQuery supports chaining, but it doesn't support ES Modules and can cause global pollution. tourgroup-js aims to be as close to native syntax as possible while supporting chaining and ES Modules without global pollution.

For more information, visit the [GitHub repository](https://github.com/bradhuang9999/tourgoup-js).

## Demo
[Online demo](https://jsfiddle.net/bradhuang9999/ga7z9vth/1/)

## Why TourGroup
- Lightweight: Less than 10KB.
- Fast: invoke native function directly
- Supports ES module.
- Browser-native interface reduces learning curve.
- Extends Array, providing native array-related functions.
- Chainable interface for ease of use.

## Example Code
```js
import TourGroup from 'https://cdn.jsdelivr.net/npm/tourgroup-js@1.0.0/dist/tourgroup.esm.min.js';
var tourGroup = TourGroup.at('.class1')
                         .querySelectorAll('span.class2')
                         .has('i');
tourGroup.setAttribute('data-my-attr', 'true')
         .addEventListener('click', () => {console.log('clicked')});
```

## Compare with jQuery
- Not support ES Module, need to include jQuery library from HTML first.
- Cause polution to global scope.

```html
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
```

- function interface is different from native
- implementation is more complex than native
```js
var target = $('div.class1').find('span.class2').has('i');
target.attr('data-my-attr', 'true')
      .on('click', () => {console.log('clicked')});
```

## Compare with Native
- Native is not chainable.
- Without some useful functions, such as toogleClass, addDelegateEventListener, etc.
```js
var target = document.querySelectorAll('div.class1');
for(let div of target){
  let spans = div.querySelectorAll('span.class2');
  for(let span of spans){
    if(span.querySelector('i')){
      span.setAttribute('data-my-attr', 'true');
      span.addEventListener('click', () => {console.log('clicked')});
    }
  }
}
```
Launching a 30-Day Web Development Challenge: Elevate Your Skills and Build Your Portfolio
Tags: javascript
Published: 2024-03-09 13:14:39

Are you ready to take your web development skills to the next level? Are you eager to gain real-world experience and solidify your knowledge in HTML, CSS, JavaScript, React, jQuery, Tailwind CSS, and Bootstrap? If so, I invite you to join me on an exciting journey – a 30-day web development challenge!

**Why a 30-Day Challenge?**

Embarking on a 30-day challenge provides an incredible opportunity to immerse ourselves in web development, practice new skills, and tackle real-world scenarios. By dedicating ourselves to building a new web app, landing page, or portfolio project every day, we'll not only enhance our technical proficiency but also cultivate a portfolio brimming with diverse and impressive projects.

**What to Expect**

Each day of the challenge will bring forth a new project, meticulously crafted to explore different facets of web development. From designing sleek and responsive landing pages to building dynamic web apps with React, each project will offer a unique learning experience. Alongside the projects, detailed overviews will be provided, covering the development process, technologies utilized, and insights gained.

**Join the Journey**

If you're eager to hone your skills, expand your portfolio, and connect with fellow developers, I invite you to join this challenge. Whether you're a seasoned developer looking to refine your craft or a beginner eager to dive into the world of web development, this challenge is for you. Let's embark on this journey together, supporting and inspiring each other along the way.
**
How to Participate**

To participate in the challenge, simply follow along with the daily project releases. Each project will be accompanied by detailed instructions, code snippets, and resources to guide you through the development process. Feel free to customize the projects, experiment with different techniques, and showcase your creativity.

**Share Your Progress**

Throughout the challenge, don't hesitate to share your progress, insights, and experiences on social media using the hashtag #30DaysWebDevChallenge. Connect with other participants, exchange ideas, and celebrate your achievements together.

**Let's Grow Together**

Together, we'll embark on a transformative journey, elevating our skills, expanding our portfolios, and paving the way for future success in the world of web development. Let's seize this opportunity to learn, create, and grow together. Are you ready to accept the challenge?

Stay tuned for the launch of the 30-day web development challenge, and let's embark on this exciting journey together!

Are you ready to accept the challenge and elevate your web development skills? Join me on this transformative journey, and let's make the next 30 days count!
I'm eager to hear your thoughts, reviews, suggestions, or any ideas you might have. Let's connect and continue learning together!
How to fix 'Type 'MouseEvent' is not generic.' TypeScript error.
Tags: webdev, typescript, javascript, programming
Published: 2024-03-09 13:07:04

A sample image of the TypeScript error.
This could be because you're using DOM events.
![Error using TypeScript](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/phw6nm3vchgngqprr4k7.png)

Here is the solution:

```
 const onSubmit = async (e: 
React.MouseEvent<HTMLButtonElement>) => {
    e.preventDefault();
}
```
Let me know if it works. Cheers ;)
Nobody had the idea of replicating YouTube
Published: 2024-03-09 12:57:55

I'm seeing a lot of people realizing what bigtech and governments are doing with the internet. But did anyone have the idea of replicating YouTube?

Would it be possible to make download of trillions YouTube videos or automate invitations to creators (YouTubers) inviting them to join this project?

Make the new YouTube free and uncensored as it was in the beginning before economic and social interests took over.

Would a project like this be possible?
Best node.js web frameworks you must know in 2024
Tags: node, bunjs, typescript, express
Published: 2024-03-09 12:34:29


## 1. express.js
This framework is the most popular one since node.js was created.
It's ecosystem is very mature, but due to lack of updates on new javascript features, it is somewhat behind the time.
And it's code is somewhat too cohesive to be well modulised and updated in time.

## 2. sails.js

sails.js is based on express and extended to be the best mvc web framework ever created for node.js,
It is specifically well fit for small business sites.
It has many features modern web frameworks which can help you rapidly develop your sites.
Due to its complexity and ambition, it is somewhat immature for more use cases.
And is not very performant and also somewhat too cohesive to be well modulised and separated when needed.

## 3. aex.js

aex was originally developed to make sails' modules optional,
and aware that mvc is not suitable for web frameworks.
So it is backed with a new theory - **_the Web Straight Line Theory_** and claim that mvc is not suitable for the web frameworks. 

Over time when the typescript is emerged and async/await is introduced, aex was totally rewrited to embrace async/await features and fully utilize the Web Straight Line Theory.

The Web Straight Line theory aside, it also incorporated express's middleware and necessary concepts for web frameworks from sailsjs.

Aex is well modulised and very extensible. It is compatible with most express's middleware and support new features of javascript/typescript specifically async/await and decorators.
It is **_spring_** like when **_decorator_** is used, but more suitable for web development with **_the Web Straight Line theory_** backed instead of MVC theory.

Its core apis are very stable since its creation.
Aex is relatively new and has a very small community, so you should use it at your risk.
Forming a Magic Square (Day 2 of 365)
Tags: hackerrank, challenge, javascript
Published: 2024-03-09 12:18:16

Challenge link: https://www.hackerrank.com/challenges/magic-square-forming/problem

This is my day 2 of the challenge. What I'm trying to solve is the forming a magic square problem from Hackerrank. So here's the break down on how I solve the problem:

**Predefined Magic Squares:** First, I define all possible configurations of a 3x3 magic square. Each configuration is represented as a one-dimensional array consisting of nine integers. These integers range from 1 to 9, with each number appearing exactly once. This step establishes the set of target magic squares we aim to compare against.
```javascript
const magicSquares = [
    [8, 1, 6, 3, 5, 7, 4, 9, 2],
    [4, 3, 8, 9, 5, 1, 2, 7, 6],
    [2, 9, 4, 7, 5, 3, 6, 1, 8],
    [6, 7, 2, 1, 5, 9, 8, 3, 4],
    [6, 1, 8, 7, 5, 3, 2, 9, 4],
    [8, 3, 4, 1, 5, 9, 6, 7, 2],
    [4, 9, 2, 3, 5, 7, 8, 1, 6],
    [2, 7, 6, 9, 5, 1, 4, 3, 8]
];
```

**Merging the Input Matrix:** The input function takes a 3x3 square (denoted as s). To simplify operations on this matrix, I merge it into a one-dimensional array. This flattening process facilitates easier access and comparison of the input square's elements with those of the predefined magic squares.
```javascript
const allInOne = [...s[0], ...s[1], ...s[2]];
```

**Calculating the Transformation Cost:** For each predefined magic square, I calculate the cost of transforming the input square into this magic square. The reduce method accumulates the absolute differences between corresponding elements of the input square and a magic square. After iterating through all possible magic squares, the minimum transformation cost is determined.
```javascript
let lesserCost = Number.MAX_SAFE_INTEGER;
magicSquares.forEach(x => {
    let totalCost = x.reduce((acc, magicValue, index) => {
        return acc + Math.abs(magicValue - allInOne[index]);
    }, 0);
    lesserCost = Math.min(totalCost, lesserCost);
});
```
Here's the final output
```javascript
function formingMagicSquare(s) {
    // will convert this one programatically
    const magicSquares = [
        [8, 1, 6, 3, 5, 7, 4, 9, 2],
        [4, 3, 8, 9, 5, 1, 2, 7, 6],
        [2, 9, 4, 7, 5, 3, 6, 1, 8],
        [6, 7, 2, 1, 5, 9, 8, 3, 4],
        [6, 1, 8, 7, 5, 3, 2, 9, 4],
        [8, 3, 4, 1, 5, 9, 6, 7, 2],
        [4, 9, 2, 3, 5, 7, 8, 1, 6],
        [2, 7, 6, 9, 5, 1, 4, 3, 8]
    ];

    const allInOne = [...s[0], ...s[1], ...s[2]]
    let lesserCost = Number.MAX_SAFE_INTEGER;
    magicSquares.forEach(x => {
        let totalCost = x.reduce((acc, magicValue, index) => {
            return acc + Math.abs(magicValue - allInOne[index]);
        }, 0);
        lesserCost = Math.min(totalCost, lesserCost);
    })    

    return lesserCost;
}

```

Voilà! That's it. I hope you like my solution :)
When you're looking for a remote job,what do you care about?🤔
Tags: discuss, career, remote, remotework
Published: 2024-03-09 12:05:16


When we work remotely, we don’t need to spend a lot of time driving or taking public transportation to go to the office. We can even decide our own working hours and locations. We can travel and work at the same time. So, what do you care about when you are looking for a remote job?

- ~~💰Salary~~ (Everyone cares)
- 🌎Location: Work from home? Work from anywhere?
- 🕑Time: flexible working hours? four days a week?
- ❤️Benefits: Insurance? 401(k) plan? Stock?
- More others? Welcome to comment and discuss💬

> Find a remote jobs? Try this👇

> {% embed https://dev.to/remotewlb/remotewlba-remote-jobs-aggregation-board-36kg %}
Where to enjoy a great meal and drinks and downtown Napa | Downtown Joe's
Published: 2024-03-09 11:58:43

Downtown Napa embodies everything you could want in a Napa Valley getaway. There’s a wide variety of things to do and see, with the once-sleepy Southend town having gone through a beautiful renaissance over the past decade. Here you’ll find inviting wine-tasting rooms, lovely river walks, great lodging, and, of course, [Downtown Joe’s.](https://www.downtownjoes.com/where-to-enjoy-a-great-meal-and-drinks-and-downtown-napa/)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/04wvcfoiybzy0egvzdzj.jpg)
Hello World!
Tags: webdev, programming, opensource, typescript
Published: 2024-03-09 11:46:22


## 👋🏽 Greetings

`Hello World!`

Hi, I want to introduce myself. I'm Suneeh - a 27 y/o professional Fullstack Software Engineer from Bavaria/Germany.

## 🧐 Why am I here

I want to learn and explore new things I don't find the time for during my working hours. Since I am currently aiming for a promotion I want to spend my free time with coding for the next months and blogging helps to persist the learned techniques and building a portfolio.

## 📋 Tech Stack

- Angular
- .NET

But I might try different things over the time.

## 🚀 About me and my project

I was working for a small e-commerce company as a trainee for 2 years but I also had to do some sales and support, which I didn't like - so I got a new Job as a pure Developer which made me so much more happy. Sometimes I miss the old web shop stuff, that's why I decided to start a web shop project on the side.

I will try to blog consistently about my journey towards being a Senior here (I will abuse this as my daily standup tbh). 

## 📷 Socials

If you want to follow what I'm doing, feel free to comment, message me on [social media](https://www.instagram.com/_suneeh/) or pair program with me live on [twitch](https://www.twitch.tv/suneeh).

You can also find my code on [github](https://github.com/Suneeh).


## ✨ Daily Standup Over

Other than that, I have nothing to report for today.
All American Security Services
Published: 2024-03-09 11:43:53

Our company offers cutting-edge technology that transforms and enhances the work of the modern security officer. All American Security Services outperforms other security companies in the market because we equip the best officers with the best technology. All of our systems are implemented to promote enhanced job performance, and keep us vigilant in any emergency.

[broward security guard companies](https://www.allamericansecurityservices.com/)


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