teleren/devto huggingface dataset:
Learn JSON in Just 15 Minutes - JSON Crash Course
Tags: json, tutorial, javascript, beginners
Published: 2023-01-17 13:16:19

**JSON**, or **JavaScript Object Notation**, is a lightweight data-interchange format that is easy for humans to read and write and easy for machines to parse and generate.It is based on a subset of the **JavaScript Programming Language**. 

To learn JSON in 15 Minutes, Watch [This Video](https://youtu.be/km55ihIBKBA)!

JSON is a text format that is completely language-independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others.

One of the main advantages of using **JSON** is its ability to transmit data between a server and a web application, as well as between different systems. This makes it an ideal choice for web and mobile applications that need to transmit data over a network. Additionally, **JSON** is also easy to read and understand, making it a popular choice for data storage and sharing.

Getting started with JSON is easy. Here are the basics:

1. JSON consists of **key-value pairs**, similar to a dictionary in Python or an object in JavaScript. The key is a string, and the value can be a string, number, boolean, null, array, or another JSON object.
2. JSON uses double quotes for keys and values, and each key-value pair is separated by a comma.
3. JSON objects are enclosed in curly braces {} and arrays are enclosed in square brackets [].
4. Here is an example of a JSON object:

```
{
    "name": "John Smith",
    "age": 30,
    "isStudent": false,
    "courses": ["math", "science", "history"]
}
```
5. To parse a JSON object in JavaScript, you can use the JSON.parse() method, like this:

```
let jsonData = '{"name":"John Smith","age":30,"isStudent":false,"courses":["math","science","history"]}';
let obj = JSON.parse(jsonData);
console.log(obj.name); // "John Smith"
```

With just these basic concepts, you can start working with JSON in your web and mobile applications. And as you can see, you can learn **JSON in just 15 minutes**!

JSON is very useful and widely used format in today's web development, it's lightweight and easy to use, so it's a good idea to have a basic understanding of it.

Once again, to learn JSON in 15 Minutes, Watch [This Video](https://youtu.be/km55ihIBKBA)!
Stubs/fakes(casting as a particular object)
Tags: webdev, javascript, beginners, programming
Published: 2023-01-17 13:11:54

Stubs are a key tool for software testing, allowing developers to **test individual units of code in isolation by replacing external dependencies with simplified versions.**

Here's an example of a stub in use:

```javascript
import { IncomingMessage } from "http";
import { Utils } from "../../app/Utils/Utils";

describe('Utils test Suite', () => { 
    test('getRequestPath valid request', () => { 
        const request = {
            url: 'http://localhost:8080/login'
        } as IncomingMessage
        const requestPath = Utils.getRequestBasePath(request);
        expect(requestPath).toBe('login')
    })
})
```

In this example, the `Utils.getRequestBasePath(req: IncomingMessage): string` function is being tested using a stub, specifically the `const request = { url: 'http://localhost:8080/login' }as IncomingMessage` object. 

This object simulates an incoming HTTP request, and is used in place of an actual incoming request that would come from a client. The function is supposed to extract the base path of the request URL and return it. In the test case, the request URL is hardcoded to be "http://localhost:8080/login", and the expected output is "login". The test case uses the Jest testing framework to test the expected output of the function.

**Stubs are not only useful in unit testing but also in integration testing and acceptance testing**. They are used to replace external systems with simple implementations, allowing the developer to test how different parts of the system interact with each other, and make tests more efficient, reliable, and flexible.
You should try git worktrees
Tags: git, productivity
Published: 2023-01-17 13:07:14


## What is it?

`git worktree` is a git command enabling to create copies of the repository to work on several branches at the same time without having to constantly use `git stash` for context switching.

## Why is it cool?

It is cool because it happens quite often that you are working on your branch when something urgent comes up. In that case what you usually do is stash your changes or commit as is with a commit message like *"WIP login form (TO SQUASH)"* (and let's be honnest, that commit won't be squashed). Then you checkout on the branch the urgent work needs to be done, you start to do the work and something even more urgent comes up. Here we go again: `git stash`, `git checkout hotfix/even-more-urgent-stuff`, ... I think you got the point, we all have repos where `git stash list` is scaringly huge and more often than not you don't put messages on each stash to remember exactly what it you were doing and why.

With git worktrees, you will have copies of your repo tracking each branch, allowing you to simply `cd` into the copy you want to do the required changes. When you have to move on to more urgent stuff, that means you don't necessarily have to commit right now nor have to stash your changes anymore: you just `cd` into the workspace you created for tracking that other branch.

## The drawbacks

There is only a single drawback that comes to my mind: many IDEs do not integrate well with having several copies of a repo opened at the same time, hence the need for closing and reopening projects that are - in fact - the same project but in another directory. 
Where I see this feature of git actually speeding up my workflow without overcomplicating it is when I work mainly from the terminal, with IDEs like Vim or just opening my IDE from the right directory/workspace and closing it when I need to move on to another branch. This second option can take a lot more time, especially in IDEs where the launch is slow (looking at you IntelliJ).

## Disclaimer

I don't actually have had the time to explore that feature extensively so if that article interested you, I **highly** encourage you to look for more articles explaining how this feature works with actual commands.
If I use it more in my day-to-day work, I will write a follow-up article explaining more precisely how I use it, what are the commands and the eventual shortcuts I use.

### More links to look at

Documentation for the `git worktree` command: https://git-scm.com/docs/git-worktree

ThePrimeagean on Youtube has a great video displaying his use of `git worktree`: https://youtu.be/2uEqYw-N8uE

Using `git worktree` with GitKraken: https://www.gitkraken.com/learn/git/git-worktree
How to serve a Vite + Vue3 page inside a sub-folder
Tags: vite, vue3, vue
Published: 2023-01-17 12:55:25

Today I've spent a quite long amount of time trying to figure out how to just serve a Vue3 + Vite page inside a sub-folder, so i decided to make a very quick post to help any people in the same situation. 

So the URL was like `https://example.com/my-page/`, and to make this happens, you need two changes

The first one is on `vite.config.ts` or `.js`, and add the parameter `base: ''`, when using `''` will work with any sub-folder, since the `index.html` assets URLs will start with `./` and use the relative path

```js
export default defineConfig({
  ...,
  base: '', // or the path instead if you want '/my-page/'
});
```

The second change, is inside your vue router , in my case `src/router/index.ts` and add the parameter base in `createWebHistory(base?: string)`

```js
const router = createRouter({
  history: createWebHistory('/my-page/'),
  routes: [...],
  ...
});
```

You could experiment with `location.pathname` to make it agnostic of the folder name, but on my testing, it fail after navigating to another route

Alternatively, you could modify your `index.html` instead of the router and just add the base tag like this `<base href="https://example.com/my-page/">`

Note that if you go to another route, ex: `https://example.com/my-page/my-route` and refresh the page, it might show you the root page of `https://example.com/`, this is something you will need to fix via your web server config such nginx, and doing that you might not need to do all these changes mentioned above, i recommend this setup just for showing a work in progress project, or one page landing, etc

I hope this was helpful.

References:
- https://v3.vitejs.dev/config/shared-options.html#base
- https://router.vuejs.org/api/#createwebhistory
- https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
A few words about exploratory testing
Tags: testing, qa, beginners
Published: 2023-01-17 12:51:12

Exploratory testing is a type of software testing that is focused on exploring the system and discovering new defects and issues. It is an interactive and dynamic testing technique that allows testers to use their creativity and curiosity to find defects that might have been missed by other types of testing.

That technique is often used when there is little or no documentation or requirements for the system being tested. It is also used when the system is complex or the testing goals are not clearly defined.

During exploratory testing, testers will typically use a combination of testing techniques, including manual testing, automated testing, and exploratory testing tools. They will also use their knowledge and experience to identify potential issues and test the system in ways that were not previously planned or specified.

One of the key benefits of exploratory testing is that it allows testers to uncover defects early in the development process, which can save time and money in the long run. It also allows testers to identify areas of the system that need further testing and to develop new test cases based on the defects that are found.

We still need to remember, that exploratory testing is a powerful technique for discovering defects and issues in software, however, it may not be sufficient in certain situations.

One of the main limitations of exploratory testing is that it is highly dependent on the skills and experience of the tester. 
It relies on the tester's ability to identify potential issues and test the system in ways that were not previously planned or specified. In situations where the tester lacks the necessary expertise or experience, exploratory testing may not be effective.

Another limitation of exploratory testing is that it may not be as thorough as other types of testing. It is focused on discovering new defects and issues, but it may not cover all possible scenarios or test cases. For example, if a software is built to be compliant with certain regulations, exploratory testing may not cover all the regulations or test cases required to assure compliance.

Additionally, in situations where there are strict deadlines or the system is mission-critical, exploratory testing may not be feasible due to the time and resources required. In these cases, other types of testing such as regression testing or automated testing may be more appropriate.

Overall, while exploratory testing is a valuable technique for discovering defects and issues, it should be used in conjunction with other types of testing to ensure that the software is thoroughly tested and meets the required quality standards.
Why I listened to radio stations for working
Tags: radio, programming, writing
Published: 2023-01-17 12:40:05

For the past couple of days or so, I have been listening to music from radio stations around the world on [radio.garden](https://radio.garden/?r=1), whenever I'm working or studying.

The reason why I chose this over Youtube or my offline music collection is broken down into 6 parts:

- __I listened to songs I know and love__. When I'm clicking on a radio station, I always know what to expect from the description or station name. Meanwhile if I turned into my Youtube collection, where it's just a bunch of random music, I never know if it's gonna play low-quality Rasputin or a banger phonk song while I'm studying.
- __Radio stations are like subreddits.__ You can find one for just about everything. If you want to listen to music from records that spins at 78 RPM from the late 1800s to the 1950s, [you can](http://radio.garden/listen/jan-s-78rpm-record-warehouse/). If you want to listen music from one of the world's northernmost inhabited areas, well, [you can too](http://radio.garden/listen/arctic-outpost-am-1270/). The thing is, no matter how obscure what you are looking for, there's almoat always a station just for it.
- __I never know what's playing next__. If I listen to music on my Youtube collection, I can always knew what will be playing next (at least on mobile), and even if I do it on computer, the algorithm isn't exactly random. But on radio stations, it is truly random. I never know what's going to play next, or if I will enjoy it. I just know it's something I will expect from them. Yes, stations still replay music every once in a while, but at least it is not trying to appeal to me.
- __I discovered new songs__. Every time I'm listening to a song on a certain station and found the song to be great, I often used my trusty Shazam to identify it. Radio stations has helped me discovered new songs that I liked and added them imto my music collection.
- __It's good for your privacy__. With services like Spotify and Youtube, you run into the risk of data mining and megacorps selling your data for advertising companies. Meanwhile radio stations doesn't collect your data, and their advertisements only came in form of sponsorships.
- __It's easy__. You don't have to sign up and log in and search to start listening to music. With radio, just tune in on a station you liked and you are set.

So yeah, that's why I listened to radio stations, and why you should, too.

> This post is a cross-post from [my personal blog](https://tsk.bearblog.dev/why-i-listened-to-radio-stations-for-working/). Check it out too!
Jetpack Compose Grid without Lazy
Tags: android, ux, kotlin
Published: 2023-01-14 19:19:54

## Introduction

For most grid situations we could use `LazyVerticalGrid`. But not if you want to add the grid to a scrollable column with multiple scrollable elements.

My custom grid-component fixes this exception:
`Nesting scrollable in the same direction layouts like LazyColumn and Column(Modifier.verticalScroll()) is not allowed.`

## Example

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


## Usage

=> The number of columns can be passed via `columns`-property.

```kotlin
Column(
    modifier = Modifier
        .fillMaxWidth()
) {
    Text(
        text = "Features",
        style = MaterialTheme.typography.h1,
        modifier = Modifier.padding(15.dp)
    )

    NonlazyGrid(
        columns = 3,
        itemCount = features.size,
        modifier = Modifier
            .padding(start = 7.5.dp, end = 7.5.dp)
    ) {
        FeatureItem(features[it])
    }
}
```

## Implementation

```kotlin
@Composable
fun NonlazyGrid(
    columns: Int,
    itemCount: Int,
    modifier: Modifier = Modifier,
    content: @Composable() (Int) -> Unit
) {
    Column(modifier = modifier) {
        var rows = (itemCount / columns)
        if (itemCount.mod(columns) > 0) {
            rows += 1
        }

        for (rowId in 0 until rows) {
            val firstIndex = rowId * columns

            Row {
                for (columnId in 0 until columns) {
                    val index = firstIndex + columnId
                    Box(
                        modifier = Modifier
                            .fillMaxWidth()
                            .weight(1f)
                    ) {
                        if (index < itemCount) {
                            content(index)
                        }
                    }
                }
            }
        }
    }
}
```
How to build a responsive website with the help of ChatGPT?
Tags: webdev, programming, chatgpt, tailwindcss
Published: 2023-01-17 12:24:54

Do you know you can even build a responsive website using ChatGPT?

How to build a responsive website with the help of ChatGPT?

ChatGPT approaches the search differently than Search engines(Ex: Google). When you search on Google...

- Google search provides a list of resources from where users need to find the answer. 
- Whereas ChatGPT does this work for the user. It analyzes the data and provides the most relevant answer to the user.

Imagine you want to write an article on how meditation helps you achieve your goals.

You visit the library and ask the librarian(google) to give you the top 10 books(websites) relevant to your article. Then you need to curate content from those books or resources.

But if you use ChatGPT, it will write a 1000 word article for you. So you don't need to work on curation and writing.

I have asked some of the questions listed below.

- How to start with vue3 and tailwind CSS websites?
- Create a software company’s website using Vue3 and tailwindcss
- How to start with Vue3 and tailwind CSS for creating a software company’s website?

ChatGPT has answered with an explanation and provided links for this task.

For a detailed article, check out [canopas blog](https://blog.canopas.com/how-to-build-a-responsive-website-with-the-help-of-chatgpt-2c1f39189098).
help me with windows terminal running neovim on ubuntu
Tags: ubuntu, neovim, termimal, nerdtree
Published: 2023-01-17 12:16:35

hello guys 
there are several things i need help with 
1.how to open commands on the very bottom
2.help me with shortcuts like(how to save a config)
3.what is nerdtree plugin?
please help me i am in desperate need of help

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/us9jqyvxd6qxacm2vd90.png)
How to virtualise on Apple M1
Published: 2023-01-17 11:57:00

I recently got a new MacBook Pro backed by the "almost" new Apple M1 socket, it's just brilliant and the battery life it's just astonishing, I'm able to run multiple workloads, have a always-on Fedora VM, and the battery won't die before the second day. 

I usually run a separated environment for my development, this allows me to keep my machine pristine (I used to do that with my previous laptop, Dell XPS 15) from dev dependencies and files that I'll never remove. In this article I'd like to show you how I virtualise on Mac and how I use VM to develop. 

> Please note that I'm not affiliated with any of the software/vendor below. What I'm writing is from my own experience. 

## Virtualisation Options 

### UTM 
UTM is an Open Source virtualisation software able to run Linux, Windows and OSX even on Apple M1. UTM allows you to run the virtualisation as-is or to use Rosetta and emulate an intel-like processor. I really like the UI simplicity and the software itself is just made to do what's supposed to, without too many features that sometime can be overwhelm.  

**PRO**
- Free / paid for 12€ on mac store
- Same features as Parallels (as much as I’m concerned) 
- Open Source
- Offer different types of virtualisation (even with Rosetta)

**CONS**
- Sometimes it can be challenging to create a new VM (the install process may fail if virtualisation is not set correctly)
- Need at least an additional settings screen to setup the IP ranges for the created VMs
- Installing Windows is really challenging as you need to basically create the ISO file (from a Windows machine...)
- Graphic acceleration doesn't work well on Windows 

### Parallels 
Parallels is a top-tier emulation software, the VM creation process is straightforward with a Wizard that guide you through all the steps, many automated. It provides a lot of customisations and options to literally unleash the real virtualisation power. This is my fav if you use virtualisation for business reason as you get extensive support with the business version. 

**PRO**
- It is straightforward and intuitive
- Creation process easy
- Mapping of CMD to CTRL

**CONS**
- License is annual and expensive 
- Doesn’t offer that much more rather than UTM (for my daily usage)


## VSCode 
Now VSCode allows you to SSH into a Linux VM, then it installs a VSCode-Server and let you code on the connected machine as you were in local. Additionally, to my surprise, it also automatically set port-forwarding, therefore if you start a web-server it will automatically forward your `localhost:something` to you `ssh-machine:something`. 


What I've done is

1. I created an SSH key and installed it on my VM 
2. I set a static IP so it won't change on reboot 
3. Open VSCode and install the Remote SSH extension
4. Connect to the VM
5. Happy coding!

Happy to answer any question, please let me know if you'd like to see more pictures and if this article is clear :) 

Special thanks to [Morten](https://github.com/mjvirt) for his tips and tricks.

Cheers
Danilo
Disagree and commit principle
Tags: management, agile, softskills
Published: 2023-01-17 11:55:38

Are you looking for a way to increase collaboration and effective decision-making in your team?

In many companies, most notably at Amazon, they use the "disagree and commit" principle to reach an agreement and make decisions quickly.

But what is it - and what are the prerequisites for this principle to actually work?


Check out this video to learn more!

{% embed https://www.youtube.com/watch?v=RYGuUHYGdUU %}
C++ for Everyone – Second Edition
Tags: cppforeveryone, cpp, secondedition, book
Published: 2023-01-17 11:47:23

Cay S. Horstmann’s thorough introduction to the C++ programming language is titled “C++ for Everyone, Second Edition.” It offers a comprehensive overview of the language and its capabilities and is designed to be approachable for both novice and seasoned programmers. You can Download the PDF of this book at the end of the Post. If you want to buy the Printed version visit here.

The book’s initial chapters address data types, control structures, and functions. Then, topics like classes, object-oriented programming, and templates that are more complicated are discussed. The book also covers the Standard Template Library (STL), a potent collection of templates for well-known data structures and algorithms.. By using the STL, you may make your code simpler and more efficient.


The focus on sound programming practises is one of this book’s distinctive aspects. The author offers helpful advice on writing understandable, legible, and maintainable code in addition to pointers for debugging and testing your applications. To help you apply what you have learned, the book also includes a variety of programming assignments and examples..

The second version of the book has been revised to reflect the most recent changes to the C++ standard and programming best practises. A new chapter also covers the most recent version of the language, C++ 11, which adds new functions like lambda expressions, move semantics, and range-based for loops.


All things considered, This book is a thorough and approachable manual for the C++ programming language. For anyone wishing to study C++ or deepen their understanding of the language, it is a fantastic resource. This book will provide you the skills and information you need, whether you are a novice or an expert programmer, to master C++ and produce effective, high-quality code.

Download Book
https://hecodesit.com/c-for-everyone-second-edition/