teleren/devto huggingface dataset:
DPS909 Blog - Lab 5: Refactoring & Rewriting Git History
Tags: opensource
Published: 2022-10-13 17:49:06

This week in my Open-Source course (DPS909), we were introduced to the concept of code refactoring and git history rewriting via `git rebase`. The purpose of this lab was to help us to practice refactoring existing code to make it easier to read, maintain, and more modular. Using `git rebase` showed us how to rewrite git history to simplify commits.

GitHub Repo: https://github.com/alexsam29/ssg-cli-tool
Refactoring commit: https://github.com/alexsam29/ssg-cli-tool/commit/cb9bb6e4278680df99c9202ca17288703cebe885

## Refactoring Process
To start refactoring my code, I first went through my code and used the 'Prettier' Visual Studio extension to format the code and adjust any lines to make it more readable. This included things like wrapping code where necessary, adding spaces between lines, adding indents, etc.

Next, I focused on extracting functions from my existing code. I had functions within `main()` that made the code look a bit messy, so I took them out of `main()` and created new files that contained functions for similar tasks. `create.js` is where I house the functions to create HTML files and the index page. While `ssgStart.js` is where command-line arguments are parsed and read. I also created a file called `utils.js` that contains miscellaneous functions for verifying files types and file paths.

I tried to reduce code duplication by creating new functions whenever I see lines of code repeated more than once. Originally I had similar lines of code for reading one file and reading more than one file in a directory. I created the `readFromFile()` function in `ssgStat.js` to reduce redundant code.

Lastly, I went through all my variable names and renamed some for more clarity. I tried to use similar variable names in functions where data is passed through, in order to be consistent. I also removed some unused packages so that unnecessary files are not installed when running the program.

While refactoring, I did encounter some bugs that I didn't find before. Instead of fixing it in the same branch, I created a new branch based off of `main` and fixed it there. I then merged it into the `main` branch before I was done with refactoring.

## Rewriting Git History
Once I was done refactoring, I used `git rebase` to `squash` all of the refactoring commits into a single commit. I then amended the commit message using `git commit --amend` to include a summarized title and the changes I made in point form. 

I didn't have much issues doing this, the only issue I encountered was a merge conflict. This was because of the bug I fixed earlier in a different branch, so I had to resolve the conflict before continuing the `rebase` and `squash`. Once resolved, all my changes were in a single commit and was able to be merged into `main` problem-free.
New JS Newsletter: JSTools Weekly
Tags: newsletter, javascript, webdev, programming
Published: 2022-10-13 17:44:34

Hi JS developers 👋

Almost a month ago, we created a new three-part newsletter about open source JavaScript tools called [JSTools Weekly](https://jstools.substack.com/), which is sent every week on Tuesdays or Wednesdays.

The focus of this newsletter is only on JavaScript or TypeScript tools that are hosted on GitHub.

Every week we check hundreds of thousands of repositories and at the end we send tools to our members in three different lists.

* In the first list, we have included well-known JavaScript tools that have had a new and important update in the last week with the link to the update details.⭐

* In the second list, we include a list of repositories that had more activities in the last week. Tools are selected that have been active in the last week, based on stars, commits, issues and pull requests they have received or created.🔥

* And in the last list, we select the new JavaScript repositories that have been released in the last week and worth mentioning.✨

We tried our best to collect a list of useful tools that will help you in the development of your JavaScript projects.

If you have any comments or suggestions that you think will help to improve newsletter, you can write in the comments section below.

If you like this newsletter, you can [subscribe](https://jstools.substack.com/) to it! 😎

Thank you 💛
Some Arrays Javascript Methods You Might Want to Know 🚀
Tags: javascript, beginners, tutorial, codenewbie
Published: 2022-10-13 17:10:57

Hello everyone, today I want to talk a little about Array in Javascript and show some examples about it!

# What is Javascript Arrays!?
In a nutshell, Arrays in Javascript are a hight level global object to make a something like a "list". Now, let's see some examples of methods with we can do with Array!

## Array.prototype.length()
Get the length of items in your array.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ezmzq79bhmog0s1u67ji.png)
___
## Array.prototype.find()
Returns the value of the first element that matches with its validation.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ww06q8jiimrpbq1n1g9e.png)
___
## Array.prototype.forEach()
Loops through each of the elements in your array.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tylgvstw4nsc0pvu1a5z.png)
___
## Array.prototype.includes()
Checks if Array contains certain element and returns true or false, respectively.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0x59h05exarbpquanvwo.png)
___
## Array.prototype.map()
Creates a new array with the values ​​according to the function that was passed.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6i3owqkwlfxct5gfijcz.png)
___
## Array.prototype.sort()
Returns an Array of sorted values, sorted in ascending order.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oz22ydt28e0ffyr1wcx6.png)
___
## Array.prototype.entries()
Returns a new Array object that has a key and value for each element of the source array.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j9bywitpv51143f95wnr.png)
___
## Array.prototype.push()
Add one or more new elements to the Array.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2k9ul0keyd9i0d6jt7b0.png)
___
There are many others Array methods, I wanted to bring some examples and I hope you liked it!

Have you seen or used them all on the list!? Leave a comment, it will be nice to hear about your experience with them!

See you soon folks!
Code Review Best Practices
Tags: codereview, devops, programming, discuss
Published: 2022-10-13 17:08:40

## We started a code review best practices thread in our [community](https://community.codacy.com/t/code-review-best-practices/1019) 
What about you? Share some of your best practices in the comments 👇 

Code reviews are one of the most important aspects of today’s software development workflow. With that in mind, I want to share some code review best practices with you. It is not an exhaustive list, but it can be a good starting point for you and your team.

## For code author
Aim for small changes
Group code changes that are related
Read through your code carefully
before submitting it for review
Run tests before submitting the code for review
Use commit templates
Describe the purpose of the code change
Add junior developers to the review to let them learn
Add experienced developers if you need them
Do not add too many reviewers
Be open to comments and suggestions
Show respect to the reviewers
Thank the reviewer for their comments and suggestions


## For code reviewer
Give respectful and constructive feedback
Give clear and actionable suggestions or recommendations
Specify the changes that the author needs to make and their level of importance
Ensure traceability for decisions
Give feedback on time
Focus mainly on core issues
Talk directly with the author, if necessary
Reduce multitasking and task switching as it reduces productivity
Don’t forget that great feedback include praise
Use a code review checklist

💡 If you want to dive deeper into code reviews, we created a guide that explains in detail what code reviews are and how to optimize them. We even give you checklists to help you become the best code reviewer you can be. **[Check it out](https://go.codacy.com/code-reviews-essential-guide)**!
Windows Opacity in VSCODE
Tags: watercooler, webdev, vscode
Published: 2022-10-13 17:07:35

Just wanted to share with you something that has been bothering me for so long, it might be nothing for you, and it might be important, anyways .. here it goes :
GLASSIT extension is not working, and I have been looking to find another extension that makes VSCODE ( for my videos recording purpose ).
And if you've been struggling like me, then I am here to tell you that there is another extension called "Windows Opacity".
You can install it easily, the only disadvantage of Windows Opacity extension is you cannot control the opacity using a shortcut like you'd do in Glassit.
There you have it, hope it will be any useful to you.
Cheers - Bek
Android Studio Build Immediate Fail
Published: 2022-10-13 17:03:19

This example code was taken straight from github.  I am confident that this code is supposed to build but I suspect something in the compiler of Android Studio has changed, updated, or with a newer version of the Android operating system something needs to be updated in the source code of an app.  This is because a build and/or gradle sync has this error immediately.  Nothing major has changed in the code.  I suspect this might be a common thing and I suspect someone must know something about this and how to fix it.  Please advise. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x2o0ojp2qspg2nxb8gg9.png)
Order of Routes in Rails
Published: 2022-10-13 17:02:03

While adding features to a class project, I was struggling with an error that took me some time to debug. This post is meant as a reminder to myself (and possibly others) that ROUTE ORDER IN RAILS MATTERS.

Originally, I had the following code:

```
  get("/movies", { :controller => "movies", :action => "index"})
  get("/movies/:id", { :controller => "movies", :action => "movie"})
  get("/delete_movie/:id", { :controller => "movies", :action => "delete"})
  get("/movies/new", {:controller => "movies", :action => "new_movie"})
```

The problem that I had initially overlooked was that since Rails compiles the code from top to bottom, it was sending me to the "/movies/:id" when I was trying to use the "/movies/new" path, thinking that "new" was the movie's id. In the program, it was trying to look up a movie with the id of "new", which it would never find, and ended up giving me an error.

Eventually, after multiple changes and continually hitting the error, I finally realized the problem was the route order. Rearranging the routes in the following way, everything worked:

```
  get("/movies", { :controller => "movies", :action => "index"})
  get("/movies/new", {:controller => "movies", :action => "new_movie"})
  get("/movies/:id", { :controller => "movies", :action => "movie"})
  get("/delete_movie/:id", { :controller => "movies", :action => "delete"})
```
npm build / shopify help
Published: 2022-10-13 16:59:04

Hello everyone,  I have a single page react app that consist of a few asset images which are wired together in layers making the full image.  I used framer motion for a little interaction.  Ive been trying and trying with no luck because my understanding just isn't quite as broad as certain steps in the many tutorials Ive been trying to follow.  I'am trying to get this up onto my Shopify store as a section. I believe I could handle it if I was only able to generate one single HTML file instead of the three .map, .chunk, files from running a build command on the project.  Could someone please help me with this?  Ive attached the directory via weTransfer.  Surly I would love to be taught how to do this myself, but If you guys explain the steps to me, please be aware of me not fully understanding educated developer word meanings, steps, or procedures.  I can write a little HTML, CSS, and JS.  Been learing three.js and Python more recently.  And I understand how to setup basic boilerplate developer environments and run commands in the right directory in the terminal.  That's about it.

thank you forn your time with this.
I'd greatly appreciate it.

Jonathan

https://we.tl/t-6wOO4CQRVg
Backend-Development Learning Roadmap - Step by Step
Tags: backend, api, database, roadmap
Published: 2022-10-13 16:54:46

### Hard Part  for Backend : Row Requirement Analysis to thinking Data Modelling and Database Design.
 We need to learn Data Modeling and Database Design....... see Next article.

- API Design
    - Rest APi
    - GraphQL
    - gRPC
    - Web Socket
    - Message Broker
- Api Security
    - JWT Token
    - Refresh Token
    - OAuth2
    - SAML
    - Identity Proviiders
        - Cognito
        - Auth0
        - Firebase
        - Okta
    - Role Base Authorization
- API Testing
    - Unit Testing
    - Acceptance Testing
    - Load Testing
- API Documentation
    - Swagger
    - Postman

— Concept Must Need for Backend Developer 

- Database
    - **ORM ( Object Relational Model)**
    - SQL
        - PostgreSQL
        - mySQL
        - MSSQL/ Oracle
    - NoSQL
        - MongoDB
        - AWS DynamoDB
    - In Memory*** - (for Cashing)
        - Redis**
        - Mem Cashed
    - Graph Database
        - Neo4j
- Linux server
- Cloud Computing
- DevOps

## Server Application Responsibility

- Listen Request
- Process
    - Algorithm
    - Data Structure
    - Database
    - Problem Solving
    - CURD Operation
- Response

### HTTP Knowladges: - Stateless communication

- Get Request - ( Want to Read from server)
- POST - ( Create new Data )
- PUT/PATCH - ( Update Existing Content)
- DELETE - (Delete Data from Database)
Back-To-CP Day 1
Published: 2022-10-13 16:38:21

13-10-2022

[Two Sum II](https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/)

For the array I used two pointers, one for the beginning of the and one for the end of the array. In a loop I checked if sum of those pointer value greater or less than the target value and decrease end pointer or increase start pointer by 1. Otherwise stop the loop.
Returned a vector containing start pointer + 1 and end pointer + 1 as the index in result supposed to start from 1 and not 0.


```
class Solution {
public:
    vector<int> twoSum(vector<int>& numbers, int target) {
         vector<int> res;
         int l = 0, h = numbers.size() - 1;
         for(int i = 0; i < numbers.size(); i++){
            if(numbers[l] + numbers[h] < target){
                l++;
            }else if(numbers[l] + numbers[h] > target){
                h--;
            }
            else{
                res.push_back(l+1);
                res.push_back(h+1);
                break;              
            }
        }
        return res;
    }
};
```

[Move Zero](https://leetcode.com/problems/move-zeroes/)
The approach is quite easy and solved it with one go. Firstly, I declared a vector. Then checked if the array contains non-zero, append that that vector otherwise counts how many 0s are there. After the counting is done we just append the number of 0s that was connected. At the end I just replaced the given vector with the new vector. Quite Simple and fun.

```
class Solution {
public:
    void moveZeroes(vector<int>& nums) {
        vector<int> res;
        int cc = 0;
        for(int i = 0; i < nums.size(); i++){
            if(nums[i] != 0){
                res.push_back(nums[i]);
            }else{
                cc++;
            }
        }
        for(int i = nums.size() - cc; i < nums.size(); i++){
            res.push_back(0);
        }
        nums = res;
    }
};
```
Cypress Integration with CI/CD Bitbucket | E2E testing with Bitbucket & Cypress
Tags: testing, cypress, javascript, cicd
Published: 2022-10-13 16:32:43

Cypress Integration with CI/CD Bitbucket | E2E testing with Bitbucket & Cypress

https://qaautomationlabs.com/cypress-integration-with-bitbucket-e2e-testing-with-bitbucket-cypress/
Azure Devops best practises: Learning by doing
Tags: azure, devops, architecture, community
Published: 2022-10-13 16:15:16

Greetings my fellow Technology Advocates and Specialists.

In this Session, I will provide you real-time insights on __AZURE DEVOPS BEST PRACTISES: LEARNING BY DOING__. 


| __IMPORTANT TO NOTE:-__ |
| --------- |
| For Ease of Explanation, I will provide Best Practises details for Azure Devops: __REPOSITORIES__, __PIPELINES__, __BOARDS__ & __WIKI__ |


| __BEST PRACTISES FOR REPOSITORIES:-__ |
| --------- |
| __Proper Folder Structure__ per Repository. |
| __Repository Security__, if we have multiple Repositories under same DevOps Project. |
| __Branching Strategy:__ 1) Feature to Development Branch, 2) Development to Main Branch. |
| Clean Commit History with Human Readable comments per commit. |
| Build Validation for Main Branch. |
| __Pull Request (PR)__ must have an Approval in Place to review the changes (Part of Code Review). |


| __HOW BRANCHING STRATEGY WORKS:-__ |
| --------- | 
| 1. Per Developer(s) – Working on Feature Branch. |
| 2. All Developer(s) Changes in Feature Branch are then Merged into Development Branch by Squash Commit using Pull Request (PR). | 
| 3. Feature Branch __DELETED__ post Squash Commit to Development Branch. | 
| 4. All changes committed in Development Branch is then pushed to MAIN Branch by Squash Commit using a Single Pull Request (PR). |
| 5. Development Branch __REMAINS__ post Squash Commit to MAIN Branch. |
| 6. Development and MAIN Branch should be in complete Sync (0 Commits Behind). |


| __BEST PRACTISES FOR PIPELINES:-__ |
| --------- |
| 1. YAML Based pipeline over Classic as it can be Version controlled. |
| 2. Reusable Templates. |
| 3. Proper Folder Structure for Each Pipeline. |
| 4. Proper Naming Convention for Each Pipeline. |
| 5. Pipeline Name and Folder should have a relevance with the Code Repository. |
| 6. Setup Pipeline Environment(s), Attach Approval Gate and Associate Pipeline(s) appropriately per Environment. |
| 7. Avoid using Pipeline Local Variable Groups or Variable Groups associated with Key Vault. All Key value pair needs to stored in Key Vault and should be retrieved as Pipeline Task. |
| 8. Use of Azure DevOps Marketplace Extensions. |


| __BEST PRACTISES FOR BOARDS:-__ |
| --------- |
| 1. If a Single DevOps Project is used to host Multiple Application Projects, then there should be __distinct Boards Per Application Project to manage Backlogs and Sprints__. |
| 2. __Permissions__ should be set accordingly for Single/Multiple Board(s) preferably using __AAD Groups__. |
| 3. __Pull Request (PR) should be linked with Work items__ in DevOps Boards so that when Pull Request (PR) is approved, it closes the Work item at the same time. This automatically puts a comment with the link to commit against the linked work item. |


| __BEST PRACTISES FOR WIKI:-__ |
| --------- |
| 1. __Create Wiki as Repo__ to version control. |
| 2. __Use Mermaid Diagrams__ below – a) Flow Chart b) Gantt Chart c) Sequence Diagram |


__Hope You Enjoyed the Session!!!__

__Stay Safe | Keep Learning | Spread Knowledge__
So, you want a RSS feed with the activity in GitHub?
Tags: rss, feed, github, activity
Published: 2022-10-13 16:14:37

If you wanted to publish your activity in GitHub somewhere and your preferred way was to read an old, friendly RSS feed, I have some not so good news for you. 

It is possible to get and RSS feed, but you need to send the adequate headers, as stated in [Feeds](https://docs.github.com/en/rest/activity/feeds).

    curl -H "Accept: application/atom+xml" https://github.com/security-advisories

This means that it won't be easy to get these feeds in your feedreader (as far as I know they won't allow to modify headers and, for example, the excellent [Feedly](https://feedly.com/) does not use this trick). 

But if you want to insert this in a program it should be easy to do (in Python, for example, you could use [feedparser](https://pythonhosted.org/feedparser/) module and, in [Other HTTP Headers](https://pythonhosted.org/feedparser/http-other.html#sending-custom-http-request-headers) they explain how to do it).


For example, for the activity of yours truly, you could use:

    d = feedparser.parse('http://github.com/fernand0', request_headers={'Accept':'application/atom+xml'})

Et voilà:

    d.entries

has the content available in the feed.

Let me know if this is of some utility for you.
What is NAS??? Before you are installing the NAS you must know these things...… 🤖🤖🤖🤖🤖🤖
Tags: cybersecurity, cloud, network, storage
Published: 2022-10-13 16:10:23

Read This 👇👇👇👇👇👇👇
https://lnkd.in/gE2wgHj
See System Restarts in 3 clicks (after one-time setup)
Tags: windows, restart, reboot, events
Published: 2022-10-13 15:59:31

---
title: See System Restarts in 3 clicks (after one-time setup)
published: true
description: Shows how to setup Windows (works in 7, 10, 11) so seeing system restarts is just a couple of clicks away
tags: Windows, Restart, Reboot, Events
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
---

Frustrating how it is so *non-obvious* to find when a Windows system has rebooted! I should just have to click a couple of buttons and have that information easily browsable. 

The following setup, once complete, will make this info only a couple of mouse clicks away. On Windows 11: (the first and last steps are slightly different on earlier versions of Windows, but you should not have any trouble figuring it out):

1. open `Event Viewer` (which you can find via the Search box or magnifying glass in Windows menu)
![Search for Event Viewer](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ulagw4the4fvg71zz9rc.png)
![Event Viewer Window](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6zwli1oq2hgkhw5dpnt3.png)
2. expand the `Windows Logs`, right-click the `System` item, select `Create Custom View`
![Select Create Custom View on System](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r7n3qpx8o4qpo4j83ecs.png)
3. where it says `<All Event IDs>`, enter `41,1074,6006,6008` and click OK
![Filter Window for Custom View](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bx8vhmu7in1kgmwsc1vw.png)
4. A `Save Filter to Custom View` dialog will appear; name the view something like `System Restarts` and click OK.
![Name the Filter](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g4sw7mft6a3dafozn80c.png)
5. (Optional) To group by *day* (very handy), right-click the new view in `Custom Views`, then `View` -> `Group by` -> `Date and Time` 
![Group by Day](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8ilus2xke34vpkdo3t9y.png)
6. On the desktop Task bar, while the `Event Viewer` window is still open, right-click the `Event Viewer` icon and select `Pin to Taskbar`.

Now seeing these restart-related events is a couple of clicks: click the `Event Viewer` in task bar, expand `Custom Views`, click `System Restarts`. 

My `Event Viewer` now looks like this: 

![Event Viewer with new Restarts Custom View](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a2ioho1td0bujmsehzin.png)

Eg, my last restart shows a `User32` event type (1074): 

> for the following reason: Operating System: Service pack (Planned)
 Reason Code: 0x80020010
 Shutdown Type: restart

Whereas the previous event shows a `Kernel-Power` event marked `Critical`:

> The system has rebooted without cleanly shutting down first. This error could be caused if the system stopped responding, crashed, or lost power unexpectedly.

Have fun!