teleren/devto huggingface dataset:
Laravel Request wantsJson() - isJson() 
Tags: php, laravel, programming, beginners
Published: 2022-01-17 09:30:43

Today I want to share this information with you, in the hope that it will help you in your future projects.

The ``wantsJson()`` method checks the Accept HTML header for the string application/json and returns true if it is set.

The ``isJson()`` method checks that the HTML header CONTENT_TYPE contains the string /json and returns true if it is found.

Both methods are found in vendor/laravel/framework/src/Illuminate/Http/Request.php
``use Illuminate\Http\Request;``

If you want to check if response needs to be JSON
If you want to check if request is of JSON type
```php
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class UserController extends Controller
{
    public function index(Request $request)
    {
        dd($request->wantsJson()); // output:- false
    }
}
```
Not all AJAX requests expect a JSON response, so utilizing request()->ajax() is useful where you want to determine if the request was an XmlHttpRequest or not, but the response doesn't care about JSON or not.

Not all requests that contain JSON expect a JSON response. so if you don't care about whether or not the response wants JSON back, but want to determine if JSON was sent in the request, then isJson() is useful for you.

Not all requests that want JSON responses are AJAX driven, so wantsJson is useful in the case where you want to return JSON data, but you don't care how the request came to your server.

I hope you enjoyed the code.
How to seperate DEV and PROD Firebase Projects in NUXT 🔥
Tags: vue, firebase, javascript, devops
Published: 2022-01-17 10:37:52

Just as easy as deploying a NUXT SSR App using Vercel is the implementation of DEV and PROD environments for 2 different firebase Projects.

First TODO is to create seperate projects in Firebase. I named mine **project-dev** and **project-prod**.

In your `nuxt.config.js`, all you have to add is the following env attribute:

```
export default {
  env: {
    NODE_ENV: process.env.NODE_ENV
  },
```

In your `firebase.js` or .ts file, you have to create 2 seperate config variables for the 2 firebase projects. 

```
const configDev = {
  apiKey: 'verysecret',
  authDomain: 'project-dev.firebaseapp.com',
  projectId: 'project-dev',
  storageBucket: 'project-dev.appspot.com',
  messagingSenderId: 'verysecret',
  appId: 'verysecret',
  measurementId: 'verysecret'
};

const configProd = {
  apiKey: 'verysecret',
  authDomain: 'project-prod.firebaseapp.com',
  projectId: 'project-prod',
  storageBucket: 'project-prod.appspot.com',
  messagingSenderId: 'verysecret',
  appId: 'verysecret'
};

let firebaseApp;

if (!getApps().length) {
  if (process.env.NODE_ENV === 'development') {
    firebaseApp = initializeApp(configDev);
  } else {
    firebaseApp = initializeApp(configProd);
  }
}
```

Thats it. As easy as it could be. Developing on localhost will now use the dev Firebase project, deploying it (for example on vercel) will automatically change the project to **project-prod**. 

If you just added a new Firebase PROD Project, you will have to activate your features (Firestore, Auth, ...), then it should work just as the DEV project.
Modern alternatives to famous shell commands
Tags: linux, bash
Published: 2022-02-03 12:03:13

---
title: Modern alternatives to famous shell commands
published: true
date: 2022-01-17 10:19:48 UTC
tags: Linux,bash
canonical_url: https://daniele.tech/2022/01/modern-alternatives-to-famous-shell-commands/
---

Discover alternatives to ls, cat, grep and so on

The post [Modern alternatives to famous shell commands](https://daniele.tech/2022/01/modern-alternatives-to-famous-shell-commands/) appeared first on [Daniele Mte90 Scasciafratte](https://daniele.tech/eng).
List of Mental Health & Therapy Platforms to Deal With Stress and Burnout
Published: 2022-01-17 10:17:07

_The story was originally posted on [Ace's blog] (https://blog.getace.io/)_

In this blog post, we’ve gathered the top 12 popular online therapy platforms with specialists that will help deal with psychological issues of any kind.

These useful sources are not directly connected to the professional life of software engineers, yet deserve special attention though. Sometimes a software development gig can seem like the cushiest job in the world, but this perception can often be misleading. Software developers often face chronic stress due to tough deadlines and unmanageable workloads.

That’s why developer burnout is a real problem. So, every developer should take care of their mental health and have the opportunity to get psychological support when it’s necessary.

Read how a manager can avoid developer burnout in our article - [Developer Burnout Can Be a Serious Issue. Here Is How to Spot It] (https://blog.getace.io/all-posts/developer-burnout?utm_source=devto&utm_campaign=blog_promo)

> GET FREE EBOOK - [Ultimate guide on developer burnout, with best practices & tools](https://www.getace.io/ebooks/one-to-one-with-developers-guide?utm_source=devto&utm_campaign=ebook_promo). 


# [BetterHelp] (https://www.betterhelp.com/) Professional Counselling

Languages: English

# [Talkcircle] (https://talkcircle.com/) Online Video & Text Therapy

Languages: English, German, Spanish, French

# [TherapyTribe] (https://www.therapytribe.com/) Free Mental Health Support Community

Languages: English, German, Spanish, French

# [Talkspace] (https://www.talkspace.com/) Online Therapy With Licensed Psychologists

Languages: English

# [It’s Complicated] (https://complicated.life/) International Counselling Platform

Languages: English

# [Calmerry] (https://calmerry.com/) Professional Mental Health Support

Languages: English

# [Sesh Therapy] (https://seshtherapy.com/) Online Group Support Sessions

Languages: English

# [Online-therapy.com] (https://www.online-therapy.com/) Cognitive Behavioral Therapy

Languages: English

# [7 Cups] (https://www.7cups.com/) Free Online Therapist & Counseling

Languages: English, Russian, Spanish, French

# [Alma] (https://www.helloalma.com/) Counseling Center

Languages: English

# [Yasno] (https://yasno.live/) Video Counseling With Therapists

Languages: Russian

# [Zigmund] (https://zigmund.online/) Online Therapy

Languages: Russian

---


To help you and your team deal with work stress, [Ace] (https://www.getace.io/) can spot the early signs of developer burnout based on his/her performance and activity in messengers and recommend the best online therapy platforms for those who need it.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aqzvunjskx7c6qddj2c7.png)
_Ace catches the early signs of burnout_

_The story was originally posted on [Ace's blog] (https://blog.getace.io/)_
How to work with configs in Mezon Framework
Tags: config, mezon, php, ini
Published: 2022-01-17 10:17:02

[Mezon]() has it's own routine for working with configs. It can be accesed with a set of functions, wich are described below.

This is the way how to start using it in your project:

```bash
composer require mezon/conf
```

Or get it directly from [repo](https://github.com/alexdodonov/mezon-conf);

Getting access to the key in config can be done with `Conf::getValue($route, $defaultValue = false)` function. It returns config value with route $route and return $defaultValue if this key was not found. For example:

```php
$value = Conf::getValue('res/images/favicon', 'http://yoursite.com/res/images/favicon.ico');
```

Setting values for the config key can be done by calling `Conf::setConfigValue($route, $value)` or `Conf::addConfigValue($route, $value)` function. The main difference between these two functions is that the first one sets scalar key, and the second one adds element to the array in config. Here is small example:

```php
Conf::setConfigValue('res/value', 'Value!');
var_dump(Conf::getValue('res/value')); // displays 'Value!' string

Conf::addConfigValue('res/value', 'Value 1!');
Conf::addConfigValue('res/value', 'Value 2!');
var_dump(Conf::getValue('res/value')); // displays array( [0] => 'Value 1!' , [1] => 'Value 2!' )
```

You also can use typed versions of these methods:

```php
Conf::getValueAsArray(...);
Conf::getValueAsObject(...);
Conf::getValueAsString(...);

Conf::setConfigArrayValue(...);
Conf::setConfigObjectValue(...);
Conf::setConfigStringValue(...);
```

You can set multyple values to the config:

```php
// here $settings is an associative array
Conf::setConfigValues(array $settings);
```

Or you can read config from JSON:

```php
Conf::loadConfigFromJson(string $pathToConfig);
```

If you are not shure that the key exists, then you can check it:

```php
Conf::setConfigValue('res/value', 'Value!');

var_dump(Conf::configKeyExists('res')); // true
var_dump(Conf::configKeyExists('res2')); // false
var_dump(Conf::configKeyExists('res/value')); // true
```

You can also able to delete config key

```php
Conf::setConfigValue('res/value', 'Value!');
Conf::deleteConfigValue('res/value');
var_dump(Conf::configKeyExists('res/value')); // false
var_dump(Conf::configKeyExists('res')); // also false
```

Or clear the entire config:

```php
Conf::clear();
```

That's all you need to know about config read/write.

## Learn more
More information can be found here:

[Twitter](https://twitter.com/mezonphp)
[Mezon Framework](https://github.com/alexdodonov/mezon)

It will be great if you will contribute something to [this project](https://github.com/alexdodonov/mezon-conf). Documentation, sharing the project in your social media, bug fixing, refactoring, or even submitting issue with question or feature request. Thanks anyway )
Fun Experiment: Bringing lazy execution to JS!
Tags: javascript, webdev, npm, opensource
Published: 2022-01-17 09:53:04

> Bringing lazy execution to higher order functions in JS!
![Teaser](https://pbs.twimg.com/media/FJPlI_saAAArL5h?format=jpg&name=4096x4096)
**How to Use**

- Install the package
`npm i lazy-hofs`

- Add to your project
`require("lazy-hofs");`

**lazySome()**
```js
let arr = [1, 2, 3, 4, 5, 6];
let ref = arr.lazySome((it) => {
  return it === 9;
});
arr.push(9);
let result = ref.lazyEvaluate();
console.log(result);
```

**lazyMap()**
```js
let arr = [1, 2, 3, 4, 5, 6];
let ref = arr.lazyMap((it) => {
  return it * 9;
});
arr.push(9);
let result = ref.lazyEvaluate();
console.log(result);
```
**lazyFilter()**
```js
let arr = [1, 2, 3, 4, 5, 6];
let ref = arr.lazyFilter((it) => {
  return it % 2 === 0;
});
arr.push(9);
let result = ref.lazyEvaluate();
console.log(result);
```

**lazyReduce()**
```js
let arr = [1, 2, 3, 4, 5, 6];
let ref = arr.lazyReduce((it, acc) => {
  return (acc += it);
}, 0);
arr.push(9);
let result = ref.lazyEvaluate();
console.log(result);
```

Join me here: https://npmjs.com/package/lazy-hofs
Contributions welcome!
Fun Experiment: Bringing lazy execution to JS!
Published: 2022-01-17 09:51:08

> Bringing lazy execution to higher order functions in JS!
![Teaser](https://pbs.twimg.com/media/FJPlI_saAAArL5h?format=jpg&name=4096x4096)
**How to Use**

- Install the package
`npm i lazy-hofs`

- Add to your project
`require("lazy-hofs");`

**lazySome()**
```js
let arr = [1, 2, 3, 4, 5, 6];
let ref = arr.lazySome((it) => {
  return it === 9;
});
arr.push(9);
let result = ref.lazyEvaluate();
console.log(result);
```

**lazyMap()**
```js
let arr = [1, 2, 3, 4, 5, 6];
let ref = arr.lazyMap((it) => {
  return it * 9;
});
arr.push(9);
let result = ref.lazyEvaluate();
console.log(result);
```
**lazyFilter()**
```js
let arr = [1, 2, 3, 4, 5, 6];
let ref = arr.lazyFilter((it) => {
  return it % 2 === 0;
});
arr.push(9);
let result = ref.lazyEvaluate();
console.log(result);
```

**lazyReduce()**
```js
let arr = [1, 2, 3, 4, 5, 6];
let ref = arr.lazyReduce((it, acc) => {
  return (acc += it);
}, 0);
arr.push(9);
let result = ref.lazyEvaluate();
console.log(result);
```

Join me here: https://npmjs.com/package/lazy-hofs
Contributions welcome!
Building a Spring Boot CRUD API
Tags: java, spring, beginners, tutorial
Published: 2022-01-17 09:43:47

Code-along while we develop this API project in Java's Spring Boot. We will be building a classic CRUD API project with find, create, update, and delete endpoints. As a database we will work with a PostgreSQL which was seeded with some data from the Pokémon API.

{% youtube OjM_odXox2k %}
Why JSON is So Popular?
Tags: javascript, programming, tutorial
Published: 2022-01-17 09:42:41

Introduction: What is JSON?

JSON is a lightweight data interchange format that uses human-readable text to represent objects. JSON provides flexibility for developers and it’s interoperable with other languages.

More than 40% sites uses JSON and almost 95% API returns and receive data in some form of JSON.

If you are new to json follow [How to Make a JSON File?](https://codebeautify.org/blog/how-to-create-json-file/)

JSON was originally intended as a light-weight competitor of XML which was designed in the 1990s for large network systems such as Web applications, but JSON has become more popular due to its simplicity and efficiency.

Use [JSON Viewer](https://codebeautify.org/jsonviewer) to test and view JSON in tree mode.

![JSON Formatter and Beautifier](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yns45dveds1ozge7ossc.png)
 

**JSON vs. XML**

JSON is a relatively new data format. It is a text-based, human readable and language independent data-interchange format. XML has been around for longer and is more complicated than JSON. XML was designed to be human readable and it has a tree-like structure that can be parsed by software.

XML is more verbose than JSON because it needs to specify the type of data in each node whereas JSON just needs to specify the type of data at the top level.

XML uses angle brackets while JSON uses curly braces.

Use [XML Viewer] (https://codebeautify.org/xmlviewer) to test and preview XML in tree mode.


**Advantage of JSON**

- It serialize / store data in an array so creating and transferring get simpler. That’s why JSON is the most used for sharing data of any size even audio, video, etc.

- JSON's syntax is very easy to use and very small and light-weighted that’s the reason that it executes and response in a faster way.

- All browser support JSON compatibility with the operating systems. All Browser and Languages has JSON Parser available.
Fun Experiment: Bringing lazy execution to JS!
Tags: javascript, opensource, npm, webdev
Published: 2022-01-17 09:40:08

> Bringing lazy execution to higher order functions in JS!

**How to Use**

- Install the package
`npm i lazy-hofs`

- Add to your project
`require("lazy-hofs");`

**lazySome()**
```js
let arr = [1, 2, 3, 4, 5, 6];
let ref = arr.lazySome((it) => {
  return it === 9;
});
arr.push(9);
let result = ref.lazyEvaluate();
console.log(result);
```

**lazyMap()**
```js
let arr = [1, 2, 3, 4, 5, 6];
let ref = arr.lazyMap((it) => {
  return it * 9;
});
arr.push(9);
let result = ref.lazyEvaluate();
console.log(result);
```
**lazyFilter()**
```js
let arr = [1, 2, 3, 4, 5, 6];
let ref = arr.lazyFilter((it) => {
  return it % 2 === 0;
});
arr.push(9);
let result = ref.lazyEvaluate();
console.log(result);
```

**lazyReduce()**
```js
let arr = [1, 2, 3, 4, 5, 6];
let ref = arr.lazyReduce((it, acc) => {
  return (acc += it);
}, 0);
arr.push(9);
let result = ref.lazyEvaluate();
console.log(result);
```

Join me here: https://npmjs.com/package/lazy-hofs
Contributions welcome!
Striver's SDE Sheet Journey - #15 Majority Element (>N/2 times)
Tags: programming, beginners, dsa, java
Published: 2022-01-17 09:34:46

> **<u>Problem Statement</u> :-**
_Given an array nums of size n, return the majority element._

_The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element always exists in the array._

> Example


**Input** :  `nums = [2,2,1,1,1,2,2]`

**Result** : `2`


##  <u>Solution 1</u>
_using sorting,we can easily find the majority element in an array._
lets understand this approach step by step.

**step-1** sort the array `nums`.

**stpe-2** initialize three variables `max = 0`, `count = 1`, `majEle = 0` .

**step-3** run a loop from `i=1` to `n-1`.

 >> **1.** increase counting if the adjacent elements are the same..
if `nums[i] == nums[i+1]` then `count++` 

 >> **2.** if not `nums[i] == nums[i+1]`, start recounting for new majority element.

>> **3.** if `count > max` then re-assign new `max` & `majEle`

## Java

```java
class Solution {
    public int majorityElement(int[] nums) {
        
        if(nums.length == 1) return nums[0];
        Arrays.sort(nums);
        
        int max =0;
        int majEle = 0;
        
        int count = 1;
        
        for(int i=0; i< nums.length-1; i++){
            if(nums[i] == nums[i+1]){
                count++;
        
            }else{
                count = 1;
            }
            
             if(count > max) {
                    max = count ;
                    majEle = nums[i];
                }
        }
        
        return majEle;
        
    }
}
```
 
**Time Complexity** : _O(nlogn) + O(n)_
**Space Complexity** : _O(1)_

##  <u>Solution 2</u>
_by using [**Boyer–Moore majority vote algorithm**](https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_majority_vote_algorithm#:~:text=Boyer%E2%80%93Moore%20majority%20vote%20algorithm,-From%20Wikipedia%2C%20the), we can solve this problem in **O(n)** time complexity_

in this algorithm, we increase or decrease the count of the majority element, in the last, we will get our majority element.

**step-1** initialise two variables `majEle = nums[0]`, `count = 1`

**step-2** run a loop from `i=1` to `n`, then
  >> **1.** if we found the `majEle`, increase the `count` by `1`
  >> **2.** if not `majEle`, decrease the `count` by `1`
  >> **3.** if count become `0` then, re-initialse `majEle` & `count`

## Java

```java
class Solution {
    public int majorityElement(int[] nums) {
        
        int majEle = nums[0];
        int count = 1;
        
        for(int i=1; i<nums.length; i++){
            
            if(count == 0){
                majEle = nums[i];
                count++;
             
            }else if(nums[i] == majEle){
                count++;
            }else{
                count--;
            }
        }
        
        return majEle;
        
    }
}
```

---
Thank you for reading this article. save it for future use.
if you found something, let me in the comment section.
Electron JS Big Rival?
Tags: javascript, webdev, node, html
Published: 2022-01-17 09:34:15

I love electron, but there are many things I don't like about electron for example the performance, if you have a pc like mine with 4gigs of ram and a i3 processor you know how much it's a struggle sometimes when working with electron and startup times are sometimes very long.

I don't need to mention the fact that the final release build also weighs decent size like 80 or 90 mb easily.

I switched to Tauri a mature electron alternative but since I don't have any prior language to rust and stuff, I messed up everything.

Now I switched to Neutralino JS, and I love it!

Unlike electron which bundles chromium, Neutralino JS uses operating system's inbuilt browser library. For example webkit2 in Linux

And performance? Man it's almost identical to a native desktop applications.

A big downside of Neutralino is that you don't use node js with it.

But Neutralino provides much better options for interacting with the OS.

Functions like writeFile and readFile make life so easier for interacting with storage.

And since local storage doesn't work in Neutralino you can still use the local storage api provided by Neutralino to store key pair values.

Currently Neutralino js is just like a child, and in the coming few years this will be a for sure competitor of electron and Tauri.

Overall Neutralino is a must try option, it won't let you down trust me!

Resources:
[Neutralino JS vs Electron vs Tauri vs NW.js vs NodeGui vs Flutter vs .net MAUI](https://github.com/Elanis/web-to-desktop-framework-comparison)
[Neutralino JS Website](https://neutralino.js.org/)
[Neutralino JS GitHub](https://github.com/neutralinojs/neutralinojs)
Day 9 of 100 - Java: About JDK
Published: 2022-01-17 09:28:13

### Basics

JDK - Java Development Kit contains, 

JRE - Java runtime environment contains code behind all the variable types and built-in functions (eg. println, Scanner). It also include a Java Virtual Machine (JVM), which allows Java code to run on any platform!

Javac - Java Compiler

Program code -> Compiler -> Translated code
Java code -> `javac` -> Bytecode -> JVM -> Machine code

---
I feel like like reading/doing something else today.

Links
https://www.oracle.com/java/technologies/downloads/#jdk17-windows
Zooming and Panning in the Blazor Maps Control
Tags: blazor, webdev, csharp, dotnet
Published: 2022-01-17 09:15:58

Learn how easily you can add zoom and pan effects to Syncfusion [Blazor Maps](https://www.syncfusion.com/blazor-components/blazor-map). In this video, you will learn how to make the Blazor Maps control more interactive by adding zooming and panning features. I’ll show you how to zoom a specific chart area using different zooming modes. You will also see how to customize and change the position of the zooming toolbar and disable the panning option. 

Explore our tutorial videos: https://www.syncfusion.com/tutorial-videos

Download this example from GitHub: https://github.com/SyncfusionExamples... 

{% youtube 82tIMSbj_l0 %}
Magento 2 Rich Snippets
Tags: maagento2richsnippets
Published: 2022-01-17 06:29:13

**[Magento 2 Rich Snippets](https://www.fmeextensions.com/google-rich-snippets-structured-date-extension-magento-2.html)**
Help your website stand out on organic SEO results. Google is actually helpful when it comes to advising you on how to optimize your web pages for search. As you probably know, Google has a structured data testing tool. Once your site's content is published, you can test its visibility in Google search using this tool. 
 
 We offer the unique feature that allows your website's structured data to be indexed and Google's crawlers better understand the meaning of your site's content. Rich snippets are structured data tags used by search engines to show up in search results.Our module will help you  implement this structured data markup. 
 
 By using markup you can: 
 
 Increase your store's visibility 
 Promote  website content 
 Attract potential customers through higher CTR 
 Benefit from lower bounce rates 
 Help users get Get a Better Idea of ​​Your Site's Content 
 Improve Website Credibility
What does the future hold for 2022?
Tags: discuss, trends, learning
Published: 2022-01-17 08:59:20

---
title: What does the future hold for 2022?
published: true
description: 
tags: discuss, trends, learning
//cover_image: https://direct_url_to_image.jpg
---
In our latest [Developer Nation Survey](https://www.developereconomics.net/?utm_medium=discuss&utm_source=dev_to&utm_campaign=future) you can see what you are missing from programming languages, stack and trends and if there is something you need to learn in 2022. Take part until January 31st.