teleren/devto huggingface dataset:
Change Terminal Keys to VIM
Tags: vim, productivity, terminal, programming
Published: 2020-01-22 21:36:47

---
title: Change Terminal Keys to VIM
published: true
description: Set terminal keys to use VIM
tags: Vim,Productivity,Terminal,Programming
---

So I have been struggling with my terminal lately, having done a lot of tweaks to improve my productivity, like using Tmux as a multiplexer, setting an alias for reoccurring commands and the likes.

I find it hard to use my terminal because to edit a command, you have to scroll with your arrow keys or press some weird key bindings. It has been frustrating so far.

I thought of using vim keys but don't know if it exists, just a little search online and I saw the command I needed.

```
$ set -o vi

```

This will set your terminal to use Vim key bindings, the default mode is insert mode so you can type anything you want. To go to command mode, just click `escape key` and you are good.

Important VIM keys I use while in command mode
- 0 or ^   - to move to the first character
- $   - to move to the last character
- f and a letter   - search for a letter through the current line
- F and a letter   - search for a letter backwards


This setting will not persist, it will only be available for the life cycle of the terminal. To persists it, you have to add `set -o vi` to your `.bashrc` or `.zshrc` or other profiles.

```
$ vim ~/.bashrc
```

After that, close your terminal and open it. Enjoy your super cool terminal.
My Understanding of Event loop in Nodejs
Tags: node
Published: 2020-01-22 08:54:55

The understanding of event loop in Nodejs will first have to start with Knowing about the Threads, The thread can be seen as the a unit of operations the CPU has to do for us. One single program process can contain many Threads. 

Using the below image to get an idea about the threads.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/k3vywv7dr7qp07cs6gwd.png)

## The Event Loop

When you run a node program, automatically the thread is created, That thread is the place where the codebase is going to be executed, In that thread, the **Event loop** is generated, The role of this loop is to schedule which operations our only thread should be performing at any given point in time.


Note This: the event loop does not get generated instantly as soon as we run our program. It only runs once the whole program has been executed

**Let me explain in details**

I will just have to assume that I have a program file to run in Nodejs 'programFile.js'.

We can run 'node programFile.js'.

The This is, in order to understand what is being done by the event loop, the picture below is showing how things are going during the event loop tick.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/vim1rsq3k1wt4g5hmkhf.png)

    

## Step1: PerformChecks

has a specific condition that will determine if the loop needs to iterate again or not. Every iteration of the event loop is called a tick.

### Conditions for Event loop to do a tick.

we execute our program, we will have a series of operations that need to be performed. These operations can be split into three main types:

- Pending timer operations (setTimeout(), setInterval(), setImmediate())
- Pending operating system tasks
- Pending execution of long running operations

So, whenever one of those are pending the event loop will perform a new tick!

### Step 2: Performing a tick
For every loop iteration, we can distinguish the following phases:

**Phase 1:** Node looks at its inner collection of pending timers and checks which callback functions passed to setTimeout() and setInterval() are ready to be called in case of an expired timer.

**Phase 2:** Node looks at its inner collection of pending OS tasks and checks which callback functions are ready to be called. An example of this could be the completed retrieval of a file from our machine’s hard drive.

**Phase 3:** Node pauses its execution waiting for new events to occur. With new events, we include: a new timer completion, a new OS task completion, a new pending operation completion.

**Phase 4:** Node checks if any function related to pending timers related to the setImmediate() function are ready to be called.

**Phase 5:** Manage close events, used to clean the state of our application. 



                                    --End--
Potential Fields to be empowered with Technology
Tags: development, sdg, technology
Published: 2020-01-22 21:15:08

## Development Fields


1. Workforce Development
   Making decent work and quality education accessible and affordable for people with barriers to employment.

2. Financial Inclusion
   Reducing poverty through financial products, services, and platforms that build and protect wealth.

3. Health
   Improving access to and experience of care, and incorporating social determinants of health into a holistic definition of well-being.

4. Food & Agriculture
   Improving livelihoods of smallholder farmers, combating food insecurity, and increasing health and nutrition.

5. Energy
   Accelerating access to clean, affordable, reliable ener
Is knowing how to use Docker a prerequisite to becoming a Senior Software Developer?
Tags: discuss
Published: 2020-01-22 21:12:52

---
title: Is knowing how to use Docker a prerequisite to becoming a Senior Software Developer?
published: true
description: 
tags: discuss
---

Just a question I think needs some discussion. I know titles in software dev are pretty much out the window at this point, but was curious on the communities thoughts.

Is knowing what containers are and how to use them necessary in 2020? Docker specifically?
Generic React Hook for async functions
Tags: react, typescript
Published: 2020-01-22 21:09:15

I came up with the following function to create a **React Hook** of **any async function** (if it matches a simple interface with just one input parameter), which turns it into a *GraphQL/Apollo-like* hook.

```typescript
type HookableFunc<T, P> = (param: P) => Promise<T|null>; 
type HookedFuncResult<T> = {
    result: T|null;
    err: any;
    pending: boolean;
};

export const asHook = <T, P>(func: HookableFunc<T, P>, param: P): HookedFuncResult<T> => {
    const [result, setResult] = useState<T|null>(null);
    const [err, setErr] = useState<any>();
    const [pending, setPending] = useState<boolean>(false);

    useEffect(() => {
        setPending(true);
        func(param)
            .then(setResult)
            .catch(setErr)
            .finally(() => setPending(false));
    }, [JSON.stringify(param)]);

    return {
        result,
        err,
        pending,
    };
};

```

**Usage**:

```typescript
const myFunc = async(param: string): string[] => {
    // fetch data, use IO, etc.
};

export const useMyFuncHook = (param: string) => asHook(myFunc, param);

// elsewhere
export const MyComponent: React.FC<MyProps> = (props) => {
    const { pending, err, result } = useMyFuncHook(props.param);

    if (pending) return "Loading...";

    if (err) return "Some error occurred: " + JSON.stringify(err);

    if (!result) return "No data found!";

    return <Result data={result} />;
};
```
----

For an electron app, I needed to fetch data from the *local file system* in many different components.

But as I *exclusively use Function Components* (I find the whole concept of classes in JavaScript a bit weird), and these doesn't play nice together with async functions (which any function that uses external IO of any sort should be naturally anyways), I needed a proper solution to call those functions.

The solution is of course **React Effects**. Finding and reading [this](https://medium.com/javascript-in-plain-english/how-to-use-async-function-in-react-hook-useeffect-typescript-js-6204a788a435) great article, I was happy to have solved my problem.

However the solution proposed there lacks generality and type-safety which I definitely wanted, as I needed this in lots of places and don't want to repeat what boils down to basically the same code over and over again, so I came up with my `asHook` function.
What makes the JAMstack secure?
Tags: jamstack, jamuary
Published: 2020-01-22 21:00:44

Security is a huge concern when building for the web. Even with countermeasures in place, keeping websites safe from attack can seem like an endless endeavor. This is especially the case in monolithic server side setups where countless third party plugins are exposed to enable administrators easy access to content and configurations. However convenient they may be, they create a massive surface area for malware penetration. Because they require frequent (and often buggy) updates, plugins are notoriously insecure. Sites that heavily rely on plugins and the frequent update cycles they demand, therefore often run the risk of either breaking or being pwned altogether. The need for such setups to be constantly running and available further increases the surface area for attack. Every site visit demands a trip to the server and a re-execution of the build. This results in critical endpoints being exposed and increases the overall risk for attack. 

As trivial as this may seem, reducing a website’s vulnerability to attack can be achieved by simply going static. In a static setup, files are read only and there is no real code or build process to be run. Though servers are still involved in a JAMstack setup—mainly to run the build process—they remain in relative obscurity since only built static files are exposed to the public via a CDN. Moreover, the distributed nature of the JAMstack API ecosystem mean that services are incredibly decoupled from one another. In the event that the CDN or an external facing API were to be compromised, you can still remain confident that the underlying infrastructure is safe and the safety of your site is not in jeopardy. With no databases, plugins, or dynamically running builds, the risk of code injection on a JAMstack style site is dramatically reduced.

JAMstack or not, security on a site is never 100% guaranteed and a robust security strategy requires some effort. HTTPS is one obvious and simple way to get started with making your JAMstack sites secure. For more convincing on why you’d want HTTPS on your static JAMstack setup, check out [this timelessly relevant post over on the Netlify blog](https://www.netlify.com/blog/2014/10/03/five-reasons-you-want-https-for-your-static-site/?utm_source=devto&utm_medium=https-div&utm_campaign=devex).
Which Recommendation Would You Prefer?
Tags: bots, github
Published: 2020-01-22 21:00:30

Pretend you received these on a pull request you submitted to a GitHub project. Which one would you prefer and why?

Recommendation A
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/reoybgwtngrvv2zxdi16.png)

Recommendation B
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/hysbkosa65bc0db98b65.png)
School problem from senior developer interview
Tags: challenge, career, math, python
Published: 2020-01-22 21:00:13

I was asked this problem years ago at interview for Java developer. It was about using BigInt really, but that's not important. I later slightly extended it and started asking when I interview other people in my turn (usually big-data or data science developers). Curiously, it puzzles about 40% people pretending for several kilo-dollars salary :o 

Code could be written in 3 minutes (e.g. in `Python`), but then people sometimes stuck for hour. I think most of you, Friends, will solve it easily - but you can check your colleagues for fun. So here it is:

### Statement

Fibonacci numbers (we all know them) are defined as:

```py
fib = [0, 1, 1, 2, 3, 5, 8, ...]

# or in other words
fib[0] = 0
fib[1] = 1
# ...
fib[n] = fib[n-1] + fib[n-2]
```

Write the program (usually in Python) which finds index, where Fibonacci value ends with specific digits. For example ending `12345` could be found at fib[155].

Then find the following:  

```
For which index X fib[X] ends with five digits `55555` ?  
For which index Y fib[Y] ends with seven digits `7770777` ?  
For which index Z fib[Z] ends with eight digits `20200123` ?
```

This value `20200123` is just today's date, nothing special about it. :)

_P.S. I think it's ok to drop X, Y, Z in the comments when you find them. Code - as you wish..._

_P.P.S. if can't solve at once, [this problem](https://www.codeabbey.com/index/task_view/fibonacci-divisibility-advanced) may give inspiration, though of course you'd better try solving on your own first... If it is necessary I'll update the post with explanation in about three days, though I believe it is too simple for most of readers._
Dev as a Hobby?
Tags: help
Published: 2020-01-22 20:59:50

---
title: Dev as a Hobby?
published: true
description: Discussion for hobbyist or enthusiast.
tags: help
---

Hey y’all. Little bit of a RANDOM topic/thing I’m pondering for y’all. I have enough skills that I’m getting bored with tutorials quickly. However, I don’t have enough interest to commit to any kind of project any length of time. Dev is kinda in a hobby slot for me right now, and I have time to put towards it. However, I’ve had trouble doing just that. I can’t lose interest in dev either though, I’m very curious how things work, how things are built, I spend time thinking of things I might want to put my time towards in the dev space. I just haven’t found something as a hobby in the dev world to consistently put my time towards.
Continuous Deploy in CircleCI to shared host 🚀
Tags: docker, php, javascript, github
Published: 2020-01-22 20:59:40

CircleCI is a powerfull tool for continuous integration and continuous Deploy. Using docker to run builds in a clean and totaly customable container.
CircleCI integrates with GitHub and Bitbucket. Every time you commit code, CircleCI create a build.

If you interest in know more, please visit [circleci.com](https://circleci.com/product/).

So, in this post I show you how you can deploy to FTP using CircleCI.

After you create your account and link that with your Github or/and BitBucket, the steps is very simple, and I'm not abord this theme here.

CircleCI use yml file to configure how you integration is work's.
The file must be in the .circleci in your root project.

In this case, I'm use a php docker image with node. Then in command Im install git-ftp.
In the very first commit, you need pass **git ftp init** instad git **ftp push**, after that, you can change to **git ftp push** otherwise you receive an error.

*Very first commit:*
```yml 
git ftp init --user "YOUR_FTP_USE" --passwd "YOUR_FTP_PASS" "ftp://youdomain.com/public_html/"
```

*Others commit:*
```yml 
git ftp push --user "YOUR_FTP_USE" --passwd "YOUR_FTP_PASS" "ftp://youdomain.com/public_html/"
```

*In deploy field you can set how branches you want deploy:*
```yml
- deploy:
    filters:
      branches:
        only: master
```

*Complete yml file:*
```yml
version: 2
jobs:
  deploy:
    docker:
      - image: circleci/php:7.1-node-browsers
 
    steps:
      - checkout
 
      - run: 
          name: Deploy Master Branch
          command: |
            sudo apt-get update
            sudo apt-get -qq install git-ftp
            echo "Deploying project ..."
            echo $(git status)
            echo "Deploying to my ftp"
            git ftp push --user "YOUR_FTP_USER" --passwd "YOUR_FTP_PASS" "ftp://youdomain.com/public_html/"
 
workflows:
  version: 2
  just-deploy:
    jobs:
      - deploy:
          filters:
            branches:
              only: master
```
If you like this post, or need more information please comment bellow and I'm try to help you.
Show Dev.to: I just open-sourced Graindashboard - responsive web-application UI kit built on Bootstrap 4
Tags: showdev, webdev, design, html
Published: 2020-01-22 20:39:42

Hello there!

I'm super happy to share Graindashboard - responsive web-application UI kit built on Bootstrap 4.

![](https://user-images.githubusercontent.com/10295466/72931623-45353300-3d6f-11ea-8658-e4e227279723.jpg)

Online demo is available [here](https://demo.graindashboard.com/)

Project link on the Github: [https://github.com/maxkostinevich/Graindashboard](https://github.com/maxkostinevich/Graindashboard)
What is a Pure Function?
Tags: javascript, functional, webdev
Published: 2020-01-22 19:51:48

---
title: What is a Pure Function?
published: true
description: Understand what pure functions are and what their benefits are.
tags: JavaScript, Functional, Webdev
cover_image: https://i.imgur.com/EkjmCK8.jpg
canonical_url: https://helder.dev/what-is-a-pure-function/
---

<center>Originally posted on [helderburato](https://helderburato.com/what-is-a-pure-function/)</center>

---

Whenever you are told about pure functions, keep the following in mind.

> Pure Functions are functions the given an input parameter will always return the same output without causing side effects.

## When do Side Effects occur?

Side Effects occur when an executed function changes state within the application, which is known as **impure functions**.

## Why Pure Functions?

I will mention some topics that make the use of function so interesting. See below:

### Refactoring

Refactor the code wherever possible, pure functions give you the ease of change so you can observe improvements and apply them without affecting the rest of your application.

### Testability

For the simple reason that pure functions have their input and output values determined, this will greatly facilitate the writing of their unit tests.

### DRY (Don’t Repeat Yourself)

**Reuse your functions!**

### Should I always use Pure Functions?

Not! It’s important to realize that pure functions while offering several benefits aren’t used throughout the project. After all, if all the functions of your project were pure functions, there would be no side effects where they are visible to the outside world. Be sure to use when necessary, create unit tests and no doubt when there are bugs, it will be easier for you to uncover and correct them.

-----

## Let’s practice!

Create two functions a **pure function** and another **impure function**. Check out:

### Pure Function

```js
## ES6 ##
const sum = (x, y) => x+y;

## ES5 ##
var sum = function (x, y) {
  return x + y;
}
```

### Impure Function

```js
## ES6 ##
const x = 20;
const sum = (y) => x+y;

## ES5 ##
var x = 20;
var sum = function (y) {
  return x+y;
}
```

Note that the variable **x** is being defined in the global state of the application, so the output of the sum function will always depend on the global state change and not on the input passed as a parameter, which makes the function dependent on external factors.

## Conclusion

That’s it, folks, I hope this post helps you in developing nice functions, generating more productivity for you and your team.

Ah, if you have any question or suggestion, do in the comments of the post, I’m always attentive!
CLI Tooling comes to the .NET Framework
Tags: dotnetcore, cli
Published: 2020-01-22 20:33:13

---
title: CLI Tooling comes to the .NET Framework
published: true
description: The .NET Framework has typically required the user to use expensive tools such as visual studio in order to get started, now that .NET Core has arrived this is no longer the case.   
tags: dotnetcore, cli
---
The .NET Framework has typically required the user to use expensive tools such as visual studio in order to get started, now that .NET Core has arrived this is no longer the case.

The .NET Core framework has a CLI or command line interface which means it is possible to now work on projects with only a text editor and a command prompt.

The good people at Microsoft have also put together a tutorial which will help me and you learn the basic knowledge needed to be productive in dotnet core development: 

https://dotnet.microsoft.com/learn/dotnet/hello-world-tutorial/intro
Learning about Developer Relations: articles from past year
Tags: devrel
Published: 2020-01-27 17:54:11

---
title: Learning about Developer Relations: articles from past year
published: true
date: 2020-01-22 20:33:00 UTC
tags: DevRel, DeveloperRelations
canonical_url: https://maxkatz.org/2020/01/22/learning-about-developer-relations-articles-from-past-year/
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/7b704uddptx8zvvs4frd.png
description: 18 articles about DevRel
---

I learned a lot about Developer Relations in 2019 and in the process I have been sharing my experience here. The following is a collection of articles I published in the past year. I hope some of the content is valuable and helps you build and grow your program. I of course continue to learn. I’d love to hear what you think and what other topics I should cover.

[How to measure Developer Relations – DevRel meetup recap](https://dev.to/maxkatz/how-to-measure-developer-relations-devrel-meetup-recap-7b9)

[Why developers have influence today?](https://dev.to/maxkatz/why-developers-have-influence-today-3lkm)

[How many developers did we help?](https://dev.to/maxkatz/how-many-developers-did-we-help-1je1)

[Make developers awesome](https://dev.to/maxkatz/make-developers-awesome-20n0)

[Scaling Developer Relations with an online conference for developers](https://dev.to/ibmdeveloper/scaling-developer-relations-with-an-online-conference-for-developers-5bnb)

[Developers don’t hate marketing](https://dev.to/maxkatz/developers-don-t-hate-marketing-1op)

[Developer Relations: content series](https://dev.to/maxkatz/developer-relations-content-series-3dkh)

[Applying the Fogg Behavior Model to Developer Relations](https://dev.to/maxkatz/applying-the-fogg-behavior-model-to-developer-relations-2408)

[Share outcomes and results, not features](https://dev.to/maxkatz/share-outcomes-and-results-not-features-75d)

[SF DevRel meetup at MuleSoft – what I learned and notes](https://dev.to/maxkatz/sf-devrel-meetup-at-mulesoft-what-i-learned-and-notes-4chk)

[Interesting content ideas you may consider](https://dev.to/maxkatz/interesting-content-ideas-you-may-try-fo1)

[Where to publish content?](https://dev.to/maxkatz/where-to-publish-content-53ao)

[Notes from DevRelCon SF 2019](https://dev.to/maxkatz/notes-from-devrelcon-sf-2019-434m)

[Notes 📝, Pictures 📷 and More 💡 from Developer Relations Conference 🥑](https://dev.to/ibmdeveloper/notes-pictures-and-more-from-developer-relations-conference-44p4-temp-slug-8652220)

[Using online meetups to scale your Developer Relations program](https://dev.to/ibmdeveloper/using-online-meetups-to-scale-your-developer-relations-program-17li)

[Active developers vs. awareness events, an approach we are trying](https://dev.to/ibmdeveloper/active-developers-vs-awareness-events-an-approach-we-are-trying-2m4f)

[Why Developer Advocacy programs should consider working with partners](https://dev.to/maxkatz/why-developer-advocacy-programs-should-consider-working-with-partners-bnj)

[How content creates content](https://dev.to/ibmdeveloper/how-content-creates-content-3edj)
Why so much ".forEach() VS .map()" posts in javascript?
Tags: discuss
Published: 2020-01-22 20:24:21

---
title: Why so much ".forEach() VS .map()" posts in javascript?
published: true
tags: discuss
---

I saw many posts comparing .forEach() and .map(), but I have never seen a situation where we are faced with a problem of choice between these 2 APIs.

Even if they both iterate through elements in an array, they stays totally different.
- The **map()** method creates a new array.
- The **forEach()** method executes a provided function once for each array element.