teleren/devto huggingface dataset:
returning function and arguments !!!JS
Tags: javascript, beginners, webdev
Published: 2022-03-07 09:26:55

So I'm currently practicing Js. Even though I cleared the basic concepts of Js It might be confusing when we implement into actual programming. I'll show the example below and then describe what I leaned from it. It might be not intimidating but It confuses beginners. 

```
In this example we need to calculate time to prepare lasagna. We have a cook book with some instructions which we need to follow.

The problem is consist of two variables and three functions.

Now lets see the code

Note that the parameters in minutes

const timeTakenPerLayer = 2;
const totalTimeToCook = 40

function RemainingTime(actualTimeInOven)
{
return totalTimeToCook - actualTimeInOven; //supose 40 - 20 = 20
}

function TimeTakenPerLayer(numberOfLayers)
{
return numberOfLayers * timeTakenPerLayer; //suppose 2*2 = 4
}

function TotalTime(numberOfLayers, actualTimeInOven)
{
return TimeTakenPerLayer(numberOfLayers) + actualTImeInOven;
}


*Suppose number of layers = 1, actualTimeInOven = 5
So expected outcome must be //7

```

`What I learned` -> What I learned from this example is that we can return a functions as well as an argument of a function. It will not give any error. Also we need to deeply analyze the problem and instead of connecting the problem to actual scenario we must also see it as mathematical problem. 

Like for lasagna layers we can easily calculate minutes by calculating it to a constant like 2,4,5,7,8. But instead of this suppose it as n number of layers. That will help you to solve the program for infinite solution and more logically and also how  you can store that value to variable for further use. 

Let me know your views, suggestions or corrections in comments.
Breakfast
Published: 2022-03-07 14:00:45

---
title: Breakfast
published: true
date: 2022-03-07 09:25:25 UTC
tags: 
canonical_url: https://dataroots.io/research/contributions/breakfast-2
---

![](https://dataroots.ghost.io/content/images/2022/03/breakfast_small-2.jpg)

Dataroots research taps mainly in two of the dataroots values, i.e. Revolutionary and Open.

_Revolutionary_ because it’s all about trying out interesting ideas, daring to fail and discovering new insights. This helps grow our expertise and helps our clients by offering them cutting-edge solutions using the latest innovations. _Open_ because this process of trying out new things should not be limited to ourselves. It has most value when shared. Shared not only within dataroots, shared also with the global AI community.

Building a strong community serves everyone being part of that community. At dataroots we want to make AI accessible to everybody and  in this spirit, we have decided to launch a new initiative to strengthen the Belgian Data Science community.

Get ready for Breakfast with Dataroots Research. We will provide breakfast where you will get the opportunity to connect with people sharing your passion for data. We believe that every person knows something that you don’t know and this is the chance to find out what that exactly might be. We’d like to welcome you to share your ideas and listen to the interesting insights others have to share.

One thing for sure, you’ll leave this breakfast with enough energy to start your day and new ideas to tell your friends and colleagues about and maybe even implement yourself.

This way, we hope to spread our shared passion for data science as wide as possible.

### Practicalities

**What:** networking breakfast  
**Where:** [SO - the best of both worlds](https://goo.gl/maps/DM56CusHcBiUjfpS6)  
**Who:** everybody with an interest in AI  
**Why:** to connect and share ideas  
**When:** Monday March 14th 2022, 7AM - 10AM, come when you want  
**How:** register through [this link](https://www.eventbrite.com/e/breakfast-tickets-276659013557)
[Azure Trial Hackathon Submission Post Placeholder Title]
Tags: azuretrialhack
Published: 2022-03-07 09:19:36

[Instructions]: # (To submit to the Microsoft Azure Trial Hackathon on DEV, please fill out all sections.)


### Overview of My Submission
[Note]: # (Please make sure the project links to the appropriate GitHub repository, and includes the [Apache-2 permissive license](https://www.apache.org/licenses/LICENSE-2.0)  and README.)


### Submission Category: 

[Note]: # (AI Aces, Computing Captains, Low-Code Legends, Java Jackpot, or Wacky Wildcards:)


### Link to Code on GitHub

[Note]: # (Our markdown editor supports pretty embeds. Try this syntax: `{% github link_to_your_repo %}` to share a GitHub repository)
[Note]: # (Your repository must include a README)
[Note]: # (You must use and list a permissive license for your code: MIT, Apache-2)


### Additional Resources / Info

[Note:] # Screenshots/demo videos are encouraged!

[Note]: # (Be sure to include the DEV usernames of your collaborators, if any. Prizes for winning projects with multiple collaborators will be sent to the person who posts this submission and they will distribute the prize evenly. DEV will not split prizes as per our rules)

[Reminder]: # (Submissions are due on March 8, 2022 @ 11:59 PM UTC)
What are the Major Reasons for Failures of Mobile App?
Tags: mobile
Published: 2022-03-07 09:18:16

It’s okay to fail if you learn something from it. Some failures are unavoidable, and few can be avoided if learned from other mistakes. The application market is one such market where chances of failure are high. To prove the failure point, we got the stats that say less than 00.01% of 10,000 mobile apps are said to be financially successful. So, you can imagine the number of applications that are facing failures every single day.

Can you do anything about it? Yes, of course, to avoid failure of your application, you can learn from these common yet evitable mistakes. These tiny loopholes in **[mobile app development](https://www.multipz.com/mobile-app-development)** often lead to a road of failures. So, let’s understand these mistakes and work on them to place your application in that 0.01% success count.

Excited about it? Great…

## Top reasons for the failure of mobile application:

### 1. Lack of research

One of the common reasons that lead to the failure of the mobile application is the lack of research. There are plenty of areas in app development where depth research is required, and a lack of research in these areas leads to the failure of the app. While developing an app, mobile app developers should think about the following questions:

* Will this app be able to solve customer’s problems?
* Who are my real competitors?
* How relevant is my app for a problem?
* Is there any similar app available in the market?

Honest answers to these questions will give clarity on whether your app will become an example of success or failure.

### 2. Lack of originality

One of the sad realities of the application world is its lack of originality as there are hundreds of identical apps on the app store. Building a similar app won’t be of any use, as it only increases the baggage of plagiarism. An ideal app should be able to highlight features with loud bangs and should be able to set how it differs from others.

### 3. No platform surety

Are you sure about the platform for your app? If not, you should know that it is the next reason for the failure of the application. You cannot choose a specific platform just because it suits your predisposition. Mobile platform selection must be on the preference of your target audience. It becomes very vital to study your platform for the success of the application. Now, most of the companies prefer both iOS and Android platforms to cater to the needs of the target audience.

Source Code: [https://multipztechnology.medium.com/what-are-the-major-reasons-for-failures-of-mobile-app-4b73cab48d8e](https://multipztechnology.medium.com/what-are-the-major-reasons-for-failures-of-mobile-app-4b73cab48d8e)
How to make wordpress sidebar widgets sticky?
Tags: wordpress, webdev, beginners, wp
Published: 2022-03-07 09:17:04

Here we will try to make wordpress sidebar widgets sticky.

For our wordpress website we have many types of sidebar like right sidebar, left sidebar, top sidebar or bottom sidebar. In these sidebars we can add as many widgets like Recent Posts Widget, Archives Widget, Search Widget, Custom HTML Widget, Gallery Widget etc.

Sometimes, we needs to make our sidebar widgets sticky like sticky google ads, sticky recent posts etc. So, we can do this with the help of WordPress Plugin Q2W3 Fixed Widget for WordPress.

## Uses of Q2W3 Fixed Widget For WordPress

- In sticky recent posts or popular posts
- In making fixed, sticky or floating google ads
- For fixed subscription forms in wordpress sidebar
- To make fixed search widget in wordpress
- To show any statistics in sidebar at fixed position
- Just download and [install this plugin](https://wordpress.org/plugins/q2w3-fixed-widget/). Use in your sidebar for any widgets.

Sticky Widget Plugin allows you to make your any widget sticky. After installing this plugin Go to Appearance ->Fixed Widget Options and save your desired options. If you do not want to make your sidebar widgets sticky for mobile or smaller devices. Then Inside Disable Width field enter the value 912 which will disable the sticky feature for devices less than 912px.

{%embed https://www.youtube.com/watch?v=vi8KwkMZDfo %}

Please like share and give positive feedback to motivate me to write more.

For more tutorials [visit my website.](https://www.w3courses.org/tutorials/)

Thanks:)
Happy Coding:)
Take full-size or area screenshots from your browser without additional tools
Tags: a11y, tooling, webdev
Published: 2022-03-07 09:03:20

So small, so useful. Did you know that you don’t need additional software to take full-size or area screenshots while browsing the web? It’s enough to:

1. Open the Chrome Browser
2. Go to page where you want to take a screenshot
3. Open the Chrome DevTools Panel (ctrl + shift + I on Linux/Windows or cmd + shift + I on Mac)
4. Click ctrl + shift + p on Linux/Windows or cmd + shift + p on Mac
5. Start typing screenshot
6. Choose which type of screenshot you want to take (normal, node, full-size, area)
7. Select the area if needed
8. The picture will be saved the same way as any other file downloaded from the Internet

![Webpage with open Chrome DevTools. In the tools' menu there is screenshot option selected](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3to7udxktfmdvselv9ah.png)
 

It’s all! I know it’s small but to be honest I love that simple option to take screenshots of the full page — not only the visible part but everything without scrolling or additional tools. Have fun!
Data Science & Algorithms: Merge Sort
Tags: javascript, python, datascience, algorithms
Published: 2022-03-07 08:41:34

Welcome To Part 2 Of My Introduction To Data Science & Algorithms Blog! In today's post, we will go through the "Merge Sort" Algorithm. And just like last time, I'll give you a code example in Python and JavaScript.

So, how does Merge Sort work?
Well, Merge Sort is considered a divide and conquer algorithm( learn about divide and conquer [here](https://en.wikipedia.org/wiki/Divide-and-conquer_algorithm#:~:text=A%20divide%2Dand%2Dconquer%20algorithm,solution%20to%20the%20original%20problem.)).
The way that it works is by diving the array into 2 equal( in terms of length) mini arrays, doing this again until each array is sorted then merges them.

To better understand this here is a photo from google:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gf3qdiea7e5284og2417.png)

Now that you understand the logic behing Merge Sort, let's look at code examples:

Here is Merge Sort in Python code:

```python
def mergeSort(arr):
    if len(arr) > 1:
        n = len(arr)//2
        l = arr[:n] # get the left half of the array
        r = arr[n:] # get the right half of the array

        # Sort the two mini arrays
        mergeSort(l)
        mergeSort(r)

        i = j = k = 0

        # I can't really explain this I'm sorry
        while i < len(l) and j < len(r):
            if l[i] < r[j]:
                arr[k] = l[i]
                i += 1
            else:
                arr[k] = r[j]
                j += 1
                
            k += 1

        # insert the remaining elements in arr
        while i < len(l):
            arr[k] = l[i]
            i += 1
            k += 1

        while j < len(r):
            arr[k] = r[j]
            j += 1
            k += 1


arr = [-6, 5, 0, 69, 42, 1]

mergeSort(arr)

print(arr)

"""
Output:
[-6, 0, 1, 5, 42, 69]
"""
```

And here is the JavaScript example:

```javascript
function merge(left, right) {
  let sortedArr = []; // the sorted elements will go here

  while (left.length && right.length) {
    // insert the smallest element to the sortedArr
    if (left[0] < right[0]) {
      sortedArr.push(left.shift());
    } else {
      sortedArr.push(right.shift());
    }
  }

  // use spread operator and create a new array, combining the three arrays
  return [...sortedArr, ...left, ...right];
}

function mergeSort(arr) {
  const half = arr.length / 2;

  // the base case is array length <=1
  if (arr.length <= 1) {
    return arr;
  }

  const left = arr.splice(0, half); // the first half of the array
  const right = arr;
  return merge(mergeSort(left), mergeSort(right));
}

var arr = [-6, 5, 0, 69, 42, 1];
arr = mergeSort(arr);
console.log(arr)

/*
Output:
[-6, 0, 1, 5, 42, 69]
*/
```
Code by [sebhastian.com](https://sebhastian.com/merge-sort-javascript/#:~:text=To%20implement%20merge%20sort%20using%20JavaScript%2C%20you%20need%20to%20first,starting%20from%20the%20smallest%20element.&text=With%20that%2C%20you%20have%20the,for%20the%20merge%20sort%20ready.)

That was all for today’s blog! Hope you enjoyed it😁 and don’t forget to ❤️!
5 Podcast I'll start listening as a Web Developer
Tags: podcast, webdev, beginners, productivity
Published: 2022-03-07 08:25:37

Am I the only developer who hasn't heard a single developer podcast episode yet? It feels like I'm living in a cave after finishing the first episode of **The Bootstrapped Founder**. I knew that Podcasts exists. But, I haven't really been active in listening to one. 

So, I'm going to share 5 podcasts that I'm gonna start listening from now on. There are a lot of podcasts out there but I feel that these are the podcasts that caught my attention and is relevant to me at the moment.

## 1. [The Bootstrapped Founder](https://bootstrapped-founder.transistor.fm/)

The Bootstrapped Founder Podcast is a weekly show about starting and bootstrapping businesses, how to build an audience, and how to build in public. 


## 2. [developer tea](https://developertea.com/)

This is a podcast about helping engineers find clarity, perspective, and purpose in regular short bursts of high-value content. 

## 3. [Soft Skills Engineering](https://softskills.audio/)

Soft Skills Engineering is a weekly advice podcast for software developers about the non-technical stuff that goes into being a great Software Developer.

## 4. [Front End Happy Hour](https://www.frontendhappyhour.com/)

A software engineering podcast featuring a panel of Software Engineers from Netflix, Twitch, & Atlassian talking over drinks about Frontend, JavaScript, and career development.

## 5. [The Hanselminutes podcast](https://hanselminutes.com/)

Hanselminutes - Fresh Air for Developers is a weekly talk show that brings interesting people together to talk about the web, culture, education, technology and more.
 

It's gonna be overwhelming to see the number of episodes you've missed and it you would most likely feel the need to catch up by listening to all of the past episodes, I also feel the same. But, for sure you don't have to go through everything, just choose the episodes that interests you and enjoy your podcast journey instead of treating it like a task.

What about you, do you have any podcast shows to suggest?
The Weekly Dev - 202210
Published: 2022-03-07 08:10:50

---
title: The Weekly Dev - 202210
published: true
description: 
tags: 
//cover_image: https://direct_url_to_image.jpg
canonical_url: 'https://kevwe.com/weekly/202210'
---
Contextual Artificial Intelligence is here, but it's still a long way to achieve General Artificial Stupidity.

In the wait, we need to fill in with some brand human one.

No machines harmed in the process:
https://kevwe.com/weekly/202210
This week in Flutter #44
Tags: flutter, dart, news
Published: 2022-03-07 07:59:57

I have been reading quite some articles about testing in Flutter lately. [Dhruv Nakum](https://twitter.com/dhruv_nakum) and [Guillaume Bernos](https://twitter.com/BeGuillaume) are writing about it in this issue.
Testing is an often **overlooked** part of programming: if only we tested more, many bugs would not even reach production.

I do not believe in **100% code coverage**: it gives you a false sense of security, and getting from 90% to 100% might not be the best way to allocate your time or budget.
Even so, I must say I do not spend as much time as I would want on designing and writing tests. I hope these readings will help me improve my testing skills.

I wonder when we will move from automating tests  to [automating the writing of those tests](https://en.wikipedia.org/wiki/Model-based_testing).

Do you reach 100% code coverage in all your Flutter projects?
Let me know in the [comment](https://ishouldgotosleep.com/news/this-week-in-flutter-44/#comments) section.

<small>- Michele Volpato</small>

## Development 🧑‍💻

### 🔗 [Flutter, add an undo feature](https://pierre-dev.hashnode.dev/flutter-add-an-undo-feature)

When I first read the title of this article, I thought it was about adding a `ctrl+z` feature to a Flutter app.
It is not. It's about giving the possibility to your users to stop an action they performed in your
app **before it's too late**. For instance, canceling a message they just sent. [Pierre Monier](https://hashnode.com/@Pierre-Monier) also gives you a solution for when the app gets killed while the message is in this cancelable limbo.

### 🔗 [Testing In Flutter](https://dhruvnakum.xyz/testing-in-flutter-unit-test)

[Dhruv Nakum](https://twitter.com/dhruv_nakum) published a series of articles on **testing in Flutter**. There is an article about [unit testing](https://dhruvnakum.xyz/testing-in-flutter-unit-test), one about [widget testing](https://dhruvnakum.xyz/testing-in-flutter-widget-test), and, finally, one
about [integration testing](https://dhruvnakum.xyz/testing-in-flutter-integration-test). They are
good getting-started articles if you are starting your testing journey just now.

[...]

Read [the rest](https://ishouldgotosleep.com/news/this-week-in-flutter-44/).

[Join the Flutter and Dart newsletter](https://ishouldgotosleep.com/subscribe-to-the-newsletter-devto/) and receive it weekly in your inbox.
Vue3 Composition API and New Features
Tags: vue, typescript, webdev, tutorial
Published: 2022-03-07 07:48:07

The combination of Vue3.0 and Typescript is getting more and more trending, let's check how to build single file components using them and understand how it works.

## Composition API
One of the most important changes in Vue3.0 is the `Composition API`,Vue3.0 is backwardly compatible with the `Options API`, but using the `Composition API` grants you more power for code sharing.

you can find a detailed cheatsheet about composition API [here](https://www.vuemastery.com/pdf/Vue-3-Cheat-Sheet.pdf)

Going through the cheetsheet we can have a basic understanding of composition API: 

1. replacing mixins
2. better code sharing across components 


The composition API gets rid of mixins, using a mixin in Vue2.0 would be like: 

```javascript
import Mixin from "./Mixin.js";
 
export default {
  mixins: [Mixin],
  data: () => ({
    data1: null
  }),
  methods: {
    method1 () { ... }
  }
}
```
back in 2016 Dan Abramov wrote an article called [`Mixins Considered Harmful`](https://reactjs.org/blog/2016/07/13/mixins-considered-harmful.html), the harm he mentioned was basically using mixin is an anti-pattern and would not recommend it. The same drawback applies to both React and Vue: 

* naming collisions
  * names used in mixins could confront with the one in the file that uses it
* implicit dependencies 
  * mixins can use methods or properties in the file too, which causes confusion, especially when refactoring code developer may omit details in mixins and causes confusion 

in composition API, rather than defining a component's functionality (state, methods, computed, etc.) as an object property, we define them as JS variables that get returned from a new `setup` function 

```javascript
// define reactive variable that functions pretty much the same as a data variable 
import {ref, computed } from "vue";

export default {
  setup(){
    const count = ref(0);
    const double = computed(() => count.value * 2)
    function increment(){
      count.value++;
    }
    return {
      count,
      double,
      increment
    }
}
```

while we can definitely extract the common logic to a single file 

```javascript 
// useCounter.js
import { ref, computed } from "vue";
 
export default function () {
  const count = ref(0);
  const double = computed(() => count.value * 2)
  function increment() {
    count.value++;
  }
  return {
    count,
    double,
    increment
  }
}
```

and the code can be reused in another component by importing it.


```javascript 
// MyComponent.js
import useCounter from "./useCounter.js";

export default {
  setup() {
    const { count, double, increment } = useCounter();
    return {
      count,
      double,
      increment
    }
  }
}
```

notice here we need to use states or methods from logic by importing them explicitly, thus solving the `naming collision` issue
Use graphql-express to deal with authorization
Tags: graphql, auth
Published: 2022-03-07 07:40:23

---
title: Use graphql-express to deal with authorization
published: true
description: 
tags: graphql,auth
series: graphql
cover_image: https://res.cloudinary.com/practicaldev/image/fetch/s--RlqwldxD--/c_imagga_scale,f_auto,fl_progressive,h_420,q_auto,w_1000/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ehd9wcdwrvrn9bu5g4z5.jpg
---

# Why

In [this post](https://dev.to/peterlitszo/deal-with-httponly-cookies-1i5a), I am using apollo client to send GraphQL request in the front-end.

It time to deal with those request and return a response in the back-end.

To do it, we choose express (a JavaScript web framework) as a server.

# What's the question?

Well. To deal with the GraphQL request, the best idea is using express-graphql. But it does not have the interface to set cookie to get the authorization.

```JavaScript
// init a express server
const GraphQLServer = express();

// deal with the GraphQL request with graphqlHTTP,
// which is from the express-graphql. 
GraphQLServer.use(
  "/graphql",
  graphqlHTTP({
    schema: GraphQLSchema,
    graphiql: GRAPHIQL,
  })
);

// Listen to port 4000.
GraphQLServer.listen(4000, () => {
  console.log("Listening on localhost:4000...");
});
```

Now we do not have idea.

# Solution

The solution is that send the `req` and `res` into the `graphqlHTTP`'s context:

```JavaScript
GraphQLServer.use(
  "/graphql",
  // The returned value of graphqlHTTP is also a function.
  // We just add a wrapper to set its context.
  (req, res) => {
    return graphqlHTTP({
      schema: GraphQLSchema,
      graphiql: GRAPHIQL,
      context: { req, res },
    })(req, res)
  })
);
```

Click for more information: https://stackoverflow.com/questions/46023367/graphql-issuing-jwt-cookie
Answer: SQLPLUS error:ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA
Published: 2022-03-07 07:33:56

{% stackoverflow 40137911 %}

我也遇到过同样的问题，connection identifier 需要用双引号引用起来，且为了让bash将双引号传递给sqlplus， 双引号之前需要加转义符号