teleren/devto huggingface dataset:
FEELING DIFFICULT TO FIND YOUR VOICE 😵‍💫🥴🤔
Published: 2022-07-08 17:27:27

🆗!!


Lemme help you out….

FIND YOUR #voice

So, let’s keep it straight.. no matter what #content you produce,

it needs to be in your own voice,

or style.

It should never seem like a copycat of someone else.

That said, it’s only by copying skilled #writers that you’ll find your own unique voice.

Typically,

creative #professionals go through

3️⃣ stages of #development —

✍🏻 imitation,
✍🏻 mastery and,
✍🏻 #innovation


So.. even if you start out reading and studying the styles of writers you admire.

You will learn to develop your own style eventually..


#️⃣TIP —

Here’s an exercise that can walk you through the process:

💫 Find 5 content writers whose style you enjoy reading

💫 Select one piece from each that is representative of their work, or that you enjoy reading.

💫 Select your favorite of the five writing samples, and read it slowly, word-for-word, out loud if necessary.


NOW… Study how that writer does it —

✔️ What the first sentence looks like.
✔️Format of introduction.
✔️How the article is structured.
✔️How the topic is developed and ideas presented.
✔️How the article is drawn to a close.
✔️What is call to action.


now… PRACTICE PRACTICE PRACTICE… !!



** If you still stuck somewhere.. I’m here to help ** (ALWAYS)


DM or 📧 [](https://www.linkedin.com/in/s0nali)Sonali Sood

For #contentwritingservices


For more #basics of #contentwriting + #contentwritingtips follow [Sonali Sood](https://www.linkedin.com/in/s0nali)


Do not FORGET to HIT the 🔔 ICON


P.S — I can be your writing saviour 🫣
Fix laravel/sanctum get /sanctum/csrf-cookie not updating cookie
Published: 2022-07-08 17:21:31

## Why why analysis...

- Why is it not updating cookie?
    - Because of incorrect `config/session.php`

- Why is it not correct?
    - Because the possible issue is
        1. `sameSite` is set to `lax` frontend and backend are on different domain eg. `http://192.168.1.2` vs. `http://192.168.1.3`
        2. `sameSite` is set to `none` but frontend domain is not on `https` domain

## Corrective Action:
    1. if `sameSite` is set to `lax` both domain should be same eg. `127.0.0.1:3000`(frontend) and `127.0.0.1:80`(backend)
    2. if `sameSite` is set to `none` `session.sucure` should be `true` and frontend domain must be on `https`
Refactoring as Anxiety Relief
Tags: productivity, architecture
Published: 2022-07-08 17:08:43


There’s a meta code smell I think about as the Anxiety Rug, the programmer’s parallel of moving the furniture around to avoid existential dread. It goes like this: a long file provokes your sensibilities, so you swipe it under the rug into a tree of files and folders; a shrunken scrollbar portends bad omens and demands a slew of micro helper / manager / servicer classes; a server has the audacity of trying to respond to more than one type of request, and is quickly shoehorned into its rightful place as a cog in the machine. This is reminiscent of “In Smalltalk, everything happens somewhere else”.

On the flip side, two eerily-similar-but-not-quite-the-same functions are turned into one basket case of conditionals and edge cases; a wrapper is introduced to orchestrate several functions and, little by little, accumulates fat and configuration options in between their seams; A group of services is identified as having some common functionality and authority is rolled over to a common governor which suddenly does too many things.

The cycle continues. On Mondays we say Don’t Repeat Yourself, on Tuesdays Everything Should Do One Thing and One Thing Only. A large part of programming is an inane battle of semantics. There is no free lunch in understanding a new codebase. No Zen in an all-in-one monolith, no bliss in a swarm of microservices. In between, a million different configurations, and no one will agree with you on the right one. Take a month, and you won’t even agree with yourself.

Some things — especially at the edge where software meets the real world and its needs — are inherently complex. Nothing we can do about it. No amount of shuffling and reorganizing and abstracting will make it go away. It is just a fact of the world. Some things are problems, and they can be solved. Others are difficulties, and they can only be recognized, then hopefully alleviated, and permanently endured. Differentiating between accidental and essential complexity is the Serenity Prayer of the programmer. Understanding which is which helps in dealing with the anxiety and saves pointless reorganization exercises.
1646. Leetcode Solution in CPP
Tags: cpp
Published: 2022-07-08 17:06:46

```
class Solution {
    vector<int> nums;
public:
    int getMaximumGenerated(int n) {
        if(n < 2) {
            return n;
        }
        nums.resize(n+1);
        nums[1] = 1;
        
        for (int i = 2; i <= n; i++) {
            if(i&1) {
                nums[i] = nums[i/2]+nums[(i/2)+1];
            }
            else {
                nums[i] = nums[i/2];
            }
        }
     
        return *max_element(nums.begin(), nums.end());
    }
};
```
#leetcode
#challenge
here is the link for the problem:
https://leetcode.com/problems/get-maximum-in-generated-array/
1945. Leetcode Solution in java
Tags: java
Published: 2022-07-08 16:53:19

```
class Solution {
    public int getLucky(String s, int k) {
        StringBuffer sb = new StringBuffer();
        int length = s.length();
        for (int i = 0; i < length; i++) {
            char c = s.charAt(i);
            int num = c - 'a' + 1;
            sb.append(num);
        }
        int sum = 0;
        int digitLength = sb.length();
        for (int i = 0; i < digitLength; i++) {
            int digit = sb.charAt(i) - '0';
            sum += digit;
        }
        for (int i = 2; i <= k; i++)
            sum = convert(sum);
        return sum;
    }

    public int convert(int num) {
        int sum = 0;
        while (num > 0) {
            sum += num % 10;
            num /= 10;
        }
        return sum;
    }
}
```
#leetcode
#challenge
here is the link for the problem:
https://leetcode.com/problems/sum-of-digits-of-string-after-convert/
1925. Leetcode Solution in CPP
Tags: cpp
Published: 2022-07-08 16:48:56

```
class Solution {
 public:
  int countTriples(int n) {
    int ans = 0;
    unordered_set<int> squared;

    for (int i = 1; i <= n; ++i)
      squared.insert(i * i);

    for (const int a : squared)
      for (const int b : squared)
        if (squared.count(a + b))
          ++ans;

    return ans;
  }
};

```
#leetcode
#challenge
here is the link for the problem:
https://leetcode.com/problems/count-square-sum-triples/
1913. Leetcode Solutoin in CPP
Tags: cpp
Published: 2022-07-08 16:45:36

```
class Solution {
 public:
  int maxProductDifference(vector<int>& nums) {
    int max1 = INT_MIN;
    int max2 = INT_MIN;
    int min1 = INT_MAX;
    int min2 = INT_MAX;

    for (const int num : nums) {
      if (num > max1) {
        max2 = max1;
        max1 = num;
      } else if (num > max2) {
        max2 = num;
      }
      if (num < min1) {
        min2 = min1;
        min1 = num;
      } else if (num < min2) {
        min2 = num;
      }
    }

    return max1 * max2 - min1 * min2;
  }
};

```
#leetcode
#challenge
here is the link for the problem:
https://leetcode.com/problems/maximum-product-difference-between-two-pairs/
1909. Leetcode Solution in Cpp
Tags: cpp
Published: 2022-07-08 16:44:40

```
class Solution {
 public:
  bool canBeIncreasing(vector<int>& nums) {
    bool removed = false;

    for (int i = 1; i < nums.size(); ++i)
      if (nums[i - 1] >= nums[i]) {
        if (removed)
          return false;
        removed = true;  // remove nums[i - 1]
        if (i > 1 && nums[i - 2] >= nums[i])
          nums[i] = nums[i - 1];  // remove nums[i] instead
      }

    return true;
  }
};

```
#leetcode
#challenge
here is the link for the problem:
https://leetcode.com/problems/remove-one-element-to-make-the-array-strictly-increasing/
1903. Leetcode Solution in Java
Tags: java
Published: 2022-07-08 16:43:23

```
class Solution {
    public String largestOddNumber(String num) {
        for (int i = num.length() - 1; i >= 0; i--) {
            char c = num.charAt(i);
            int digit = c - '0';
            if (digit % 2 != 0)
                return num.substring(0, i + 1);
        }
        return "";
    }
}
```

#leetcode
#challenge
here is the link for the problem:
https://leetcode.com/problems/largest-odd-number-in-string/
Paracetamol.js💊| #162: Explica este código JavaScript
Tags: javascript, webdev, spanish, programming
Published: 2022-07-08 15:33:09

## **<center>Explica este código JavaScript</center>**
#### <center>**Dificultad:** <mark>Intermedio</mark></center>

```js
console.log({...[1,2,3]})
console.log({..."hola"})
```

A. `{ [1,2,3] }`, `{ hola:"hola" }`
B. `{ 0:1, 1:2, 2:3 }`, `{ 0:"h", 1:"o", 2:"l", 3:"a" }`
C. `{ 1, 2, 3 }`, `{ "hola" }`
D. `Ninguna de las anteriores`

Respuesta en el primer comentario.

---

Respuesta:
B. `{ 0:1, 1:2, 2:3 }`, `{ 0:"h", 1:"o", 2:"l", 3:"a" }`

Tanto arreglos con cadenas son elementos iterables, por ello cuando aplicamos el operador spread los índices del iterable se convierten en claves y los elementos (para arreglos) y caracteres para cadenas) representan los valores respectivamente.
1844. Leetcode Solution in Java
Tags: java
Published: 2022-07-08 16:42:18

```
class Solution {
    public String replaceDigits(String s) {
        char[] array = s.toCharArray();
        int length = array.length;
        for (int i = 1; i < length; i += 2) {
            char letter = array[i - 1];
            int digit = array[i] - '0';
            array[i] = (char) (letter + digit);
        }
        return new String(array);
    }
}
```
#leetcode
#challenge
here is the link for the problem:
https://leetcode.com/problems/replace-all-digits-with-characters/
1742. Leetcode Soluiton in Cpp
Tags: cpp
Published: 2022-07-08 16:41:20

```
class Solution {
public:
    int countBalls(int lowLimit, int highLimit) {
        unordered_map<int, int> cnt;
        int ans = 0;
        for (int i=lowLimit; i<=highLimit; ++i) {
            int s = 0;
            for (auto x=i; x; x/=10)
                s += x % 10;
            ans = max(ans, ++cnt[s]);
        }
        return ans;
    }
};
```
#leetcode
#challenge
here is the link for the problem:
https://leetcode.com/problems/maximum-number-of-balls-in-a-box/
1773. Leetcode Solution in Cpp
Tags: cpp
Published: 2022-07-08 16:39:54

```
class Solution {
 public:
  int countMatches(vector<vector<string>>& items, string ruleKey,
                   string ruleValue) {
    const int index = ruleKey == "type" ? 0 : ruleKey == "color" ? 1 : 2;
    return count_if(begin(items), end(items),
                    [&](const auto& item) { return item[index] == ruleValue; });
  }
};

```
#leetcode
#challenge
here is the link for the problem:
https://leetcode.com/problems/count-items-matching-a-rule/
Perceptron
Tags: deeplearning, ai, machinelearning, perceptron
Published: 2022-07-08 16:38:21

## Perceptron Model

You can think of it as a basis of neural network. The motivation for perceptron is taken from the human neuron.

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

Input are going to neuron which perform some sort of computation on it in order to give the output. The functionality inside the neuron is often referred as **Activation Function**. 

Now, in order to do the learning we need to adjust some parameters these parameters are known as **weights**. These weights get multiplied to the input.


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

There is still a problem. What if the input is zero? Doesn't matter what change we do to the w nothing is going to happen. In order to solve this problem we will add a bias to each input.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/908m8hu8kkyuzlucw9uf.png)
 
The interesting thing is the multiplication of input and it's weight has to overcome the bias in order to have some effect on the output.

The value of both the weight and bias can be positive and negative.

Mathematically our generalisation is 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yk96r4df4irj14t7siak.png)
1763. Leetcode Solution in java
Tags: java
Published: 2022-07-08 16:35:38

```
class Solution {
    public String longestNiceSubstring(String s) {
        int maxLength = 0;
        String longest = "";
        int length = s.length();
        for (int i = 0; i < length; i++) {
            for (int j = i + 1; j <= length; j++) {
                String substr = s.substring(i, j);
                if (isNice(substr)) {
                    if (substr.length() > maxLength) {
                        maxLength = substr.length();
                        longest = substr;
                    }
                }
            }
        }
        return longest;
    }

    public boolean isNice(String s) {
        Set<Character> set = new HashSet<Character>();
        int length = s.length();
        for (int i = 0; i < length; i++)
            set.add(s.charAt(i));
        for (int i = 0; i < length; i++) {
            char c = s.charAt(i);
            char difCase = c <= 'Z' ? (char) (c + 'a' - 'A') : (char) (c - 'a' + 'A');
            if (!set.contains(difCase))
                return false;
        }
        return true;
    }
}
```
#leetcode
#challenge
here is the link for the problem:
https://leetcode.com/problems/longest-nice-substring/
PHP IMAP - NO OAuth!!! - MUST READ
Tags: php, imap, oauth, outlook
Published: 2022-07-08 16:34:19

I'm here with a sad😔 story, in the last two year both Google and Microsoft annunced to ban from the BASIC login IMAP service.

![TRIGGERED](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4jcvbychnb1vuanxhcnf.gif)
 
All PHP application are based on the standard PHP IMAP, extension it works well for 90% of cases, but what NOW??

In fact, standard PHP IMAP not goes with OAuth. That's the gold mine for me. I'm looking for million dollar project to push my career up on the Open Source Olympus. I hope it's the time.

Please rate my project ⭐

https://github.com/javanile/php-imap2

Spread the voice 📣

---

Read more here 🔥

https://github.com/ddeboer/imap/issues/443#issuecomment-1172158902
Setup your fancy terminal
Tags: zsh, shell, terminal
Published: 2022-07-08 16:33:35

## ﻿Setup your fancy terminal
Using your shell with Oh My Zsh and Starship on macOS

Some use [fish shell](https://fishshell.com/) as it is an interactive, user-friendly, and modern shell. But it does not have POSIX sh compatibility. Using fish as your default shell could break part of your system. In this post, I will focus on zsh. With powerful plugins. You can have a powerful interactive interface.

## Install [Z shell (zsh)](http://www.zsh.org/)

```bash
brew install zsh
```

## Install [Oh My Zsh (omz)](https://ohmyz.sh/)

```bash
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
```

## Set zsh as your default shell

```bash
chsh -s /usr/local/bin/zsh
```

## Install [Oh My Zsh plugins](https://github.com/zsh-users)

Clone [zsh-autosuggestions](https://github.com/zsh-users/zsh-autosuggestions.git), [zsh-syntax-highlighting](https://github.com/zsh-users/zsh-syntax-highlighting.git) and [zsh-completions](https://github.com/zsh-users/zsh-completions.git).

```bash
git clone https://github.com/zsh-users/zsh-autosuggestions.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

git clone https://github.com/zsh-users/zsh-completions.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-completions
```

Add the plugin to the list of plugins for Oh My Zsh to load (inside ~/.zshrc):

```
plugins=( 
    # other plugins...
    zsh-autosuggestions
    zsh-syntax-highlighting
    zsh-completions
)
```

## [Starship.rs](http://starship.rs/) (a fast fancy prompt written in Rust)


You need [Nerd Font](https://www.nerdfonts.com/) installed and enabled in your terminal.

We will install [Fira Code Nerd Font](https://www.nerdfonts.com/font-downloads).

```bash
brew tap homebrew/cask-fonts
brew install --cask font-fira-code-nerd-font
```

Open your terminal preferences and enable the font you've just downloaded.

```
⌘,
```

Add the following to the end of `~/.zshrc`:

```
eval "$(starship init zsh)"
```

## Result

![Terminal screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/macj1pii2j2whysky6o2.png)
1752. Leetcode Solution in CPP
Tags: cpp
Published: 2022-07-08 16:32:07

```
class Solution {
 public:
  bool check(vector<int>& nums) {
    const int n = nums.size();
    int rotates = 0;

    for (int i = 0; i < n; ++i)
      if (nums[i] > nums[(i + 1) % n] && ++rotates > 1)
        return false;

    return true;
  }
};

```
#leetcode
#challenge
here is the link for the problem:
https://leetcode.com/problems/check-if-array-is-sorted-and-rotated/
Rails or Express?
Tags: rails, javascript, webdev
Published: 2022-07-08 16:21:41

Ruby on Rails and Express.js are a couple of popular choices for developing a backend for web apps and both have their strengths and weaknesses. 

## Ruby on Rails

For my bootcamp we were taught Ruby/Rails and how to create a working web application with either the use of a frontend framework (React, Vue, etc.) or use the built-in MVC that Rails comes packed with.

Rails is fully featured and comes with about every tool one would need to get deployed and has it's own Gemfile with some common packages left in comments in case it will be needed, bcrypt is the one that comes to mind first. A lot of the building of the source is opinionated and is fairly easy for any other developer to go through the code and collect the objective for the backend purpose.

Along with all that it's packed with, Rails has the ability for ease of setup, such as an API flag, templating, or initializing the SQL database for the project (postgresql, mySQL).

## Express

Express was the first technology I went looking into after graduating since most employers and looking for experience using Node.js or worked with MERN/MEAN stack.

Upon following a short tutorial on doing to reading how express works and how it makes the life of the developer easier by cutting the amount of lines to get a server up and running. While Express is not as feature packed as Rails is, installing packages becomes fairly routine with any Node/JavaScript project and nearly goes overlooked after the 100+ time of using `npm install`.

While having a Node server using the Express framework as the backbone, there is a bit of freedom I felt while writing a backend. When writing the MVC, aside from React handling the views, it was nice have a shorter file structure all while having the functionality that I required the same as a Rails app.

## Conclusion

While a closer comparison with Sinatra might be more appropriate, my choices for backends, at the current time, is between Rails or Express.

As such, Rails is feature rich which is both good getting a web application up and running and bad for it having all the packages which can make it slow to work with.

Express is the lightweight option which will be faster to run and becomes more customizable, but will inevitably take more lines of code to create the same level of functionality as the Rails server would be able to do.
Simple Kanban in React
Published: 2022-07-08 16:15:25

Hey Devs!, I have been building an example of a Simple Kanban in React. 

Repo: 
https://github.com/ionmx/simple-kanban-react

Demo: 
https://simple-kanban-six.vercel.app/

It features:

- Uses beautiful-drag-dnd to drag and drop columns and tasks
- Create, edit and delete boards, columns and tasks
- Have implemented 2 backends:
  - Rails: 
    https://github.com/ionmx/simple-kanban-ror
  - Phoenix: 
    https://github.com/ionmx/simple_kanban_phx

The main idea of this project is to have a more elaborated example than the classic To-Do app to learn tech stacks.

You can take a look to the front-end and back-end code, so you can learn about the implementation. You can implement new back-ends (e.g. Express/Prisma) or new front-ends (e.g. Vue, Svelte).
PDF Reviewer (3) - The Architecture
Tags: pdfreviewer, springboot, angular, pdfjs
Published: 2022-07-08 16:08:32

[PDF Reviewer](https://www.pdfreviewer.com/) is a cloud-based service that enables users to annotate PDF files in Markdown syntax, with support for Latex Equations. It is a paid service with free trial (until Aug 31, 2022), but no credit card is needed for the trial. Readers are encouraged to check it out.

Internet services are not only simple web pages. There are some complex modules behind the scene. So is our service. Following is the architecture.

![PDF Reviewer Architecture](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ndtj8n6qs5ue1xsfqtzn.png)

There're multiple components:

1. **The Portal**. It serves what visitors will see when they visit [PDF Reviewer](https://www.pdfreviewer.com/). It is built on top [Angular 13](https://angular.io/).
2. **The Viewer**. It serves a PDF viewer which is built on top of the [Mozilla PDF.js library](https://github.com/mozilla/pdf.js). Another component is the [**PouchDB**](https://pouchdb.com/) library, which we use to store annotations locally. 
3. **The Server**. All the service code that backs the website. It is built on top of the famous [Spring Boot](https://spring.io/projects/spring-boot) framework.
4. The **PostgreSQL** database. It stores user session information, the credential token when users are authorized via the login button, and PDFs file information.
5. The **Object Storage**. It stores PDF files.
6. The [**Apache CouchDB**](https://couchdb.apache.org/) server. It stores Annotation data.
7. The [**Google Account**](https://account.google.com/) service. It is not a part of our service, but provides user credential management for our service.
Think Globally…
Tags: opensource, microservices, devjournal, luos
Published: 2022-07-08 16:01:34

If you use distributed applications and containers for your project, you can easily create sub-applications that can handle a task and communicate with the containers they need. The concept of microservices in the embedded world.

⏩ https://www.luos.io/blog/think-globally

Read this article to understand Luos benefits and vision. How to write an application inside a container witch can communicate with other containers?

#microservices #opensource #embedded
1700. Leetcode Solution in Java
Tags: java
Published: 2022-07-08 15:55:17

```
class Solution {
    
    public int countStudents(int[] students, int[] sandwiches) {    
        LinkedList<Integer> studentQueue = new LinkedList<>();
        int len = students.length;
        for (int i = 0; i < len; i++) {
            studentQueue.offer(i);
        }
        
        int lastQuery = -1;
        int sIdx = 0;
        
        while (sIdx < len) {
            if (studentQueue.peekFirst() == lastQuery) {
                break;
            } else if (students[studentQueue.peekFirst()] == sandwiches[sIdx]) {
                studentQueue.pollFirst();
                lastQuery = -1;
                sIdx++;
            } else {
                Integer tmp = studentQueue.pollFirst();
                studentQueue.offer(tmp);
                if (lastQuery == -1) {
                    lastQuery = tmp;
                }
            }
        }        
        
        return studentQueue.size();
    }
}
```
#leetcode
#challenge
here is the link for the problem:
https://leetcode.com/problems/number-of-students-unable-to-eat-lunch/