teleren/devto huggingface dataset:
Sum of Two Integers without Arithmetic operators
Tags: dsa, python
Published: 2022-02-18 16:38:33

##Instructions
Given two integers a and b, return the sum of the two integers without using the operators + and -.

## Approach
We cannot use arithmetic operators, so we have to use bit manipulation to achieve addition.
The XOR operator is useful for bit manipulation where its output is shown below.

```
1^1=0
0^0=0
0^1=1
```
From the code above we observe that 1^1=0 which is not equal to 1+1. We can use the AND(&) operator to handle carry to calculate the correct answer. We shift the carry to the left and repeat the operations until we get a result of 0 meaning there are no more carries. 

Here is an example:

![XOR AND <<](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w5xpd32inpjhp08moajq.jpeg)
##Python Implementation

```python
def getSum(self, a: int, b: int) -> int:
        while (b != 0):
            carry = a & b
            a = a ^ b
            b = carry << 1
        return a
```
The time complexity is 0(n).
The solution is sufficient for most scenarios but we can improve it by consider that the range of bits for representing a value is not 32 in Python.
Therefore, we have to use a 32 bit mask of 1's represented by 0xfffffff.
The mask expands a number into a 32 bit / unsigned integer.
Our solution becomes:

```python
def getSum(self, a: int, b: int) -> int:    
        mask = 0xffffffff
        while (b & mask) > 0:
            carry = (a & b) << 1
            a = (a ^ b)
            b = carry
        return (a & mask) if b > 0 else a
```

##Approach 2
We can use logarithms to achieve the same result.
From  our knowledge of logarithms, we know that 

- 2 <sup>a</sup> x 2 <sup>b</sup> = 2 <sup>a+b</sup> and 

- log <sub>a</sub> (a <sup>n</sup>)= n therefore,

- log <sub>2</sub> (2 <sup>a+b</sup>)= a+b
###Python Implementation

```python
def getSum(self, a: int, b: int) -> int: 
    return int(math.log2(pow(2,a)*pow(2,b)))
```


####Useful Links

[Mask](https://leetcode.com/problems/sum-of-two-integers/discuss/489210/read-this-if-you-want-to-learn-about-masks)
[Mask](https://leetcode.com/problems/sum-of-two-integers/discuss/1665450/python-bit-manipulation-masking-explanation)
What causes imposter syndrome among software developers?
Tags: javascript, webdev, imposter, security
Published: 2022-02-18 16:35:08

Imposter syndrome is defined as “a collection of feelings of inadequacy that persist despite evident success.” It’s also referred to as the imposter phenomenon. Some believe imposter syndrome occurs due to an individual feeling they don’t belong in their line of work. They believe others feel the same way about them.

## “The imposter syndrome can be caused by external or internal factors.”

Internal factors would be things like a person not being able to learn new material, difficulty with time management, and one-on-one interactions with people because they’re afraid they’ll say something stupid.  External factors could stem from things such as money problems, which cause a person stress and impact their confidence levels.

## Self-efficacy, or the feeling that your skills are up to par with what’s expected of your.

 When impostor syndrome strikes, it can result in a lack of self-efficacy, especially when the imposter believes they’re not living up to standards or being as productive as they could be.” This also lends itself to time management issues because they believe they have less time than others who have similar responsibilities. If an imposter seems to be having trouble learning new material, this may very well relate back to their lack of self-efficacy.

## “The impostor complex is also linked to perfectionism and fear of failure.”

 Perfectionism is all about impressing others and impostor syndrome happens when a person feels they’re not impressing people enough.  They’ll obsess over mistakes or past failures that have nothing to do with their current job, believing this is impostor syndrome manifesting itself.

## In general, imposter syndrome tends to affect women more than men.”

Women may be more likely to feel impostor syndrome because of the way society has conditioned them from a young age. They often learn they have to work twice as hard as men in order to get half the recognition for doing something of equal value. This can cause self-doubt and feelings they don’t belong in certain roles or professions despite excelling at their position or having relevant skills and experience.

## It can be a problem that persists for years, and imposter syndrome is to blame.

It prevents people from reaching their full potential in the workplace.” The constant feeling of being inadequate keeps one from climbing the corporate ladder or being promoted to roles they might be able to excel at if impostor syndrome wasn’t holding them back.

READ MORE:

Mistakes that Junior Software Developers Make While Having an Interview
Why Programmers experience Imposter Syndrome
Minimum Viable Product vs. Minimum Lovable Product
Tags: product, backlog, management, market
Published: 2022-02-18 16:34:11

**MVP vs MLP**

Recently I have started working with a client who uses the MLP principle for their product management. 
I have always worked on the MVP style and never thought of challenging it. But now that I have been introduced to this way of thinking (I am not calling it new because MLP could be around for some time and I only now I have heard of it 🙄)

![under the rock](https://media.giphy.com/media/pxJ1yS3YtSHL7IMqCu/giphy.gif)


**MVP:** The idea is to come up with a minimum set of features/functionalities in a product with which you can take it into the market and get instant feedback aka to fail-fast and build upon it.

**MLP:** Here the idea is to focus on what your end-user will love. So, you set out to build a product with the least possible number of features, yet lovable by your users/customers. Hence, it's not essentially the fail-fast approach, but the opposite of it where you get them to like your product as soon as it hits the market. 

I am still going through the adoption & understanding of MLP, but my take is that it is a lot better than MVP in most cases (I say most because there are some cases where MVP works better, please read on…)

MLP focuses on customers first and to me, that is a winner from the get-go. How many times have we used products which are half-baked and leave us frustrated? 
Because the focus is customer, focus on customer research is done beforehand. Unlike in MVP, we expect customers to tell us on product launch what they don't like or what they expect from it. 

I come from a software background, and I think having MLP in place forces us to think about the architecture well in advance. We know our customer needs and challenges are and we can plan our architecture accordingly. 

However, I do see why MLP is not for everyone. First of all, it's expensive to do in-depth market research. The other issue is what if you are building a brand new product with a very little know consumer base? In this case, trialing an MVP based on some business analysis makes sense.

This is a very subject post based on my opinion, but I would love to hear from you all out there.
![alt image](https://media.giphy.com/media/xPYhbdLdxdyWKamutx/giphy.gif ):
This Pi technology saved my life.
Tags: raspberrypi
Published: 2022-02-18 16:20:11

My laptop was broken and I didn't have the money to buy one. But luckily a few weeks before I had ordered a **raspberry pi 400** just for testing it. Surprisingly, the resources of this little hardware were enough to do the job.
during this period I worked on a website project. It was difficult at the start but after it was easy. The only stuff with this hardware it's you must be creative.

**some recommendations before trying this hardware:**

- _have a monitor to connect your raspberry pi 400._
- _have a basic knowledge of the Linux terminal._
- _be someone curious and so on._
Writing fashionable functional code
Published: 2022-02-18 16:15:38

---
title: Writing fashionable functional code
published: true
description: 
tags: 
//cover_image: https://direct_url_to_image.jpg
---

Old and boring code:

```typescript
interface Authenticated {
  isAuthenticated: true
  username: string
  firstName?: string
}

interface Anonymous {
  isAuthenticated: false
}

type User = Authenticated | Anonymous 

function greet(user: User) {
   if(user.isAuthenticated) {
      return 'Hello ' + (user.firstName || user.username)
   } else {
      return "I don't talk to strangers, bye"
   }
}

```

It's functional, it's not bad, but it lacks in style. We need more swag! Monads are all the rage nowadays. Functional code without monads ain't no functional code. Let's throw in some to make code look more hip

```typescript
interface Authenticated {
   username: string
   firstName: Option<string>
}

interface Anonymous {
}

function greet(someone: Either<Authenticated, Anonymous>) {
   return someone
       .mapLeft((user) => 
         'Hello ' + user.firstName
               .getOrElse(user.username))
       .orElse(() => "I don't talk to stranges, bye")
}
```
How much better is this? Infinitely better!

And did you also noticed, we didn't just add swag, we removed the unnecessary boolean isAuthorized! We can identify users from anonymous by their political leaning left or right*. Less business specific jargon, more generalizations, better code!

Which style do you prefer more? Leave comment.

*Monad inspired APIs, for example fp-ts, frequently refer to one of two possible types of values either as 'left' or 'right'
My First Quarter Goals for 2022
Tags: webdev, beginners
Published: 2022-02-18 15:59:19

2021 was quite the unproductive year and although I still learned a lot, I wasn't able to make full use of my available time that could've helped me achieve more. I think one of the main reasons why I underachieved was that I didn't set any goals for myself. I just went through my days, doing what it is I feel like doing along with my school works which to be honest, I did not like. Enough rambling from me. 

##My Main Goals
1. Create a website for a Non-profit Organization or a Charity, for free.
2. Create a Personal Website Portfolio
3. Organize my Github Profile
4. Keep Learning!

##Footnote
I decided to write down some of my goals so whenever I post a blog and visit this website, I'll see them in my dashboard and hopefully motivate me to get through them.
Stylish Text Editor created with HTML, CSS, and JavaScript only
Tags: javascript, css, html, webdev
Published: 2022-02-18 15:47:11

Hello friends,
Hope you are doing great. I wanna share with you one website which I have created with HTML, CSS, and JavaScript only.

★彡 𝕍𝓲𝓼𝔦т η𝕠𝕎 彡★ - [https://stylishtexteditor.blogspot.com/] 

**(っ◔◡◔)っ ♥ Stylish Text Editor ♥ **

Stylish Text Editor (Font Generator) is the most popular free online tool for creating unique, stylish fonts with a variety of fancy font styles. Stylish Text Editor is used by millions of people as a fancy text creator to create cute fonts to copy and paste.

To create the cool and trendy text, simply type or paste your text into the textbox and let the Stylish Texting do the rest. When you're finished, the fancy text algorithm will convert several styles of cool, cute, and fancy fonts for you, which you can copy and paste anyplace. To copy and paste fancy font online, Stylish Text Editor is the finest free online fancy font generator alternative to Font Generator, Lingo jam, Yaytext, Cool symbol, and Fsymbols.

Stylish Text Editor lets you copy and paste any cool fancy text by simply clicking the copy button. The nicest part about the Stylish Text Editor is that the fancy text it generates is compatible with most devices and apps. You may use cool fancy writing in your Instagram bio, Facebook posts, WhatsApp chats, Twitter tweets, and anywhere else online. Also, check out some of the other fantastic Stylish Text Editors developed just for you!
Escribir como programar
Tags: programming, writing, spanish
Published: 2022-02-18 15:47:00

Desde que empecé a escribir textos (de ficción o no ficción), lo hago como si estuviera escribiendo un programa de computadoras. ¿Qué significa esto? Voy a intentar explicarlo.

[https://www.contramar.org/index.php/2022/02/13/escribir-como-programar/](https://www.contramar.org/index.php/2022/02/13/escribir-como-programar/)
Indian Nurses hub
Published: 2022-02-18 15:46:15

Indian Nurses hub

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7dr4tq9pt9fiw6xcd57t.jpeg)
Indian nurses hub is a association of Registered Nurses and Nursing Students
Indian Nurses hub association is comprised of nursing majors and those interested in the profession of nursing
Indian nurses hub work to provide opportunity for personal , intellectual, professional and social growth of its members.
The Indian Nurses Hub was established to address the problems, inequities and problems prevalent in the field of nursing education and nursing medicine. Due to the efforts made by the organization, the nursing education and medical world is getting strengthened and the efforts of improvement by the organization are going on continuously as there is a great need for improvement in the field of nursing education and medicine.

The National President of Indian Nurses Hub is Mr. Prem Miral who is always in the forefront of Nursing interests Work to take the problems related to the nursing profession to the government through tweets, strikes, letters
Run glances without install with pipx
Tags: python
Published: 2022-02-18 15:40:02

---
canonical_url: https://waylonwalker.com/til/pipx-run-glances/
published: true
tags:
- python
series: til
title: Run glances without install with pipx
---

Glances is a fully featured system monitoring tool written in python.  Out of the box it's quite similar to htop, but has quite a few more features, and can be ran without installing anything other than `pipx`, which you should already have installed if you do anything with python.


``` bash
pipx run glances
```

Once you run this you will be in a tui application similar to htop.  You can kill processes with k, use left and right arrows to change the sorting column, and up and down to select different processes.

![running pipx run glances on my ubuntu 21.10 machine inside the kitty terminal](https://images.waylonwalker.com/pipx-run-glances.png)

## Links

* [pipx](https://pypa.github.io/pipx/)
* [website](https://nicolargo.github.io/glances/)
* [docs](https://glances.readthedocs.io/en/latest/index.html)
* [github](https://github.com/nicolargo/glances)
Opening my app with 'yarn start' : error Command failed with exit code 1
Tags: react
Published: 2022-02-18 15:34:24

I'm beginner with React. My first app as exercice work well. But for next exercices I have to download a file from GitHub.

[This one for exemple](https://github.com/OpenClassrooms-Student-Center/7008001-Debutez-avec-React/tree/P2C2-Solution)

So, I download the file, unzip it, open the unzipped file from vsCode, everything opens, everything looks ok.

I do 'yarn start' as with my first app and this is what is displayed in my Terminal:

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


What does it mean ?
Arrays in JS
Tags: javascript, webdev, beginners, programming
Published: 2022-02-18 15:32:18

# Arrays in JS

## Declaration
`const a = []
const a = Array()`

## pre-fill the array 
`const a = [1, 2, 3]
const a = Array.of(1, 2, 3)`

## An array can hold any value, even values of different types:

`const a = [1, 'Flavio', ['a', 'b']]`

`const matrix = [
  [1, 2, 3],
  [4, 5, 6],
  [7, 8, 9]
]

matrix[0][0] //1
matrix[2][0] //7`

## Declare and define arrays at same time
`Array(12).fill(0)`

## Length of array
`const a = [1, 2, 3]
a.length //3`

## How to add an item to an array
### At the end
`a.push(3);`

### at the beginning of an array 
`a.unshift(5);`

## How to remove elements from the array

### remove an item from the end of an array using the pop() method:

`a.pop()`

### remove an item from the beginning of an array using the shift() method:

`a.shift()`

## How to join two or more arrays

### You can join multiple arrays by using concat():

`const a = [1, 2]
const b = [3, 4]
const c = a.concat(b) //[1,2,3,4]`

### spread operator (...) in this way:
`
const a = [1, 2]
const b = [3, 4]
const c = [...a, ...b]
c //[1,2,3,4]`

## How to find a specific item in the array

### You can use the find() method of an array:

`a.find((element, index, array) => {
  //return true or false
})`

### A commonly used syntax is:
`
a.find(x => x.id === my_id)`


`a.findIndex((element, index, array) => {
  //return true or false
})`

### Another method is includes():

`a.includes(value)
Returns true if a contains value.
a.includes(value, i)
Returns true if a contains value after the position i.`


Thanks for reading <3
Blockchain development
Tags: blockchain, web3
Published: 2022-02-18 15:27:30

The current expansion of Web 3 and Blockchain development has created several new oppoertunities. if you're interested in becoming a blockchain developer, this blog is for you:

**who is a Blockchain Developer?**
Blockchain Devs are the ones who are incharge of optimizing and building blockchain-related applications like consensus protocols, dApps, smart contracts, design architecture systems.

**Types of Blockchain Development**

1. Core Blockchain Developemnt

2. Blockchain Software Development

**Core Blockchain Development**
It involves directly working with protocols and improving consensus protocols to meet the needs of the needed applications.
_Core Blockchain Developers build the architecture of the blockchain_

**Blockchain Software Development**
This is the development that most people think of when they hear the term **Blockchain Development**
They are the ones that create decentralized blockchain apps using protocols created by **Core Blockchain Developers**

**How to get started**
First and foremost, learn the fundamentals. Make sure to understand the basics, just as you would with any other technology!
Understand the process. it is critical to understand how things function behind the scenes. it helps while learning
Before you dive into Web 3 and Blockchain, it is essential to understand basic web development concepts such as HTML and JavaScript or its framework like React.

**learn to write smart contracts**
They are an essential component of any blockchain ecosystem, each blockchain has its own language that you can use to write smart contracts. 
Example:
Ethereum -> Solidity
Solana -> Rust

Lastly join communities and build projects
Process Analytics - January 2022 News
Tags: news, opensource, typescript, bpmn
Published: 2022-02-18 15:19:01

Welcome to the Process Analytics monthly news 👋.

As you know, the goal of the Process Analytics project is to rapidly display meaningful Process Analytics components in your web pages using BPMN 2.0 notation and Open Source libraries.

2021 is over 🥺. Welcome 2022! 🥳 🎉 On our side, the project team worked hard to prepare the 2022 Roadmap that will be detailed in the next 2022 news.

☃️ We also worked on improving the BPMN Visualization (JavaScript/TypeScript) library. Let’s see what’s new here 👀!

## BPMN Visualization JS/TS library

In January, we released 2 versions 📣: [0.21.2](https://github.com/process-analytics/bpmn-visualization-js/releases/tag/v0.21.2) & [0.21.3](https://github.com/process-analytics/bpmn-visualization-js/releases/tag/v0.21.3).

The library now generates a clearer error message when it is unable to parse the BPMN source ✨.

In previous releases, passing malformed content caused the 'load' function to throw an Error with an 'r is undefined' message 😱. It now handles the error correctly and returns a proper error message 💪.

In addition, a window alert was opened on load error. It should have been included only in the demo code and the examples 🤫, but not in the library code. This is now fixed and you can now fully control how you want to display errors in your application 🤗.

⏩ [The "load remote BPMN diagrams" example](https://cdn.statically.io/gh/process-analytics/bpmn-visualization-examples/v0.21.3/examples/display-bpmn-diagram/load-remote-bpmn-diagrams/index.html) has been updated to display load errors in a toast, as it already did for BPMN diagram fetch status. The recording below 👇 shows the new error management in action and the fixed BPMN load error message as well.


![Display load errors in a custom application](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ejurfe0qqtxht52i1dvw.gif)
*Display load errors in a custom application*

### Plans for the future

Here are the topics we will be addressing in the coming months:
-   Continue styling improvements for CSS usage and introduce an API to apply styles to specific BPMN elements 🦄.
-   Create new examples to demonstrate other process analytics / process mining use cases 🤩.

## That’s All Folks!

We hope you enjoyed this January project news and are looking forward to what February will bring 👋.

In the meantime, to stay on top of the latest news and releases, follow us through:
-   Website: [https://process-analytics.dev](https://process-analytics.dev/?utm_source=devto&utm_medium=display&utm_campaign=news)
-   Twitter: [@ProcessAnalyti1](https://twitter.com/ProcessAnalyti1)
-   GitHub: https://github.com/process-analytics

*Cover photo by [Benjamin LECOMTE](https://unsplash.com/photos/A0FL94En8qk?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) on [Unsplash](https://unsplash.com/?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText)*
TIL – Generate unique IDs with Crypto.randomUUID()
Tags: todayilearned, javascript
Published: 2022-02-18 15:18:04

---
title: TIL – Generate unique IDs with Crypto.randomUUID()
published: true
description: Today I learned that you can easily generate a v4 UUID using only a standardized web API.
tags: til, javascript
//cover_image: https://direct_url_to_image.jpg
---

Today I learned that you can generate UUIDs using the Web Cryptography API.

Here’s what it looks like:

```javascript
let uuid = self.crypto.randomUUID();
console.log(uuid); // “36b8f84d-df4e-4d49-b662-bcde71a8764f”
```

MDN docs: https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID
JavaScript one-liner puzzle: throw an error without using throw
Tags: javascript, puzzle, fundamentals, beginners
Published: 2022-02-18 15:17:29

Write a function that throws an error. Contstraints:

- do not use `throw`
- one line only
- simply returning an Error is not sufficient (since it's not thrown)
- function declaration must not throw the error, only execution should throw
- Syntax error is not allowed!
- max. ovarall characters for the code: 15

Tips:

- the function is not something you should ever use in your code
- think of fundamentals and what you learned about them
- it's marked `#beginners`, because it's way easier than you might think
- you can make pretty weird things with JavaScript