teleren/devto huggingface dataset:
Advent of code Day 17
Tags: adventofcode, adventofcode2021, programming, 42
Published: 2021-12-17 21:16:23

Nothing special to discuss this time.
I think I've done the dumbest exhaustive search ever, without even too much consideration to get good bounds.
The interesting bit is the formatting:
do you think this code is formatted ok? in 42 you can write in a very different style, and it is not clear how to format certain things.
```
reuse [L42.is/AdamsTowel]
Point = Data:{Num x, Num y}
Velocity = Data:{Num x, Num y}
Probe = Data:{
  var Point location = \(x=0Num,y=0Num)
  var Velocity velocity
  mut method Void step() = (
    (x,y) = \velocity
    \location(\location.with(x=\x+x).with(y=\y+y))
    \velocity(\velocity
      .with(x=0Num.max(x-1Num)).with(y=y-1Num))
    )
  }
Square = Data:{
  Num x1, Num x2, Num y1, Num y2
  method Bool #in1 (Point that)=
    that.x().isInRange(this.x1() to=this.x2()) 
    && that.y().isInRange(this.y1() to=this.y2())
  }

Main = (
  //input=S"target area: x=88..125, y=-157..-103"
  Square target=Square(
    x1=88Num x2=126Num y1=Num"-157" y2=Num"-102")
  result = 0Num.acc()(
    for x in Range(0I to=1000I),
    for y in Range(I"-300" to=1500I) (
      v = Velocity(x=\(x),y=\(y))
      p = Probe(velocity=v)
      res = 0Num.acc()(while !(p.location() in target) 
        ,,&& p.location().y()>=target.y1()
        ,,&& p.location().x()<=target.x2() ( 
        p.step() 
        \val(\val.max(p.location().y()))
        ))
      //Part1
      //if p.location() in target \val(\val.max(res))
      if p.location() in target \addOne()//Part2
      //\val(\val.max(res))
      )
    )
  Debug(result)//12246 and 3528
  )
```

For example, consider this part:

```
res = 0Num.acc()(while !(p.location() in target) 
  ,,&& p.location().y()>=target.y1()
  ,,&& p.location().x()<=target.x2() ( 
  p.step() 
  \val(\val.max(p.location().y()))
  ))
```
In 42 the comma (,) is just a spacing character like space and new line, so we can use it as often as we want. In practice, it can be used to distinguish different kinds of indentation.
Here I'm using it to differentiate the indentation of the long while condition and the indentation of the while body.
This is further complicated by the fact that the while is the argument of the #apply method of Num.Acc.

Ideas?
Subtree with Maximum Value
Tags: 100daysofcode, algorithms, java, programming
Published: 2021-12-17 21:04:10

# [Description](https://binarysearch.com/problems/Subtree-with-Maximum-Value)

Given a binary tree `root`, return the maximum sum of a subtree. A subtree is defined to be some node in `root` including all of its descendants. A subtree sum is the sum of all the node values in the subtree. A subtree can be null in which case its sum is `0`.

**Constraints:** 

- `1 ≤ n ≤ 100,000` where `n` is the number of nodes in `root`

## Example 1

### Input

```
root = [3, [0, null, null], [2, [0, null, null], null]]
```

![Untitled](https://s3-us-west-2.amazonaws.com/secure.notion-static.com/3fb1a47f-963b-4c92-94d4-c5a94de43ff2/Untitled.png)

### Output

```
5
```

# Intuition

# Implementation

```java
import java.util.*;

/**
 * public class Tree {
 *   int val;
 *   Tree left;
 *   Tree right;
 * }
 */
class Solution {
    private int max = 0;
    public int solve(Tree root) {
        dfs(root);
        return max;
    }

    private int dfs(Tree root) {
        if (root == null) {
            return 0;
        }
        int left = dfs(root.left);
        int right = dfs(root.right);
        int sum = left + right + root.val;
        max = Math.max(sum, max);
        return sum;
    }
}
```

## Time Complexity

- Time: O(n)
- Space: O(logn)
C++ complete roadmap
Tags: programming, tutorial, beginners, cpp
Published: 2021-12-17 21:03:34


Let's jump in!

If you are a beginner I will suggest you to make a time table of at least 45 days which will be sufficient in order to get a really good understanding of C++. Now, you can break your 45 days into 6 weeks and start with the concepts.

**1st Week**: Now, these seven days will introduce you to something that you have no previous knowledge of. So make sure you understand the foundations well and give a kickstart to the world of programming.

- What is C++?
- It’s history and features.
- Understanding and writing our first Hello World program in C++.
- Tokens
- Variables, Datatypes.
- Keywords
- How to take input from the user?
- Operators
  - Arithmetic Operators.
  - Logical Operators.
  - Relational Operators.
  - Other operators.
- Selection Statements
  - if statements
  - if-else
  - else-if
  - switch

**2nd Week**: Now you have understood the basic units of a program well. Its time to take a step forward. So, schedule yourself to learn the following topics.

- Loops
  - for loop
  - while loop
  - do-while loop
- Jump Statements
  - goto
  - break
  - continue
- Comments.
- Arrays
  - One-Dimensional Array.
  - Two-Dimensional Array.
- Strings.

**Now, start solving some problems on these topics, so that you get a good grip on them.**

**3rd Week**: It’s time to start functions and play with pointers.

- Functions
  - Call by value.
  - Call by reference
  - Function Overloading.
  - Inline functions.
- **Pointers**: Now this is a topic that most of the students find difficult. But believe me, it’s a myth. If you will understand the basics of pointers well, you will surely love C++, as it is one of C++’s coolest features. So get a hold on them.
- Relation between Pointers and Array.
- Array to Functions.
- Structures.

As I said, solve problems to check your understanding.

**4th Week**: Now, these topics are asked everywhere like Interviews, practical exams, etc. So don’t make haste and understand them in depth.

- Classes and Objects.
- this keyword, static keyword, Friend Functions.
- Constructors.
  - Default Constructor.
  - Parametrized Constructor.
  - Copy Constructor.
- Destructors.
- Concepts of Object-Oriented Programming(OOP).
  - Abstraction.
  - Encapsulation.
  - Inheritance.
  - Polymorphism.
  - Data Hiding.

Practice problems on these concepts.

**5th Week:**

- Inheritance
  - Types of Inheritance.
  - Derived and Base class.
  - Access Specifiers.
- Polymorphism.
  - Compile Time Polymorphism.
    - Overloading.
    - Overriding.
- Run Time Polymorphism.
  - Virtual Functions.
  - Operator Overloading.
- Exception Handling.

**Practice, practice, and practice.**

**6th Week:** Get familiar with:

- Templates.
- Data File Handling.
- Macros.

That’s it. After learning the above topics you can stand anywhere and say I know C++. :)

**Most Important Tip**: You will face problems while learning some concepts, but please don’t quit. Because everybody faces them and it’s totally OKAY. Give yourself time and jump to that topic again cause this is how things work in the world of programming.

Happy Coding:)
Hello everyone!
Tags: career, beginners, github, programming
Published: 2021-12-17 20:59:26

I'm starting this blog to share with everyone my discusses abou tech, learning and of course grow up together.
For now I'll share a little simple things about myself and so soon I'll start writhe good articles here.


```JS
const about = {
fullname: Julia Barcelos,
age: 31,
married: true,
nerdHobby: board games,
sport: beach tennis,
softSkill: [ resilience, empathy, communication, leadership],
}
```
ML Composer: A Machine Learning ft Jetpack Compose Dev Story — Episode 2
Tags: android, machinelearning, kotlin, github
Published: 2021-12-17 20:47:36

## Text Translation

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

**Hi Folks!**

## Prologue
In the **previous episode** We started with the **Text Recognition** feature, recognizing text from the picture taken by our camera.
https://dev.to/fstranieri/ml-composer-a-machine-learning-ft-jetpack-compose-dev-story-episode-1-5fbp

Now It’s the time to understand that text!
Just imagine to be out of your country, into a restaurant that’s not having an English menu or into a local shop not so tourist friendly: nightmare!
The solution? **Text Translation**

Full article here:
{% medium https://medium.com/huawei-developers/ml-composer-episode-2-e3f334047f29 %}

Stay tuned for the next episode with another awesome Machine Learning superpower!!!

**Bye Folks :}**
ML Composer: A Machine Learning ft Jetpack Compose Dev Story — Episode 1
Tags: android, machinelearning, kotlin, github
Published: 2021-12-17 20:43:15

## Text Recognition

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

**Hi Folks!**

## Prologue
Today I decided to seriously start learning and improve my skill with Jetpack Compose and so I was thinking about an idea for a simple project that covers some interesting topics and all the main points about the UI.
So finally I thought about the machine learning capabilities, they are a lot, using camera, text to show and to edit, menu, buttons and so on.
That’s how ML Composer was born!

Full article here:
{% medium https://medium.com/huawei-developers/ml-composer-episode-1-b52c842ff05e %}

Stay tuned for the next episode with another awesome Machine Learning superpower!!!

**Bye Folks :}**
Float vs Double
Tags: programming, beginners, tutorial, java
Published: 2021-12-17 20:40:30

Float and double, both are used to represent floating point numbers in programming languages. The main difference between them is their range and the number of bits/bytes they use.

In Java, float uses 4 bytes and has comparatively less range than double which uses 8 bytes. Float gives you presion up to 6 decimal places while double gives you precison up to 16 decimal places.

Let's take an example, suppose you made a program in which a variable is used to represent distance. Now if we want presion up to few decimal places like 1.23, 5.3821, etc we can use float. But for precision up to more decimal places like 1.23728164829 we will use double.

Happy Coding :)
Handling form submissions via the Netlify API
Tags: netlify, api, forms
Published: 2021-12-17 20:18:57

---
title: Handling form submissions via the Netlify API
published: true
description: Learn how to use the Netlify API to programmatically access, update, or delete your form submission
tags: Netlify, API, Forms
cover_image: https://www.netlify.com/img/blog/og-form-submissions-api.png
canonical_url: https://www.netlify.com/blog/2021/12/17/handling-form-submissions-via-the-netlify-api/
series: Netlify - a feature a day 2021
---


> Throughout December we'll be [highlighting a different Netlify feature each day](https://www.netlify.com/blog/2021/12/01/highlighting-a-different-netlify-feature-each-day-in-december/?utm_campaign=featdaily21&utm_source=devto&utm_medium=blog&utm_content=submissions-api). It might just be the thing you need to unlock those creative juices, and [dust off that domain](https://www.netlify.com/blog/2021/12/01/dusty-domains-your-forgotten-domains-raise-money-for-charity/?utm_campaign=featdaily21&utm_source=devto&utm_medium=blog&utm_content=submissions-api) you registered but never deployed! Keep an eye [on the blog](https://www.netlify.com/blog/2021/12/01/highlighting-a-different-netlify-feature-each-day-in-december/?utm_campaign=featdaily21&utm_source=devto&utm_medium=blog&utm_content=submissions-api) and on [Twitter](https://twitter.com/netlify) for each feature!

When [using Netlify Forms](/blog/2021/12/16/accepting-form-submissions-without-a-server/?utm_campaign=featdaily21&utm_source=devto&utm_medium=blog&utm_content=submissions-api), you can access your submissions via the UI under the `Forms` tab of your site, but if you'd like to
programmatically access them, you can use the Netlify API to do so.

A few endpoints and operations are available.

**Note: All URLs start with https://api.netlify.com/api/v1. SSL only.**

- Get verified submissions for **all forms** of a site with a GET request to `/sites/{site_id}/submissions`.
- Get verified submissions for a **specific form** of a site with a GET request to `/forms/{form_id}/submissions`.
- Get spam submissions by adding the query parameter `state=spam` to the URLs mentioned above. _For example `/forms/{form_id}/submissions?state=spam`_.
- Change submission state with the 2 following operations:
  - PUT request to `/submissions/{submission_id}/spam` to mark a submission as spam.
  - PUT request to `/submissions/{submission_id}/ham` to mark a submission as ham.
- Delete submissions with a DELETE request to `/submissions/{submission_id}`

That's it! From there you can manage your submissions whichever way you want!

## More information

- [Docs: Handling Forms via the Netlify API](https://docs.netlify.com/api/get-started/?utm_campaign=featdaily21&utm_source=devto&utm_medium=blog&utm_content=submissions-api#forms)
3 SEO tips from my podcast interview with SEO expert
Published: 2021-12-17 19:57:22

I just published my [chat](https://wannabe-entrepreneur.com/episodes/174) with the SEO wizard [Roberto Robles](https://twitter.com/robertodigital_) 🧙‍♂️ . He has been working in SEO for more than 15 years and what he teaches in our chat is really useful for indie makers and small entrepreneurs...

Here are my three lessons from my SEO chat with Roberto:

**1- Pick one Keyword per page**

*SEO keywords are the words and phrases in your website that make it possible for people to find your content via search engines.*

You should define one keyword per page and use them in your h1 tags. Let's say you have a Twitter analytics tool, your home page keyword could be *Twitter*. However, the product page would have different keywords like *analytics* or *dashboard*.

**2- The importance of backlinks**

*A backlink is a link created when one website links to another.*

For Google to see you as an authority in your topic is crucial that websites in the same field link to your content. A simple way to achieve this is by adding content in the so-called "foundational websites" that allowed you to create backlinks (indie hackers is one of them but Twitter is not). 

**3- Use on-page optimization tools**

These page optimization tools point out many improvement areas in your page that will help you rank better. This includes: metatags, page speed, load speed, images, etc...

These are just 3 simple tips from our chat but if you are a bootstrapper I really recommend you to [listen to the full chat](https://wannabe-entrepreneur.com/episodes/174) because there are many other SEO topics covered.
I made an app to visualize React Hooks flow
Tags: react, javascript, webdev
Published: 2021-12-17 19:47:54

Are you using [React hooks](https://reactjs.org/docs/hooks-intro.html) in your projects? If you're like me then you probably might had ran into weird or unexpected re-renders.

I made a React app that lets you visualize the flow in which (some) React hooks are executed. Here's the list of hooks/actions that were considered for this app:
- [Lazy Initial State](https://react-hooks-flow.vercel.app/)
- [useState](https://react-hooks-flow.vercel.app/)
- [useEffect](https://reactjs.org/docs/hooks-reference.html#useeffect)
- [Clean up effects](https://reactjs.org/docs/hooks-reference.html#useeffect)
- Rendering of a component
- Unmounting of a component

The app is based on [Donavon West](https://github.com/donavon)'s [React hooks flow diagram](https://github.com/donavon/hook-flow).

[Here's the link](https://react-hooks-flow.vercel.app/) to the app and also the [link to the source code](https://github.com/augusto1024/react-hooks-flow) in case you want to check it out 😁

Hopefully you'll find this useful and any feedback will be very much received 🙌
Send HubSpot Companies to Slack!
Tags: hubspot, slack, integrations, saas
Published: 2021-12-17 19:40:16

---
title: Send HubSpot Companies to Slack!
published: true
description: There are hundreds of data integrations you can do between HubSpot and Slack. One of them is to send the number of HubSpot companies to a Slack channel.
tags: HubSpot, Slack, Integrations, SaaS
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o1vq0l5bpvapv2p7z394.png
---

There are hundreds of data integrations you can do between HubSpot and Slack. One of them is to send the number of HubSpot companies to a Slack channel.

With just a few steps and lines of code, you can easily create it!

1. Click [here](https://manage.fusebit.io/make/slack-send-message+hubspot-crud-companies) to install the integration
2. Create an account or login to Fusebit
3. You will be redirected to the Fusebit web editor with already most of the code you need.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/acb1xvtlct2jd2ecnlx1.png)

4. Now, let’s fetch HubSpot companies, we can do this with one line of code: 
`const companies = await hubspotGetCompanies(ctx);`
in line 16 (inside `integration.router.post`)
5. Send the new message to Slack with
`await slackSendMessage(ctx, 'You have ${companies.length} companies in HubSpot')`
in line 19 (or any other message of your preference).
6. In addition to sending the message directly within Slack you can also send it in the response body. Change what’s inside of the `ctx.body` to companies: `companies.length` and that’s it!

Check out the full blog post [here](https://fusebit.io/blog/send-hubpsot-companies-to-slack/)
What was your win this week?
Tags: discuss, weeklyretro
Published: 2021-12-17 19:33:19

---
title: What was your win this week?
published: true
description: Got to all your meetings on time? Started a new project? Fixed a tricky bug?
tags: discuss, weeklyretro
cover_image: https://cl.ly/188e843c2985/download/Image%202019-02-15%20at%202.36.37%20PM.png
---

Hey there! 


Looking back on this past week, what was something you were proud of accomplishing?

All wins count — big or small 🎉

Examples of 'wins' include:

- Starting a new project
- Fixing a tricky bug
- Reconnecting with an old friend ... or whatever else might spark joy ❤️ 

---

Congrats on your accomplishments this week! 

![Adventure Time Happy Calculator](https://media.giphy.com/media/12XTNObsY1pWQU/giphy.gif)
Tailwind CSS Standalone CLI: Use Tailwind CSS without Node.js
Tags: tailwindcss, productivity
Published: 2021-12-17 19:30:26

Tailwind just released a standalone CLI in a self-contained executable, no Node.js or npm required.

---

## Get started

Download the executable for your platform from the latest [**release**](https://github.com/tailwindlabs/tailwindcss/releases/latest).

Copy it to the root directory of your project.

Rename the executable to `"tailwindcss"`.

Create anywhere in your project an entry point `input.css` and `output.css` destination for the compiled css. Also note the path of both files relative to the `"tailwindcss"` executable

Now you can use it just like the npm-distributed CLI tool:

```bash
# Open a terminal at project root

# Create a tailwind.config.js file
./tailwindcss init

# Start a watcher
./tailwindcss -i <relative-path-to-input.css> -o <relative-path-to-output.css> --watch

# Compile and minify your CSS for production
./tailwindcss -i <relative-path-to-input.css> -o <relative-path-to-output.css> --minify
```

It comes bundled with the latest versions of all of tailwind's first-party plugins, so if you want to use them in your project, just require them in your tailwind.config.js file like you would in a Node-based project:

```js
module.exports = {
  // ...
  plugins: [
    require('@tailwindcss/forms'),
    require('@tailwindcss/typography'),
  ]
}
```

## Refrences
[Standalone CLI: Use Tailwind CSS without Node.js](https://tailwindcss.com/blog/standalone-cli) - [Adam Wathan](https://twitter.com/adamwathan)
🎄 CodeCast's Coding Advent: Day Seventeen 🎄
Tags: productivity, webdev, beginners, career
Published: 2021-12-17 19:19:26


![Day 17](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/udwamc0wrfnufzyepbbn.png)

### DAY 17

Let's keep the portfolio train rolling for day seventeen! Today, we're tackling part two of the portfolio building series!

https://www.codecast.io/casts/Yg9QXYGjLa1W-creating-a-portfolio-website-part-2-setup-assets-navbar

You can also be sure to follow us on [Instagram](https://www.instagram.com/codecastapp/), [Twitter](https://twitter.com/CodeCastApp), [Facebook](https://www.facebook.com/codecastapp), and [LinkedIn](https://www.linkedin.com/company/code-cast/) to see our daily advent releases there!
Most useful eslint rules for networking code (async/await/promises)
Tags: eslint, javascript, async, tooling
Published: 2021-12-17 18:58:37

The main caveat is that you have to use typescript. Put this into the `rules` section of your `.eslintrc.json`:

```json
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/require-await": "error",
"@typescript-eslint/no-floating-promises": "error"
```

You'll also need to tell eslint where your tsconfig file is:

```json
"parserOptions": {
    "project": "tsconfig.json"
}
```

Then if you write code like this, where you don't await an asynchronous call:


```ts
async function f() {
    await fetch('a')
    doSomethingElse()
    fetch('b')
}
```

Then you'll get a helpful error message, which pops up over the text in vscode if you're using the eslint extension:

```
temp.ts
4:5   error  Promises must be handled appropriately or explicitly marked as ignored with the `void` operator  @typescript-eslint/no-floating-promises
```

You'll also get errors if an `async` function has no awaits or if you await a sync function.
Living in the Shell #18; du (Report Directory Size)
Tags: productivity, linux, bash, devops
Published: 2021-12-17 18:53:15

## `du` 💽

Reports disk usage.

## See summarized directory size `-s`

```sh
du -s ~/Downloads
```

> ```text
> 11732700        /home/babak/Downloads
> ```
>
> Note that the result is in kilobytes.

## Human-readable size values `-h`

```sh
du -sh ~/Downloads
```

> ```text
> 12G   /home/babak/Downloads
> ```

## Exclude files by pattern `--exclude`

```sh
du -sh --exclude '*.iso' ~/Downloads
```

> ```text
> 7.1G   /home/babak/Downloads
> ```

## See exhaustive sub-directory sizes

```sh
du ~/Documents
```

## Limit recursion depth `-d`

```sh
du -h -d 1 ~/Documents
```

## Include files in exhaustive size report `-a`

```sh
du -h -a ~/Documents
```
Number of Palindromic Substrings
Tags: 100daysofcode, programming, java, algorithms
Published: 2021-12-17 18:06:12

# [Description](https://binarysearch.com/problems/Number-of-Palindromic-Substrings/solutions/7067481)

Given a lowercase alphabet string `s`, return the number of palindromic substrings in `s`.

**Constraints:** 

- `1 ≤ n ≤ 1,000` where `n` is the length of `s`

## Example 1

### Input

```
s = "tacocat"
```

### Output

```
10
```

### **Explanation**

```
The palindromic substrings are:

"t"
"a"
"c"
"o"
"c"
"a"
"t"
"coc"
"acoca"
"tacocat"
```

---

# Intuition

`DP[i][j]` means if `substring(i,j)` is a Palindromic string

1. if `i==j` -> `dp[i][j] = true`;
2. if `i!=j` -> `dp[i][j] = dp[i+1][j-1] && char[i]==char[j]`

---

## Details

1. init dp array with `false`: `boolean[][] dp = new boolean[length][length]`;
2. init `count = 0`;
3. compare `start` to `end`:
    ◦ `start == end`: `dp[start][end] = true`;
    ◦ compare `chars[start]` to `chars[end]`

# Implementation

```java
import java.util.*;

class Solution {
    public int solve(String s) {
        int length = s.length();
        boolean[][] dp = new boolean[length][length];
        int count = 0;
        for (int end = 0; end < length; end++) {
            for (int start = 0; start <= end; start++) {
                if (start == end) {
                    dp[start][end] = true;
                    count++;
                } else {
                    if (s.charAt(start) == s.charAt(end)) {
                        if (end - start == 1 || dp[start + 1][end - 1]) {
                            dp[start][end] = true;
                            count++;
                        }
                    }
                }
            }
        }
        return count;
    }
}
```

## Time Complexity

- Time: O(n^2)
- Space: O(n^2)