teleren/devto huggingface dataset:
Global Research Letters - Home - GRL Research Paper Publishers Online - GRLJournals
Tags: globalresearchletters, publish, grljournal
Published: 2023-01-12 10:44:10

An open access journal is a type of academic journal that makes its articles available to anyone with an internet connection, free of charge. The open access model allows for wider dissemination of research findings, as articles are not limited to only those with access through a paid subscription. This can include not only researchers and scholars but also the general public, practitioners, policymakers and others.

Open access journals can be operated in a number of different ways, but typically authors or their institutions are required to pay an article processing charge (APC) to cover the costs of publishing. There are several ways for authors to make their research open access, and many journals, traditional or open-access, will allow authors to make their individual articles open access for a fee. There are many journals offering open access feature and other attributes. A highly authorized and recommended journal is [Global Research Letters](https://grljournals.in/). 

[Global Research Letters](https://grljournals.in/) (GRL) is a research journal authorized by the UGC. They offer research publishing services at nominal rates and are highly trusted by researchers and academics. GRL is an international journal that gives your research the reach, readership and visibility you need. The editors, reviewers, and members of the journal are all highly technical and have unparalleled expertise in their fields. GRL supports research in a number of fields including science, medicine, engineering, humanities, and more. Academicians and researchers choose GRL for quality peer review and open access visibility of their research work.
Adding a Leading Zero in 1 Line in JavaScript
Tags: javascript, tutorial, webdev
Published: 2023-01-13 14:27:05

---
title: Adding a Leading Zero in 1 Line in JavaScript
published: true
date: 2023-01-12 15:00:28 UTC
tags: JavaScript,javascript,tutorial,webdev
canonical_url: https://www.jenniferbland.com/adding-a-leading-zero-in-1-line-in-javascript/
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yzvg7xu451be1oc0ce2p.png
---

At work, I recently ran into a scenario where we were capturing a user's date of birth (DOB). This information is collected in 3 fields day, month, and year. If your DOB is January 7, 1962, people were inputting 1 for the month, 7 for the day, and 1962 for the year. This sounds good but our back-end database required both the month and day to be 2 digits. So I needed to find a way to add a leading zero for both of these fields.

## Starting Data

```javascript
let month = 1;
let day = 7;
```

My simple solution in one line is:

```javascript
month = `0${month}`.slice(-2)
```

Let's walk through this code. This combines `0` with the value the user inputs for their month. Then it takes the right two digits and assigns this to the month.

But what if the user inputs the value `10` for their month? It still works. It will combine 0 with 10 to produce `010` and then it takes the right two digits which is `10`.

## Let's Connect

Thanks for reading my article today. If you like my content, please consider [buying me a coffee](https://www.buymeacoffee.com/JenniferBland) ☕.
The Power of Greedy Algorithms: A Simple but Effective Approach to Problem-Solving
Tags: programming, algorithms, computerscience
Published: 2023-01-19 10:00:00

Are you in search of an efficient and effective way to solve complex problems in computer science? Look no further than greedy algorithms, a powerful technique that can help simplify and optimize your solutions. In this article, we'll explore the ins and outs of greedy algorithms and how they can revolutionize the way we approach problem-solving.

---

A greedy algorithm is a method for solving problems by making the locally optimal choice at each stage with the hope of finding a global optimum. The algorithm makes the most beneficial choice at the current moment, without worrying about the consequences of future decisions. This approach can lead to highly efficient solutions, as it reduces the number of decisions that need to be made.

One example of a problem that can be solved using a greedy algorithm is the "coin change problem." This problem involves finding the minimum number of coins needed to make a certain amount of change. A greedy algorithm would make the locally optimal choice of using the highest denomination coin possible at each stage, without worrying about the consequences of future decisions. This leads to the most efficient solution, as the algorithm always uses the largest denomination coin possible.

```python
# Function to solve the coin change problem using a greedy algorithm
def coin_change(coins, change):
    # Initialize a variable to keep track of the number of coins used
    num_coins = 0
    # Iterate through the coins in descending order
    for coin in sorted(coins, reverse=True):
        # Use as many of the current coin as possible
        num_coins += change // coin
        # Update the remaining change
        change %= coin
    return num_coins

# Example usage
coins = [1, 5, 10, 25]
change = 63
print(coin_change(coins, change))
# Output: 6
```

Greedy algorithms have a wide range of applications in other computer science fields, such as operations research, artificial intelligence, and graph theory. For example, in operations research, greedy algorithms are used to solve scheduling problems, in artificial intelligence, it is used in decision-making and planning, and in graph theory, it's used to find minimum spanning trees.

---

Greedy algorithms are a simple yet effective approach to problem-solving that can greatly improve the efficiency and optimality of our solutions. It's not just limited to a specific field but has a wide range of applications. By making the best decision at the present moment, we can find a globally optimal solution. So next time you're faced with a complex problem, consider using a greedy algorithm. It's time to take advantage of this powerful tool and elevate your problem-solving skills to the next level.
MongoDB
Published: 2023-01-14 13:52:03

**Introduction :**
MongoDB is a cross-platform, document-oriented database that provides high performance, high availability, and automatic scaling. It is a NoSQL database, which means that it does not use a fixed schema and does not rely on tables and rows to store data. Instead, MongoDB stores data in flexible, JSON-like documents, which can have any number of fields and can be nested. It also uses a dynamic schema, which allows for the addition, deletion, and modification of fields in a document without the need for fixed tables. MongoDB can be used for a wide range of applications, including big data, content management, and real-time analytics.

**Why MongoDB ?**
**High performance:** MongoDB is designed for high performance and can handle large amounts of data and high traffic. It uses a memory-mapped storage engine and an indexing system that allows for fast querying and data access.

**Scalability:** MongoDB is highly scalable and can automatically distribute data across multiple servers. This allows for horizontal scaling and easy management of large data sets.

**Flexibility:** MongoDB uses a document-oriented data model, which allows for flexible and unstructured data. This makes it easy to store and query data in a variety of formats, including nested objects and arrays.

**High availability:** MongoDB supports automatic failover and replication, which ensures high availability and disaster recovery.

**Cross-platform:** MongoDB runs on a variety of platforms, including Windows, Linux, and macOS. It also supports multiple programming languages, including Java, Python, and C#.

**Rich query language:** MongoDB has rich query language that supports ad-hoc queries, indexing, and real-time aggregation, which enables powerful ways to access and analyze the data

**Cloud support:** MongoDB has cloud-based solutions, like MongoDB Atlas, which allows you to easily deploy and manage MongoDB clusters in the cloud.

**Community support:** MongoDB has a large and active community, which provides support, tutorials, and resources for developers and administrators.
Subtle VsCode Extension I Can't Live Without
Tags: vscode
Published: 2023-01-13 15:00:09

I came across an extension for VsCode when I was frustrated about having to run the `code .` or `code ../<some_dir>` command over and over when I wanted a new VsCode window to open. 

I came across this [VsCode extension](https://marketplace.visualstudio.com/items?itemName=chrisdias.vscode-opennewinstance): `chrisdias.vscode-opennewinstance`

![Context Menu Shortcut](https://github.com/chrisdias/vscode-opennewinstance/raw/HEAD/images/preview.png "Context Menu Shortcut")


It's real simple, it just adds an option to your context menu inside of VsCode that allows you to open a folder in a new window/workbench. 

Although it's simple, I find it super useful, and realized recently when working on a VM that I can't live without it! It's one of the first extensions that I add to a new system.
Customized Basketball Suit for Every Customer
Published: 2023-01-14 01:55:00

With the improvement of people's living standards, more and more people begin to pay attention to the management of physical health and figure. All kinds of sports have become the object of people's pursuit, among which basketball is deeply loved by young people. Basketball has long been popular around the world. There are many kinds of professional basketball competitions at home and abroad, and more and more people take basketball as a profession. This has also spawned the industry of [custom basketball suits](https://www.printscode.com/National-Team-Basketball-Suits-pl3757638.html).
There are many existing sports clothing brands in China, but most of them have a single style of clothing. To cater to consumers, clothing is suitable for most sports, and there is no clothing specifically for basketball. Even if there are few clothing styles, it is easy to wear clothes, which can not meet the pursuit of the beauty of contemporary young people. Customization of basketball clothes can solve the above problems.
Customization of basketball clothes can be customized according to the shape of consumers, and can also meet the requirements of consumers on clothing color and style, and make their unique basketball clothes for each customer.
Link: [https://www.printscode.com/National-Team-Basketball-Suits-pl3757638.html](https://www.printscode.com/National-Team-Basketball-Suits-pl3757638.html)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6ufrvuapakjle6ipkqik.jpg)
Is GitHub flow better than Git flow?
Tags: git, tutorial, todayilearned
Published: 2023-02-08 11:33:03

## Git flow or Github flow?

The world of Git offers several collaboration strategies, including Github Flow, Git Flow, Gitlab Flow, and others. In this post, I'd like to share my thoughts on Github Flow specifically.

My team and I opted for Git Flow at the outset of our project, after a thorough discussion on which flow to adopt. We were all new to Git at the time, so we relied on [a post](https://techblog.woowahan.com/2553/) for guidance and diligently followed its advice.

## Let's do it: GitHub flow

As I continued to use Git Flow, I became aware of its limitations, particularly its complexity with the use of multiple branches - Master, Develop, Feature, Hotfix, and Release. However, this complexity can be mitigated through the use of Github Flow, which only requires two branches: Master and etc. As [Scott Chacon](https://scottchacon.com/2011/08/31/github-flow.html) stated, 

> Anything in the master branch is deployable.

Github Flow, first introduced by [Vincent Driessen](https://nvie.com/posts/a-successful-git-branching-model/), is a more suitable option for teams practicing [continuous delivery](https://www.atlassian.com/continuous-delivery/principles/continuous-integration-vs-delivery-vs-deployment), as it provides a simpler workflow compared to Git Flow. 

> If your team is doing continuous delivery of software, I would suggest to adopt a much simpler workflow (like GitHub flow)

## What if we require versioned releases?

As previously mentioned, anything in the Master branch is deployable, but there are times when we need to maintain starting points for significant updates. This is where the [Tagging](https://git-scm.com/book/en/v2/Git-Basics-Tagging) feature in Git comes in handy. By utilizing the git tag command, we can easily create versioned releases, such as

> $ git tag
v1.0
v2.0

## Further
- [**GitHub flow**](https://scottchacon.com/2011/08/31/github-flow.html)
- [Get started GitHub flow](https://docs.github.com/en/get-started/quickstart/github-flow)
- [Git flow, GitHub flow, GitLab flow](https://ujuc.github.io/2015/12/16/git-flow-github-flow-gitlab-flow/)
What is a Serverless Architecture?
Tags: webdev, beginners
Published: 2023-01-27 16:43:46

They say if you can't explain something to a kid you probably don't understand it yourself…right? I am sure they said that LOL!. Okay so in the simplest terms Serverless architecture is a way of building and running things like websites or apps where you don't have to worry about the underlying infrastructure, such as servers, and you can scale and adjust automatically as needed. 

Serverless architecture allows applications to be hostless ie not hosted on a server. This means that instead of having to provision and maintain servers, you can simply run your code in response to events and automatically scale as needed.

Examples of services that use serverless architecture include AWS Lambda, Azure Functions, and Google Cloud Functions. These services allow you to run your code in response to events such as an HTTP request, a message on a message queue, or a change in a database, and automatically manage the underlying infrastructure for you. This can include things like automatic scaling, patching, and security.

**Well you may ask what is the alternative to a serverless architecture?**

The main alternative to serverless architecture is a traditional, or "serverful," architecture. In this approach, you would provision and manage your own servers, or use a virtualized infrastructure, such as a cloud-based virtual machine (VM), to run your applications and services. This approach gives you more control over the underlying infrastructure, but also requires you to manage and maintain that infrastructure, including tasks such as scaling, patching, and security.
In a traditional architecture, you would typically use a web server such as Apache or Nginx to handle HTTP requests and an application server such as Tomcat or Node.js to handle application logic. You would also have to manage the underlying operating system, including security updates, and scaling the infrastructure up or down as needed.
Another alternative to Serverless is Container-based architecture, where you would package your applications and services as container images, and run them on a container orchestration platform such as Kubernetes or Docker Swarm. This gives you many of the benefits of serverless, such as automatic scaling and patching, but also gives you more control over the underlying infrastructure than serverless.

In summary, the main alternative to serverless architecture is traditional, or "serverful," architecture, where you would provision and manage your own servers or use a virtualized infrastructure to run your applications and services. Another alternative is Container-based architecture, which gives you many of the benefits of serverless but also gives you more control over the underlying infrastructure.

I know I have taken you down the little rabbit hole there for a minute but I hope we have come out the other end together alright. 
Thank you and stay tuned for more
How to use the Browser Geolocation API with StimulusJS and Rails
Tags: ruby, rails, geolocation, stimulus
Published: 2023-02-05 19:23:42

---
title: How to use the Browser Geolocation API with StimulusJS and Rails
published: true
tags: ruby,rails,geolocation,stimulusjs
canonical_url: https://blog.corsego.com/stimulus-get-browser-location
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/phyxyj5qqpnkgypoo4wp.png
---

Task: get users **coordinates** from browser, redirect to page with coordinates in params:

![geolocation-api-search.gif](https://blog.corsego.com/assets/images/geolocation-api-search.gif)

To request users’ location, we will use [Web/API/Geolocation/getCurrentPosition](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition) with StimulusJS.

Create stimulus controller:

```ruby
rails g stimulus geolocation
```

```js
// app/javascript/controllers/geolocation_controller.js
import { Controller } from "@hotwired/stimulus"

const options = {
  enableHighAccuracy: true,
  maximumAge: 0
};

// Connects to data-controller="geolocation"
export default class extends Controller {
  static values = { url: String }

  search() {
    navigator.geolocation.getCurrentPosition(this.success.bind(this), this.error, options);
  }
  
  success(pos) {
    const crd = pos.coords;
    // redirect with coordinates in params
    location.assign(`/locations/?place=${crd.latitude},${crd.longitude}`)
  }

  error(err) {
    console.warn(`ERROR(${err.code}): ${err.message}`);
  }
}
```

Finally, a button to get location:

```html
<div data-controller="geolocation">
  <button data-action="geolocation#search">search near me</button>
</div>
```

💡 Interestingly, if you use `this.success` instead of `this.success.bind(this)`, stimulus targets will not work within the success function.

### Get address from coordinates

Get **address** (city, street...) based on **coordinates** using [**geocoder**](https://blog.corsego.com/gem-geocoder-ruby) , and search `near` the address:

```diff
# app/javascript/controllers/geolocation_controller.js
- location.assign(`/locations/?place=${crd.latitude},${crd.longitude}`)
+ location.assign(`/locations/?coordinates=${crd.latitude},${crd.longitude}`)
```

```diff
# app/controllers/locations_controller.rb
  def index
+    if params[:coordinates].present?
+      place = Geocoder.search(params[:coordinates])
+      params[:place] = place.first.address
+    end

    if params[:place].present?
      @locations = Location.near(params[:place], params[:distance] || 10, order: :distance)
    else
      @locations = Location.all
    end
  end
```

That’s it! Now you can get Geolocation with Javascript and use it within a Rails app!
Advance Git commands
Published: 2023-02-05 17:02:54


**Version control**, also known as source control, is the practice of tracking and managing changes to software code, it helps software teams manage changes to source code over time.

VC sometimes known as SCM (Source code management) tools or RCS (Revision Control System) and one of the most popular VCS tools in use today is called GIT.


Git is a distributed version control system, a category known as DVCS that tracks changes in any set of computer files, usually used for coordinating work among programmers collaboratively developing source code during software, Git once had a reputation for a steep learning curve. However the Git maintainers have been  steadily releasing new improvements like sensible defaults and contextual help massages that have made the onboarding process a lot more pleasant.

**Advanced Git commands are listed and explained below**

**GIT rebase command** is similar to the git command, it combines a sequence of commits to a new base commit. Rebasing is most useful and easily visualised in the context of a feature branching workflow, you can rebase whenever you want to add changes of a base branch back to a branched out branch. You should use the Git rebase command when you have multiple private branches to consolidate into a single branch.

Usage
$ git rebase <base>

**The git revert command** can be considered an 'undo' type command, however, it is not a traditional undo operation. Instead of removing the commit from the project history, it figures out how to invert the changes introduced by the commit and appends a new commit with the resulting inverse content. This prevents Git from losing history, which is important for the integrity of your revision history and for reliable collaboration. Reverting should be used when you want to apply the inverse of a commit from your project history. This can be useful, for example, if you’re tracking down a bug and find that it was introduced by a single commit. Instead of manually going in, fixing it, and committing a new snapshot, you can use git revert to automatically do all of this for you.

**git cherry-pick** is a powerful command that enables arbitrary Git commits to be picked by reference and appended to the current working HEAD. Cherry picking is the act of picking a commit from a branch and applying it to another. git cherry-pick can be useful for undoing changes. It doesn't modify the history of a respiratory insteads it adds to the history.

Usage
 $ git cherry-pick  <commit-hash>
Open-Sourced GPTZero
Tags: gpt3, opensource, nlp, programming
Published: 2023-01-29 00:00:45

## **We've open-sourced the implementation of GPTZero!** 

**How does it work?**

1. It uses GPTv2 Perplexity Model from [ Huggingface ](https://huggingface.co/docs/transformers/perplexity)to find total perplexity of the sentence. 

2. Later, we break it into individual sentences based on some delimiters, and find individual perplexity per line and find total average perplexities. 

3. The average perplexities is then passed through certain threshold, and if it crosses it, it becomes human-centric, otherwise the text is generated by an AI.

- You can find the implementation on GitHub [here](https://github.com/BurhanUlTayyab/GPTZero). 

- Play around with it with a website [here](https://gptzero.sg). 

- How we implement, watch [here](https://www.youtube.com/watch?v=x9H-aY5sCDA).

- Join our [Discord](https://discord.com/invite/F3kFan28vH) community for discussion and feedback. 

See you there~

_Powered by Ailiverse_