teleren/devto huggingface dataset:
LeetCode #206 Reverse Linked List
Tags: leetcode, linkedlist, dsa, webdev
Published: 2022-08-25 08:59:24

hey everyone👋

Today We discuss the leetcode #206 problem 

## Problem
Reverse a singly linked list.

## Example:

Input: 1->2->3->4->5->NULL
Output: 5->4->3->2->1->NULL

## Follow up:

A linked list can be reversed either iteratively or recursively. Could you implement both?

## Solution — Iteration- 

Use a pointer that points to a node x which is head at beginning. In each iteration if it has next node y ,move next node to be front of current head and update head pointer to y. Once x has not next node, i.e. it’s tail, end the iteration.


```

# Python3

# Definition for singly-linked list.
# class ListNode(object):
#     def __init__(self, x):
#         self.val = x
#         self.next = None

class Solution:
    def reverseList(self, head):
        """
        :type head: ListNode
        :rtype: ListNode
        """

        # Iteration approach
        # Run one pointer p in list. At each iteration:
        #     1. n = p.next
        #     2. p.next = n.next, jump cross n
        #     3. n.next = head, n prepend to the front
        #     4. head = n, reassign head

        if head == None:
            return None

        p = head
        while p.next:
            n = p.next
            p.next = n.next
            n.next = head
            head = n

        return head
```

## Complexity-

the time **complexity is O(n)** if n denotes to counts of nodes in this linked list.

It’s trivial that it only uses **O(1) extra space.**

## Solution — Recursion

```
# Python3

# Definition for singly-linked list.
# class ListNode(object):
#     def __init__(self, x):
#         self.val = x
#         self.next = None

class Solution:
    def reverseList(self, head):
        """
        :type head: ListNode
        :rtype: ListNode
        """

        # Recursion approach:
        #     take head and reverse list whose head is head.next
        #     then reversely assign the link between them

        if head == None or head.next == None:
            return head

        n = head.next
        h = self.reverseList(n)

        # reverse link
        head.next = None
        n.next = head

        return h
```

## Complexity
At each function call, it’s only takes** O(1) time for assigning link**. And there are n-2 calls if n denotes to counts of nodes in this linked list. Therefore, time complexity will be O(n).

Also, it **uses O(1) extra space **in each function call and there are n-2 calls in calling stack. Hence space complexity is O(n) as well.



Thank you for read this article .I hope its help you to solve this problem 
If you like the article so just follow on **@coders_village in instagram **

Thank You 
Shivani Tiwari 
(Software Developers)
How to put data from RTK query into state slice in Redux toolkit
Published: 2022-08-25 08:48:04

Someone asked the question [How to put data from RTK query into redux slice](https://stackoverflow.com/a/68760199/17171424)

I found an answer here on a [dev blog](https://dev.to/agiksetiawan/put-data-from-rtk-query-on-to-state-slice-in-redux-toolkit-1p1m)

I found an answer from [stackoverflow](https://stackoverflow.com/questions/68612556/how-to-store-the-result-of-query-from-createapi-in-a-slice)

**Thank you, please follow me**

[linkedin](https://linkedin.com/in/ifeanyi-thankgod-chima)
[github](https://github.com/masterifeanyi)
[twitter](https://twitter.com/@ifeanyiTchima) 

<a href="https://www.buymeacoffee.com/ifeanyichima" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a>
awk total records processed
Tags: bash, awk, programming, python
Published: 2022-08-25 08:41:00

Hi All,



I would like to add several lines to the output of my script. Currently, the script behaves as outlined in the README.md file [here](https://github.com/brianbills21/parse-samples). But the behavior I want to change it to is below:

```
./sample.sh -s 0-9 -c 0-3 -t samples.bin
                Ch0     Ch1     Ch2     Ch3
Sample 0:       0x1a03  0x1a03  0x4a03  0x5703
Sample 1:       0x4b03  0x4403  0x1e03  0x0904
Sample 2:       0x1003  0x1903  0x4003  0xae03
Sample 3:       0x1e03  0x2603  0x3303  0xad03
Sample 4:       0x1003  0x8403  0x4303  0x6203
Sample 5:       0xe003  0x1603  0x3403  0xc403
Sample 6:       0xf802  0x3b03  0x5303  0x6103
Sample 7:       0x1003  0x1503  0x4203  0x5803
Sample 8:       0x2303  0x1f03  0x5703  0x6203
Sample 9:       0x1703  0x7303  0x3103  0x3303
Total Samples in Record:        374371
Total Samples Processed:        10
```
and here:

```
./sample.sh -r samples.bin
Total Samples in Record:        374371
```
and here:

```
./sample.sh -t samples.bin
Total Samples in Record:        374371
Total Samples Processed:        374371
```
The script works as expected, I just want the argument -r to replace -t and passing -t after -s and -c, should produce the total number of samples processed along with the total number of samples in the input file. I should still be able to pass -t to sample.sh, but in this case, it will count the number of samples in the file and tell us the total number of samples processed. The script is [here](https://github.com/brianbills21/parse-samples/blob/main/sample.sh). If you want you can clone the project and then do a pull request, and if the solution works, I'll approve it.


Thanks,
Brian
New Feature Laravel min_digits and max_digits Validation
Tags: laravel, webdev, tutorial, php
Published: 2022-08-25 08:34:00

In the new version 9.26 we have the feature min_digits and max_digits validation

According to the size rule, the number of digits in a digital input cannot be traditionally validated using min and max.

Currently, we have digits to validate the exact length of a number, and digits_between to validate the length within two bounds.

However, as far as I can see, there is still no way to verify that a number has a minimum or maximum number of digits, just both.

This PR offers two validation rules - min_digits and max_digits for this usage

https://github.com/laravel/framework/pull/43797

```php
Validator::validate([
    'number' => 1000,
], [
    'number' => [
        // Passes as `1000` has 4 digits
        'min_digits:3', 'max_digits:5',
        // Fails as `1000` is greater than 5
        'min:3', 'max:5',
    ],
])
```

I hope you enjoyed with me and to learn more about this release visit the sources and search more. I adore you who search for everything new.

Source :- https://laravel-news.com/laravel-9-26-0
Source :- https://www.youtube.com/watch?v=ZCYqn0Y6qc0
Handling big API request with small execution time
Tags: php, programming, bigdata, api
Published: 2022-08-25 08:26:00

Hello,

I am a web developer, using wordpress as a base framework to manage and handle boats that i get from an API, 

The api has multiple endpoints to get all the data for each boat.
For example,
1 endpoint will give you all the data of one boat but all the data are given in IDs, which means you need to map these IDs with another endpoint from their API : 
Boat :

{"boats":{"checkinDays":"monday","locationId":"2301","RegionId":"1283","CountryId":"1283","EquipmentId":"12","ServiceId":"123"}} 


After parsing and trying to save all the data in the database, the server get overloaded by memory usage and the update (Cron task)  crashed the server.

To handle this problem i've used "https://github.com/halaxa/json-machine" to decrease the memory usage and "https://github.com/spatie/async" to decrease the time taken for the "update process" to complete

Note : 
Before updating any boats, i run a Cron task that will hit the API endpoints then save the data as json file in my server. ( it's faster and uses less memory) 


Kind regards,
Hemant.
Application of wireless wake-up in irrigation system
Tags: wireless
Published: 2022-08-25 08:24:43

Agriculture is the economic lifeline of a country, and the development of a country is inseparable from the development of agriculture. As one of the major agricultural countries, with the development of agriculture, the proportion of agricultural water use is also increasing. And my country's current agricultural irrigation is mainly based on traditional artificial irrigation. There are three main disadvantages of traditional artificial irrigation:

In order to reduce labor costs, rationally use water resources, and improve the environmental quality of crop growth, it is necessary to improve traditional irrigation methods and apply technology to agricultural irrigation.
Applying wireless wake-up to the agricultural irrigation system, the entire system network is mainly composed of multiple nodes, gateways, host-side servers, and client-side, in order to realize remote operation, grasp the current environmental status of crops, and rationally irrigate. Take the E31-T50S2 of Chengdu Ebyte Electronic Technology Co., Ltd. as an example to introduce. The node is mainly composed of main control equipment, E31-T50S2, various controllers, temperature sensors, soil moisture sensors, liquid level sensors, etc.
The gateway module is mainly composed of the main control chip, the wireless serial port module E31-T50S2 (or similar high-power modules), etc., and also plays the role of forwarding and relaying. The location of the gateway is approximately the same distance from each node location (each greenhouse, etc.). Of course, if it is in a relatively small network, the gateway can also be partially banned.

The host server is mainly composed of main control equipment, wireless serial port module E31-T50S2 (or similar high-power module), computer, system software, etc.

The client uses various terminal devices to connect with the host server through the Internet.

To view technical articles and consult technical questions for free, you can visit our official website and various official platforms:

[Chengdu Ebyte](https://www.cdebyte.com/Module-WiFi)--Internet of Things application experts, always by your side, always ready to serve you!
Create AWS Step Function and Lambda using Terraform and GitLab CI
Tags: aws, terraform, stepfunction, lambda
Published: 2022-08-25 08:09:38

## Install Terraform

- Download Terraform binary and unzip the package.

- Set terraform path to unzipped binary location. Terraform runs as a single binary named terraform. Any other files in the package can be safely removed and Terraform will still function.

- Verify the setup by using command terraform version in CLI.

## Install AWS CLI

- Download and run the [AWS CLI](https://awscli.amazonaws.com/AWSCLIV2.msi) MSI installer for Windows (64-bit):

- To confirm the installation, open the Start menu, search for cmd to open a command prompt window, and at the command prompt use the aws --version command.

![0](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/whefbn6wtqxd5md0tnmx.png)

## Build a infrastructure

- Create a directory for your configuration  `mkdir terraform`
- Change the directory and create a file _main.tf_.

![1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t1n33vop1zvhb7tdwdhb.png)
- Initialize the directory with `terraform init`.

![2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nn8gxi1lv1kel422kbiy.png)
- Run `terraform plan` to see any changes are required for 
  infrastructure.
- Format and validate the configuration
![3](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xb6syq77z2qp06ktu92x.png)
- Apply the configuration now with the `terraform apply` command.

![4](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9nn21iv90ysbaqbs6icc.png)                      

## Configuring Gitlab CI for Terraform

- Create a file on the root of your repository called .gitlab-ci.yml
- Get your access key ID and secret access key.
- Set aws variables go to - gitlab project → settings → CI/CD → Variables

         

## Sample GitLab pipeline
```
stages:
  - validate
  - plan
  - apply
  - destroy
image:
  name: hashicorp/terraform:light
  entrypoint:
    - '/usr/bin/env'
    - 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
before_script:
  - export AWS_ACCESS_KEY=${AWS_ACCESS_KEY_ID}
  - export AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
  - rm -rf .terraform
  - cd terraform/
  - terraform --version
  - terraform init

validate:
  stage: validate
  script:
    - terraform validate
  only:
    - branches
  
plan:
  stage: plan
  script:
    - terraform plan -out "planfile"
  dependencies:
    - validate
  artifacts:
    paths:
      - planfile
 
apply:
  stage: apply
  script:
    - terraform apply -input=false "planfile"
  dependencies:
    - plan
  when: manual
  only:
    - main

destroy:
  stage: destroy
  script:
    - echo "Destroying resources"
    - terraform destroy -state=$STATE --auto-approve
  dependencies:
    - apply
  when: manual
  only:
    refs:
      - main
```
[Sample terraform code for lambda and step function](https://github.com/shubhampawar/terraform_POC)
Cherrybomb 0.7 is now GA
Tags: api, programming, beginners, productivity
Published: 2022-08-25 07:57:31

#What is Cherrybomb?
Cherrybomb is a CLI tool that helps you avoid undefined user behavior by validating your API specifications and running API security tests.

#What's new in version 0.7?
I am happy to announce that Cherrybomb can now be easily integrated into your CI process with its new and improved user interface.
The process is simple and easy to use, and only requires a few minutes to complete.
All you need to do is use the intuitive config generator to select you CI pipeline and OAS provider of choice, change a few settings to customize your experience, and you’re ready to go!

With Cherrybomb integrated, you’ll be able to quickly and easily run your tests and get the results you need in order to continue with your development process.
You’ll see exactly what tests have failed, what is the problem, and how serious it is.
That way you can quickly fix those problems and improve the security of your API!

You can learn more about Cherrybomb and how it can help you over at its [repository](https://github.com/blst-security/cherrybomb).
New to a Daunting Field
Tags: beginners, career, programming, help
Published: 2022-08-24 13:03:56

Eeek! As I look at the course load of an intensive 6 month coding boot camp, I am feeling overwhelmed and already exhausted. How am I going to teach special education fulltime, take night classes 3 days with 9 hours of class time, up to 20 hours of studying, and the most important job of them all: Mom to an 8 year old (and dog mom to a pug and lab)?

My only option is to succeed. I need to be successful in an ever emerging field to earn more money, to show my daughter that you can change careers at anytime in order to be happy, more successful, and more secure, and that women can be successful even in a field that is led mostly by men. 

So as a fairly new beginner to this field (my first major in college was computer science learning C++ but that was 20 years ago and only lasted a semester) what are your tips, suggestions, and best advice for an almost 40 year old entering this field of full of youngsters who grew up with coding?

Help!!!
7 chrome extension to boost your productivity🚀
Tags: programming, productivity
Published: 2022-08-25 07:36:00

1)ScribeHow

Scribe automatically creates a how-to guide with screenshots, instructions, and clicks.

You can edit, annotate and easily share or export them.

Must have extension for students, educators, and founders.

🔗 https://scribe.how/chrome

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

2)Email Finder

Email Finder is a free extension for Google Chrome that allows you to quickly find the email addresses of people you know. 

It also includes a handy search function so you can easily find the email address of someone you don't know.

🔗 https://chrome.google.com/webstore/detail/email-finder-getprospect/bhbcbkonalnjkflmdkdodieehnmmeknp?hl=en

3)Bitwarden

This chrome extension is a secure and easy-to-use password manager that allows you to store and manage your passwords securely and conveniently. 

The extension allows you to easily access your passwords from any device or browser.

🔗 https://chrome.google.com/webstore/detail/bitwarden-free-password-m/nngceckbapebfimnlniiiahkandclblb?hl=en

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

4)Checker Plus for Gmail

This extension displays a popup window whenever you receive a new email, letting you quickly read, delete, or mark as unread. 

You can also snooze emails or have them automatically deleted after a certain amount of time. 

🔗 https://chrome.google.com/webstore/detail/checker-plus-for-gmail/oeopbcgkkoapgobdbedcemjljbihmemj

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

5)Zoom scheduler

This extension allows you to schedule Zoom meetings directly from your Google Calendar, and it also integrates with your Gmail account so you can easily send invites to participants.

🔗 https://chrome.google.com/webstore/detail/zoom-scheduler/kgjfgplpablkjnlkjmjdecgdpfankdle?hl=en

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

6)TinyEye

A quick and easy way to do a reverse image search.

With this extension, you can simply right-click on any image and select "Search Image on TinEye" to search. 

🔗 https://chrome.google.com/webstore/detail/tineye-reverse-image-sear/haebnnbpedcbhciplfhjjkbafijpncjl

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

7)Focus To-Do: Pomodoro Timer & To-Do List

It helps you to stay focused on your tasks by using the Pomodoro technique, which involves working for 25 minutes and then taking a 5 minutes break. 

Includes a to-do list to keep track of your tasks.

🔗 https://chrome.google.com/webstore/detail/focus-to-do-pomodoro-time/ngceodoilcgpmkijopinlkmohnfifjfb?hl=en

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ch0iwowmpvochfrf8hpx.png)
The correctness of an MVP, when it is and when it ceases to be.
Tags: mvp, discuss, help, webdev
Published: 2022-08-25 07:25:00

Good morning my developer friends
These days I was thinking about starting a personal project. But whenever I start a project I have a doubt that plagues me

- 1. How far is an MVP considered an MVP?
- 2. At what point does an MVP stop being an MVP?
- 3. What practices help to achieve an MVP without deviating in the goal?
- 4. At what point is it considered that it is time to iterate in the second, third or fourth phase of development of an MVP?
Leetcode Challenge (The end)
Published: 2022-08-25 07:17:03

It's been a while since the last post.

I'm sorry about that I am here to tell you this series will stop here, due to my personal reasons :(

I might continue updating the [GitHub repo](https://github.com/MiccWan/leetcode) sometimes (and maybe not), but there won't be any new post.

Happy programming everyone :)
Early CSS tailwind snags
Tags: codenewbie, tailwindcss
Published: 2022-08-25 07:14:01

Just a quick recap on my experience with tailwind so far

Before starting tailwind I spent quite a bit of time with trying to understand basic css/scss. I was able to do animations, transitions, make a basic responsive landing page, and style elements efficiently.

When I began using tailwind I was smitten right away, by the ability to prototype designs so quickly. I still love the power of tailwind which i have yet to fully tap into. I did however, naively underestimate the bar to entry. 

I'm currently building a landing page with Tailwind, and here are some pros and cons I've come across so far. I'll just stick to the ones I don't see mentioned frequently in threads:

- I love how easy it is to set breakpoints at different screen sizes.

- It is fascinating how some things like element styling, positioning, transitions, are able to be done so much more efficiently especially in smaller chunks. Yet i spend much longer being hung up on the effects of sm,md sized classes and the like. Maybe i should try a mobile first route initially...

- With pure CSS I grew accustomed to plugging in a custom .btn class for a button and being done with it. the tradeoff being obviously it was a pain starting out building, and organizing the classes. 

- It has been easier to efficiently position items where I want them to be for either mobile, or full screen sizes However, I get hung up on the nuances of making either of them responsive. Sticking with it seems to be the better option long-term because it's not like media queries were the most expedient. I know I'll probably get more fluid soon, and be grateful for the persistence.




###It's a beautiful lesson to learn, not getting to comfortable in my ways especially in a trade that's perpetually evolving in some ways.###

Learning the hard way to understand how the fundamentals work, but not allowing myself to get too comfortable doing things one given way seems to be a prudential route.
Get Help in your Math Exam
Tags: javascript, webdev, programming, productivity
Published: 2022-08-25 07:08:48

Mathematics is one subject that you cannot avoid in your life. It is important to master mathematics and learn the fundamentals and concepts in this subject. To do this, or to [take my math exam](https://www.mathexamhelp.com/take-my-math-exam/) you can find an online help who will help you to improve your knowledge and skills. There are many websites that offer tutoring or exam help for various subjects including math. As per my opinion, Maths is a really fascinating subject for students that opens up several opportunities to further growth and an interesting career ahead. So, according to my research, I would like to recommend [Math Exam Help](https://www.mathexamhelp.com/) as one of the best online tutoring websites for maths exams.
Episode 6 Direct Uploads in Ruby on Rails
Tags: rails, ruby, javascript, tutorial
Published: 2022-08-25 07:07:08

Active Storage facilitates uploading files to a cloud storage service like Amazon S3, Google Cloud Storage, or Microsoft Azure Storage and attaching those files to Active Record objects. We will learn how to use Active Storage to make direct uploads in Ruby on Rails.
{% youtube rERpL9rjlxE %}