teleren/devto huggingface dataset:
Currying in Javascript
Tags: javascript, beginners, webdev
Published: 2023-01-20 17:30:01

Currying in javascript is utilized to process a function with varying parameter list as shown below:

add(1)(3)
add(7)(29)(41)
add(0)(1)(2)(3)(5)

Adding two numbers can be achieved as shown in the following code snippet

_Snip a - Function to add 2 numbers_
```
let add2 = (a) => (b) => b ? add2(a + b) : a;
console.log(add2(1)(3)());
```
But this is not scalable when we have to add more than 2 numbers and becomes cumbersome to create a solution with increasing parameters.

_Snip b - Function to accept 4 arguments_
```
function sum(a) {
  return function (b) {
    return function (c) {
      return function (d) {
        return a + b + c + d;
      };
    };
  };
}

console.log(sum(1)(2)(3)(4));
```

Hence solution here is to come up with a generic way to curry this. As we observe in the above snip b, we return a function (function(b) from function(a)) which can accept a parameter ( the next parameter which is b). The cycle continues, until we have exhausted all the parameters in curried function call stack in the execution context and final value gets returned back to the caller as the function calls gets popped off the stack.

> function(a)(b)(c)....(n)

What we see above is similar to a recursive function call to exhaust (in a way to fetch) the parameters from a curried call 

**So to make this task generic we can build a function which can help us consolidate the parameters into an object(array)**

```
function testCurrying(func) {
  let firstArgument = null;
  let innerFunc = (...args) => {
    firstArgument = args[0];
    console.log(`Build Array : ${args}`);
    return (innerArg) => {
      if (!innerArg) return func(args);
      console.log(`innerArg = ${innerArg}`);
      return innerFunc(...args, innerArg);
    };
  };
  return innerFunc;
}

let testFunction = (x) => console.log("final array = ", x);
testCurrying(testFunction)(3)(4)(6)();

$ node function.js 
Build Array : 3
innerArg = 4
Build Array : 3,4
innerArg = 6
Build Array : 3,4,6
final array =  [ 3, 4, 6 ]
```

_As shown below, A curry requires_

- tadka : A function which either adds or multiplies or divides etc a given list of array

- tava : A inner function to consider varying list of parameters to either add or multiply or divide etc
 
- gravy : An argument list which needs to be built / accumulated into an array overtime with the items(values)

- item : Each parameter thats passed from the parameter list

_Snip c - Currying 'n' parameter list_
```
let curry = (tadka) => {
  const tava =
    (...gravy) =>
    (item) =>
      item ? tava(...gravy, item) : tadka(gravy);
  return tava;
};

let sum = (arr) => arr.reduce((acc, val) => acc + val, 0);
let curriedSum1 = curry(sum);
console.log(curriedSum1(1)(2)(3)(4)(6)(5)(100)());
```
List of Artificial Intelligence (AI) Tools for Personal Uses– 2023
Published: 2023-01-30 16:04:56

Artificial Intelligence (AI) Over the years, there has been a lot of progress and development when it comes to artificial intelligence. Most of this progress has been geared toward the growth of businesses and industries. However, several companies are working on artificial intelligence tools fit for personal use. Artificial intelligence is said to be the next.
Please follow link to read more.
[read more](https://amlogy.com/list-of-artificial-intelligence-ai-tools-for-personal-uses-2023/)
What are your goals for the week of January 30?
Tags: discuss, motivation, watercooler
Published: 2023-01-30 15:59:20

What are your goals for this week?
 
- What are you building? 
- What will be a good result by week's end?
- Are you attending any events this week?
- Did you meet your goals last week?

**Last Week's Goals**

- [:white_check_mark:] Update resume/linkedIN/portfolio.
- [:white_check_mark:] Job Search. Spending my mornings hitting LinkedIn and sending DMs. Applying to open roles.
- [:white_check_mark:]Start new project.
- [:X:]Blog.
- [:white_check_mark:] Attend [Jam.DEV](https://cfe.dev/events/the-jam-2023/) Jan 25 & 26.


### Still working on: 
- Update resume/linkedIn/portfolio.



**This Week's Goals**

- Update resume/portfolio.
- Continue Job Search.
- Continue new project.
- Blog.
- Prepare for Virtual Coffee's February Challenge, Getting job ready.

**This Month's Goals**
- Gain more followers here. I would like to have more followers on DEV than I had on the bird site. Need about 100 more here. My twitter followers increased but most were bots.
- Gain more followers on Mastodon. [@jarvisscript@hachyderm.io](https://hachyderm.io/@jarvisscript) 

You've read my goals so I'll throw that question back to you.

What are your goals for the week?

```
-$JarvisScript git push
```
🐧 🚀 Linux Voice Control Assistant
Tags: linux, assist, python, ai
Published: 2023-01-30 15:39:37

![preview](https://raw.githubusercontent.com/omegaui/linux-voice-control/main/images/preview.gif)

[**📹 See YouTube Video Preview**](https://www.youtube.com/watch?v=oTfOO_Gz1_s&feature=youtu.be)

## ![icon](https://img.icons8.com/color/48/null/metallic-paint.png) Features
- [x] [**ChatGPT Mode**](https://github.com/omegaui/linux-voice-control/issues/8) (just say **activate chat mode**)
- [x] GUI Mode (using Flutter)
- [x] Master Control Mode (yeah, it's your Jarvis Now)
- [x] Voice Feedback 
- [x] Desktop Notifications
- [x] Simplest Command Execution Logic (use your own words and map them to a command in **lvc-commands.json**)
- [x] Accurate Master Voice Matching using **[speechbrain](https://speechbrain.github.io/#)**
- [x] Automated Setup!
- [x] Customization
  - [x] Change Your Control System Name
  - [x] Voice Feedback Speech Control
  - [x] Voice Feedback Speed Control
  - [x] Total Execution Control through configuration
- [ ] **[Live Mode](https://github.com/omegaui/linux-voice-control/issues/3)** (under development, till then listens for every **x** seconds or for the hot words specified in **lvc-config.json**)
- [ ] **[Dynamic Mode](https://github.com/omegaui/linux-voice-control/issues/5)**

**Pro-Tip**: _Say '**See you later**' to it turn off._

**Pro-Tip**: _Say '**Activate master control mode**' to turn on master control mode without manual config._

**Pro-Tip**: _Say '**Deactivate master control mode**' to turn off master control mode without manual config._

**_Yes, these are the built-in actions!_**

[**Visit Repo**](https://github.com/omegaui/linux-voice-control)
🚀 Shared Preferences API for Java 🚀
Published: 2023-01-30 15:30:56

Hello, world!
This tiny API is worth taking a look.

## **<u>Features</u>**
- 📢 No Redundancy
- 😼 Easily Handles multiple references of same Storage
- 🤖 Real-Time Write i.e Automatically Saves file on changes
- 🎉 Auto constructs the entire path
- 🚀 Usable with Java CLI and any GUI framework

Example:
```java

public class Preferences {
    public static void save(){
        HashMap<String, Integer> map = new HashMap<>();
        map.put("Simon", 99);
        map.put("Alex", 96);
        map.put("Sofia", 89);

        DataStorage storage = DataStorage.getStorage(".config", "settings.json");
        storage.put("students", map); // Auto-Save

        System.out.println(storage.query("students", "Simon"));
        // Displays 99


        DataStorage storage2 = DataStorage.getStorage(".config", "settings.json");
        storage2.put("teachers", 18); // Auto-Save
        // storage2 is the same storage object with no object redundancy 😎

    }

    public static void main(String[] args) {
        save();
    }
}

```


[Visit Repo](https://github.com/omegaui/json-data-storage)
How do you motivate yourself to write when so few are reading it?
Tags: discuss, watercooler, meta
Published: 2023-01-30 14:50:40

---
title: How do you motivate yourself to write when so few are reading it?
published: true
description: How do you justify spending time on writing articles when at the end very few people read them?
tags: discussion, watercooler, meta
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2023-01-28 06:32 +0000
---

## No views

Scrolling through the [latest](https://dev.to/latest) articles one can see that most of the articles have no reactions and no comments. Even if we scroll down to articles posted 10-20 hours ago.

I bet I am not the only author here on DEV whose articles are barely read. Looking at my dashboard many of my articles don't even hit the magic 25 views to show a real number and even the ones that pass it are mostly under 100 views.  

Even worse a "view" doesn't even mean the visitor has read the article. The title might have been interesting, but the content might have made the person run away.

## No reactions

The fact that the total number of likes and bookmarks is often closer to 0 than to 1 just rubs it in. 

I often think it is not worth the time I put in the articles if so few people are interested in opening them and so few like them. Yet I constantly see 4-600 new articles on DEV every day.

## Newcomers and stars?

Is it the case the case that, beside a few successful authors who get lots of views and lots of reactions to their articles, most of the posts are by hopeful newcomers who post a few articles and then leave?

Is it the case that most of the people for most of their articles get almost no reactions, but once in a while they have one success? 

## Feeling disappointed?

I guess I am not the only one feeling these results to be disappointing. If you have been publishing on DEV for a while, how do **you** justify spending time on your articles? How do you **motivate** yourself?
Music Monday — What are you listening to? (60's Edition)
Tags: watercooler, discuss, music
Published: 2023-01-30 14:50:19

_cover image source: [giphy](https://giphy.com/gifs/rainbow-the-beatles-yellow-submarine-FsFyS8K0mETiE)_

**We've been time traveling through the decades for the past couple of weeks and are sticking with the theme again this week... This time we're headed to the swingin' 60's. Motown, the British Invasion, bossa nova, surf rock, psychedelic rock, folk... the genres of the 60's spread far(out) and wide. Whether you're inspired by the unhinged, acid-laced sounds of Hendrix's electric blues or are more drawn to the radio-friendly, straight-laced bubblegum pop of the era, I'd like to hear what ya are into.** 🙌

![Picture of Aretha Franklin with a speech bubble... the words "All I'm askin' is for a little" fill into the bubble one by one and the word "Respect" is written in all caps and flashing different colors at the bottom.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bf4rx6nyqovkow688exg.gif)

***

## How we do 

In this weekly series, folks can chime in and drop links to whatever it is they've been listening to recently + browse others suggestions.

If you like talking about music, consider following the org [#music discussions](https://dev.to/music-discussions) for more conversations about music!

{% embed https://dev.to/music-discussions %}

***

Hop in that time machine and let's head back to the sixties. _Note: you can embed a link to your song using the following syntax `{% embed https://... %}`. This should work for most common platforms!_

Really looking forward to listening to y'all's suggestions! 🎶
Implement Stack widget Flutter in React Native
Tags: reactnative, mobile, typescript, stack
Published: 2023-01-30 14:39:06

## What is Stack widget?
The Stack widget is a component in Flutter that allows you to position its children relative to the edges of the widget's box. This is a handy tool when building user interfaces. Unfortunately, React Native doesn't have a component like this, but you can still achieve a similar result.

## How to use Stack widget?
To use the Stack widget in Flutter, simply provide a list of widgets as children to the Stack component, like this:
```
Stack(
  children: <Widget>[
    Container(
      width: 100,
      height: 100,
      color: Colors.red,
    ),
    Container(
      width: 90,
      height: 90,
      color: Colors.green,
    ),
    Container(
      width: 80,
      height: 80,
      color: Colors.blue,
    ),
  ],
)
```
This will produce a stack of containers with different colors, as demonstrated in the accompanying image.
![in flutter](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4csd1zuknvvlkz046yg2.png)

## How to implement Stack widget in ReactNative?
If you need to achieve a similar effect in React Native, you can use the cloneElement API to modify the children of a component and add the necessary styles to each child. Here's an example of how to do it:
```
<Box {...props}>
  {React.Children.map(children, (child, index) => {
    return React.cloneElement(child as 
      React.ReactElement<any>, {
         position: 'absolute',
         zIndex: length - index,
    })
  })}
</Box>
```
This code creates a custom component called Box that uses the cloneElement API to add the position and zIndex styles to each child. The result is a stack of components with the desired behavior.

![Code exam](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ednb6janw82b6ed9ruvz.png)

![Result code exam](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lqkm6spriyla7cf0afg1.png)

The post provides code examples and images to illustrate how to use the Stack widget in Flutter and how to create a similar component in React Native. The source code for the example is available on Github for you to check out.

Overall, the post provides clear and concise instructions for using the Stack widget and creating a similar component in React Native.

Happy coding!
You can check source code at [Github](https://github.com/bonnguyenitc/react-native-starter)
The Role of Big Data in Market Research Surveys - SurveyDuniya
Published: 2023-01-30 11:34:30

Big data has revolutionized the way businesses approach market research. The vast amount of data available today allows companies to gain insights into consumer behaviour and preferences that were previously unimaginable. Market research surveys are one of the most popular ways to collect data, and big data is playing an increasingly important role in this process.

Big data refers to the vast amount of data that is generated every day by businesses and consumers. This data is generated from a variety of sources, such as social media, online transactions, and mobile devices. Big data can be analyzed to identify patterns and trends that can provide valuable insights into consumer behaviour and preferences.

One of the key benefits of big data in market research surveys is the ability to reach a larger number of participants. Surveys can now be distributed to a wider audience, including people who may not have been reached through traditional methods. This allows for a more representative sample and a more accurate portrayal of consumer behaviour and preferences.

Big data also allows for more targeted surveys. Businesses can use data from various sources to identify specific demographics, such as age, gender, location, or income level. This allows for more accurate data to be collected and for more relevant insights to be gained.

Big data can also provide more detailed insights into consumer behaviour and preferences. For example, analyzing social media data can provide insights into the types of products or services that consumers are interested in, as well as their opinions and feedback.

Surveyduniya.com https://surveyduniya.com/ helps businesses take advantage of big data in market research surveys by providing an easy-to-use survey platform that integrates with big data sources. SurveyDuniya allows businesses to create targeted surveys and reach a large number of participants in a short period. Additionally, our platform includes built-in tools for analyzing data, including big data. Our website helps businesses to identify patterns and trends in the data and make informed decisions based on the results.

In conclusion, big data is playing an increasingly important role in market research surveys. It allows businesses to reach a larger number of participants, targets specific demographics, and gain more detailed insights into consumer behaviour and preferences. Surveyduniya.com https://surveyduniya.com/ provides businesses with an easy-to-use survey platform that integrates with big data sources, helping them to take advantage of the benefits of big data in market research.
Cap XVII: Esclavo de tu propia solución o cómo querer ser imprescindible, El libro negro del programador. 💻
Tags: programming, books, spanish, productivity
Published: 2023-01-30 14:35:31

## **Esclavo de tu propia solución o cómo querer ser imprescindible**

* Como programadores nos gusta apoderarnos de nuestro código o nuestra solución.

* Existen algunos compañeros de trabajo que se niegan a enseñarnos como funciona algo que ellos hicieron y prefieren mantenerlo como una caja negra.

* Cuando eres tan bueno en algo, te vuelves prisionero de tu ego y esto impide cualquier crecimiento laboral.

* Cuando te especializas en algo muy específico y solo te dedicas a ello, corres el riesgo de parar de aprender o ponerte al día con las nuevas tecnologías.

* Atarse a una sola tecnología es lo mismo que hacerse cautivo de ella, esto se traduce en insatisfacción laboral y estrés añadido.

* Nunca lo olvides: **NADIE ES IMPRESCINDIBLE EN UNA EMPRESA**.

* Si crees que dominando un área de tu empresa eres imprescindible cometes un grave error.

* Un desarrollador no puede buscar en ningún momento la «zona de confort», con el tiempo el software y las herramientas se vuelven obsoletas.

* Se recomienda que un programador participe en varios proyectos a lo largo del tiempo, nada peor que mantener el mismo software por tiempo prolongado.

* No podemos ignorar las nuevas tecnologías que van saliendo, si lo hacemos tendremos alas muy cortas en la industria.

* Quizá pienses que buscar un estado de seguridad puede reducir la ansiedad y el estres a enfrentarnos a cosas nuevas, pero una cosa está clara: todo lo que hacemos ya viene con una obsolescencia programada.

* La falta de adaptabilidad al cambio hace que perdamos muchas oportunidades.

* La seguridad no es un hecho, no existe un lugar «seguro» en desarrollo de software, solo es una sensación de tenerla.

* Un profesional se trata así mismo como una empresa, buscando el mejor proyecto para su desarrollo. 

* Hoy en día las empresas solo contratan al mínimo personal necesario para cumplir con sus objetivos, no pinta aferrarse a una tecnología.

* Realizar las mismas tareas por mucho tiempo es antinatural para un programador.

* Comenzamos con un proyecto sabiendo a priori que en algún momento lo dejaremos.

---

Te dejo el link gratuito de [*El libro negro de programador*](https://underpost.net/ir/pdf/cy3/el-libro-negro-del-programador.pdf) por si te intesa leerlo, o dale click a la imagen:


[![libro](https://www.digitalskillsinstitute.com/assets/media/books/5541eba31b4b42b5bb021dc77c70d658-480.jpg)](https://underpost.net/ir/pdf/cy3/el-libro-negro-del-programador.pdf)
Unlock the Power of ChatGPT: Learn to Code Effortlessly
Published: 2023-01-31 06:36:06

---
title: Unlock the Power of ChatGPT: Learn to Code Effortlessly
published: true
date: 2023-01-30 14:30:39 UTC
tags: 
canonical_url: https://adithyana.hashnode.dev/unlock-the-power-of-chatgpt-learn-to-code-effortlessly
---

## Introduction

Coding is an essential skill in today's digital world. It is the backbone of the technology industry and is used to create everything from websites and apps to software and games. However, learning to code can be a challenging task, especially for beginners. With so many programming languages and concepts to master, it can be difficult to know where to start. In this blog, we will explore how ChatGPT, a large language model developed by OpenAI, can be used to learn code more effectively.

## How Can We Use ChatGPT to Learn Code

ChatGPT, a large language model developed by OpenAI, can be used to learn code in a number of ways. Here are a few examples:

1. Code Completion: ChatGPT can be used to generate code snippets based on a given prompt. This can be especially useful for beginners who are still learning the syntax of a particular programming language. By providing a partial code and asking ChatGPT to complete it, the model can help users understand the correct syntax and structure of the code.

2. Code Explanation: ChatGPT can also be used to provide explanations for specific lines of code. By inputting a line of code and asking ChatGPT to explain it, the model can provide a clear and concise explanation of what the code does, which can be helpful for understanding more complex code.

3. Code Troubleshooting: ChatGPT can be used to help troubleshoot coding issues. By inputting an error message and the code that is causing the issue, ChatGPT can suggest possible solutions to the problem.

4. Code Generation: ChatGPT can generate code based on the requirement or the input, it can be beneficial for the developers who are working on the project and they are stuck at some point, they can input the requirement to the model and it will generate the code for the same.

5. Coding Challenges: ChatGPT can be used to create coding challenges for users. The model can be trained on a particular programming language or task, and then used to generate coding challenges that users can complete to test their understanding of the language or task.

In conclusion, ChatGPT can be a valuable tool for anyone looking to learn code. Whether you're a beginner just starting out or an experienced developer looking to improve your skills, ChatGPT can help you understand and write code more effectively.
Resolvendo problemas no HackerRank: Invertendo uma Lista e inserindo entre Maior e menor
Published: 2023-01-30 14:30:04

Com foco em melhorar ainda mais o rendimento e aprendizado em uma linguagem, também exercendo a lógica da programação, nessa nova série de resoluções irei demonstrar como resolvi certos conflitos de lógica: alguns simples, outros que necessitam de mais esforço.


**Arrays - DS**

Nesse primeiro exercício nos é passado uma listagem com parâmetros. Nosso objetivo nesse caso é inverter a lista, utilizando `return` para mostrar os arrays na ordem contrária. Veja mais a seguir ->

```
/* Padrão:
4 parâmetros
1 4 3 2


O que ele quer:2 3 4 1*/
```

É possível resolver esse desafio de muitas formas. A forma que fiz foi a seguinte:


```
function reverseArray(a) {
    // Write your code here
    let reverse = [];
    for (let i = a.length -1; i >= 0; i--){
      reverso.push(a[i]);
    }
    return reverse
}
```
Esse código define uma função chamada "reverseArray" que recebe um array "a" como entrada. A função cria um novo array "reverse" e preenche-o com os elementos de "a" na ordem inversa, começando do último elemento e terminando no primeiro. Finalmente, a função retorna o array "reverse".



**Mini-Max-Sum**

No caso abaixo nós temos um parâmetro que pede para inserirmos a soma máxima e soma mínima:


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



Resolvi da seguinte maneira:

```
function miniMaxSum(arr) {
    // Write your code here
  const totalArrSum = arr.reduce((acc, cur) => acc + cur);
  
  let miniSum = totalArrSum - Math.max(...arr);
  let maxSum = totalArrSum - Math.min(...arr);

  console.log(miniSum,maxSum);
}
```

Criamos uma const que vai fazer um reduce que soma o valor atual com o que foi guardado. Fazendo isso, criamos uma variável dos valores mínimos(sem o maior valor da lista) que pega o const reduce com todos os valores somados, menos o valor máximo alcançado(Math.max(...arr)) que seria 9.

No caso do maior valor seria o mesmo procedimento mas retirando do parâmetro o valor 1. Por fim , ele nos pede para printar o valor, por essa razão usamos `console.log(miniSum,MaxSum);`

Com isso, finalizamos os problemas no HackerRank de hoje. Até a próxima!