teleren/devto huggingface dataset:
Open source crisis
Tags: watercooler, opensource, javascript
Published: 2020-05-15 18:36:17

This is a short post about recent changes I'm facing during the last few months in my open source community.

While some of my packages [about to reach 1000 GitHub stars](https://github.com/VeliovGroup/Meteor-Files) and used by [5 figure projects](https://forums.meteor.com/t/meteor-products-that-make-money/52735), my Patreon donations dropped to $5/mo. I believe it happened due to the ongoing worldwide crisis 🤔

The fun fact — I wasn't cashing Patreon donations, but was adding extra funds to send it to other creators I rely on. For example, to Sindre Sorhus, who one of the most active contributors in the JavaScript community nowadays. As I am, my commercial and my open source projects rely on his contributions.

Hence this month, I'm moving backing off Patreon to donating directly via PayPal. Here's how I'm doing that:

1. During the month, I pick projects and save its links in the notepad list; Sourcing from `package.json` and websites I visit;
2. Once a month, I have a recurring reminder that it's time to donate!
3. In less than an hour I pick 2-3 projects and start looking for the "donate" button;
4. If I can not find a button, I'm sending a nice supportive email, kindly asking for a PayPal link.

That's it! Sometimes contributors are not seeking cash support, but receiving my short email is inspirational and emotional support.

Support projects and contributors you rely on!

---

Are you an open source contributor or community member? Please, share how's your experience has changed during the global lockdown.

---

The ways to support open source contributions:

 - Follow [on Facebook](https://www.facebook.com/veliovgroup);
 - Follow [on Twitter](https://twitter.com/veliovgroup);
 - Support [via PayPal](https://paypal.me/veliovgroup);
 - Check and star open source projects on [GitHub](https://github.com/VeliovGroup).
Resolvendo problema de Access-Control-Allow-Origin (CORS) no Laravel
Tags: php, laravel, cors, accesscontrolalloworigin
Published: 2020-05-15 18:35:19

Quando estamos desenvolvendo APIs RESTFULL, é comum esbarrarmos com erro de CORS do tipo
![Erro CORS](https://www.andyknight.net/assets/img/2018-12-27/corserror.png)

Esse bloqueio se da por conta do protocolo HTTP e precisamos resolver.

Existem várias soluções na internet, como alterar o .htaccess, instalar pacotes como o [barryvdh/laravel-cors](https://packagist.org/packages/barryvdh/laravel-cors) entre outros.  

A solução que compartilho com vocês é bem simples e resolveu o meu problema no Laravel 6.
Vamos lá!  

1- Crie um novo Middleware
`php artisan make:middleware Cors`  
  
2- Adicione neste novo Middleware, localizado em **app/Http/Middleware/Cors.php**, o seguinte:
Dentro do método **handle**
`public function handle($request, Closure $next)
{
    return $next($request)
        //Acrescente as 3 linhas abaixo
        ->header('Access-Control-Allow-Origin', "*")
        ->header('Access-Control-Allow-Methods', "PUT, POST, DELETE, GET, OPTIONS")
        ->header('Access-Control-Allow-Headers', "Accept, Authorization, Content-Type");
}`  

3- Edite o arquivo **app\Http\Kernel.php** da seguinte forma:
Dentro de **$middleware** acrescente o middleware que acabou de criar:
`protected $middleware = [
    \App\Http\Middleware\TrustProxies::class,
    ...
        ...
        \App\Http\Middleware\Cors::class, //acrescente essa linha
    ];` 

4- Teste novamente sua aplicação e vida que segue! 

Tem muito conteúdo bom na internet explicando sobre CORS, porque acontece isso, n maneiras de resolver. Então, quis trazer um conteúdo curto e direto ao ponto, pois nosso prazo anda bem curto para as entregas, né?!

Agora, vamos voltar a codar porque a sprint está quase acabando.

Um abraço e até o próximo direto ao ponto.

Thiago Luna - [Linkedin](https://www.linkedin.com/in/thiago-luna/)
What is the advantage of Golang over Java and Scala?
Tags: go
Published: 2020-05-15 18:29:42

Go is designed for concurrent applications. Concurrency is a lot easier in Golang than Java or Scala.

Unlike Java, Go is compiled to machine code and is executed directly. That makes it faster. 

Threads and queues are built into Go, they are called goroutines and channels. Java uses OS threads but Go uses goroutines.

Go is the intentionally simplified language. It leaves out many Java (leave alone Scala) features. 

For example, there are no Object oriented features in the same way there is in Java. This makes it a lot simpler.

It also has great microservices support. Applications often have a number of external services like databases,queues,caches. 

Go uses async I/O so that application can work with any number of services without blocking web request.

So some advantages are:

* Fast Compilation
* Lightweight theading
* Go compiles to Native Code

More about Go:
* <a href="https://golangr.com">Learn Golang</a>
* <a href="https://golang.org/">Golang website</a>
Hire Laravel Developer
Tags: hirelaraveldeveloper, hireremotelaraveldeveloper
Published: 2020-05-15 18:26:57



Looking to hire Laravel developer for your project, We at Infigic Technologies provide Laravel expert developer from india for Laravel design and development services for startups, small, medium and large businesses. Laravel is a popular PHP framework that provides expressive and elegant syntax which simplifies the development process for a developer without sacrificing application functionality. Our talented and experienced PHP Laravel developer tends to deliver a prolific solution as per your business goals.
Python Scheduler: A cron job replacement
Tags: python
Published: 2020-05-15 18:14:47

In this post I would like to show you a more convenient way of scheduling tasks to execute on a given time period. 

Cron jobs are commands which are performed in a set time interval, it can be every minute, every hour, every third day, once a week etc.
Sometimes the process of creating and setting up a cron job might appear to be tedious and complicated. I've found an awesome python module for doing exactly what a cron job does but in a way cooler and more fun way.

The module is called **schedule** and according to its [official documentation](https://schedule.readthedocs.io/en/stable/), it is designed to be very understandable by a human. Here's how it looks: 

{% gist https://gist.github.com/dimitrov-d/454a92d7df415cf08beb5cb23cc8b896 file=schedule.py %}

Now, let's say we have a real life problem we need to solve and keep doing that periodically. As an example, I've made a script which checks for empty folders in a given path. This might appear to be a mess for someone who forgets to delete empty folders, keeps rearranging files and other scenarios. This is how the schedule module looks like in action:

{% gist https://gist.github.com/dimitrov-d/454a92d7df415cf08beb5cb23cc8b896 file=scheduler.py %}

Now, the last thing we need to consider: the scheduler is running only as long as we have our program open and running. When we close or stop the program, the scheduler is cut off and no longer checks for the time interval in the background.
As a solution for this, we can use the **nohup** command, which stands for no hangup and makes a process immune to hangups (in our case the hangup means stopping the script from running).
We have our scheduler.py file ready with the task we want to be executing in our timeline. These are the steps you should take in order to have the desired result:
* Install the schedule module via pip by running ```pip install schedule```, preferrably in your virtual environment
* At the top of your script add ```#!/usr/bin/env python3```. This step is necessary if you have multiple versions of Python installed and /usr/bin/env will ensure that the first Python interpreter in your $PATH environment variable is taken.
* In the terminal, run ```chmod +x scheduler.py```, which will grant the required file permissions for continuous execution
* Run the command ```nohup /path/to/scheduler.py &```. The '&' symbol ensures that your script will run in the background as a system process.

Congrats, you now have your script running in the background. You can feel free to close the terminal and do something else while your script will check for the time period uninterruptedly. If you want to stop script from running, you can list the processes and find its id with the command ```ps ax | grep scheduler.py``` which shows you the process' PID and then run ```kill PID``` 
[Source](https://janakiev.com/blog/python-background/)


*Note: This was developed and tested only on a MacOS system*
Free Python courses from Microsoft.
Tags: microsoft, python, programming, covid19
Published: 2020-05-15 18:06:30

Want to learn something for free during LockDown?

Well, Microsoft has released a free Python tutorial on their YouTube channel, with over 20 videos to help you learn Python.

(It was actually released last September, but it's still online for you to use)

The biggest hurdle when learning any new programming language is simply knowing where and how to get started.

Microsoft Senior Program Manager, Christopher Harrison says...

“What’s important? What do I need to know to be proficient? It’s hard to follow docs when you’re not even sure what you’re reading.

You might be taking a look at Python. Maybe you’re drawn because of its popularity. Maybe you’re drawn to its flexibility. With Python, you can create solutions of all shapes and sizes. You can dig into web development. Simplify your life through automation. Or maybe begin building the future with machine learning.

Picking up a new language is a common situation for modern-day developers. The days of going your entire career focused on one language are long since gone.

Fortunately, concepts typically don’t change as you move from one programming language to the next. Sure, the syntax might be different, but an if statement is still an if statement, even when it’s written using {,} or End If. So, we don’t need to learn how to program, but rather how to program in a new language.”

Over the last 25 years, I have constantly heard the phrase “Google’s my best friend”, as developers, we all struggle to remember every difference or nuance for the syntax and functions used in each language. I’ve certainly used Google more often than not for help or clarity. Do not be afraid to ask or do the same.

In today's world, we as developers will use different tools, depending on the project required.

Also, one more thing to consider during these difficult times, is that although it’s a novelty to work from home, just consider the benefits of working with likeminded people on the same project – I’ve always benefited from working with others and sharing ideas. This can be a little bit difficult when you work from home. Sure we could use Zoom or MS Teams to hold a meeting however it’s not the same when we're chatting at our desks or getting coffee, breakout sessions or over lunch.

Click the following link to check out the Free Python course.

https://www.youtube.com/playlist?list=PLlrxD0HtieHiXd-nEby-TMCoUNwhbLUnj


##python #code #programming #mikemintonuk #microsoft #microsoftdeveloper #learntocode #youtube
It's so annoying in 2020 you have to work with an ancient API which forces to use FormData
Tags: webdev, javascript, tutorial
Published: 2020-05-15 17:25:11

Here is a FormData helper for plain Object:
```javascript
export const getFormData = (input) => {
  const formData = new FormData();

  Object.keys(input).forEach((key) => {
    if (typeof !input[key] === "undefined") {
      return;
    }

    Array.isArray(input[key])
      ? (input[key]).forEach((value) => formData.append(`${key}[]`, value))
      : formData.append(key, `${input[key]}`);
  });

  return formData;
};
```
More tips and best practices on my [Twitter](https://twitter.com/max_frolov_).
Exploring Denoland #1 - My first stomps with DENO
Tags: deno
Published: 2020-05-15 16:35:32

---
title: Exploring Denoland #1 - My first stomps with DENO
published: true
description: The start of my journey through Denoland
tags: Deno
---

Sooo Deno 1.0 just launched. I have 0 knowledge about it but I’m curious to see what it has to offer. 

As the seasoned software developer that I am, let’s start as usual:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/d62sex3q65q98qab1o9x.png)

Deno.land looks promising, let’s execute the installation command:

```bash
curl -fsSL https://deno.land/x/install/install.sh | sh
```
```bash
Deno was installed successfully
```

That was fast and easy. After adding needed variables to my .bash_profile I can see my deno version:

```bash
$ deno --version
deno 1.0.0
v8 8.4.300
typescript 3.9.2
```

Soooooo let’s try it...wait...I...can...execute...remote...scripts...just...like...this:

```bash
$ deno run https://deno.land/std/examples/welcome.ts
Welcome to Deno 🦕
```

That’s useful...and scary...but they say it’s secure so ¯\_(ツ)_/¯

Ok last test in deno.land is the classic web server. I create a new test.ts file, copy the code:
```typescript
import { serve } from "https://deno.land/std@0.50.0/http/server.ts";
const s = serve({ port: 8000 });
console.log("http://localhost:8000/");
for await (const req of s) {
 req.respond({ body: "Hello World\n" });
}
```
and run `$ deno test.ts`

ERROR...It’s `$ deno run test.ts`
```bash
ERROR Uncaught PermissionDenied: network access to "0.0.0.0:8000", 
run again with the --allow-net flag
```

Here is the security, I have to explicitly allow Deno access to network requests:
```bash
$ deno run test.ts --allow-net 
```
ERROR...what about...
```bash
$ deno run --allow-net test.ts 
```
SUCCESS --- **Hello Denoland**
### End of exploration #1
 - Native Typescript support 💙💙💙💙
 - I like the idea of a strong and controlled standard library.
 - No package.json, fixed urls for packages. What about updating?

Have you tried Deno? Any thoughts about it?

[@albertobeiz](https://twitter/albertobeiz)
Create your own snippets in VS Code
Tags: vscode, tutorial
Published: 2020-05-15 17:20:15

Often you find yourself typing repetitive code or code you don't always remember by heart. With Visual Studio Code you can easily create your own code snippets so you can use them at any time. Like this:

![media query snippet](https://dev-to-uploads.s3.amazonaws.com/i/qvf65klpebuoyfl343my.gif)

Start by opening the Command Palette `Ctrl + Shift + P` and enter `Preferences: Configure User Snippets`. It will then ask you which files it should be used for, which can be CSS for example.

In the .json file, you can add as many snippets as you like in the object. This is a snippet I find useful, to write media queries.
```json
{
  "Mobile CSS": {
    "prefix": "media",
    "body": [
      "@media only screen and (max-width: 600px) {", 
      "  ",
      "}"
    ],
    "description": "media query for mobile screen"
  }
}
```

The first property is just what you name your snippet. The prefix is what you type in the editor to get the snippet suggested, body contains an array of lines of code, and a description of the snippet.

That's it. Go write code rapidly and easily.
![Fast typer GIF](https://media.giphy.com/media/PiQejEf31116URju4V/giphy.gif)
Is Golang used for enterprise software development? 
Tags: go
Published: 2020-05-15 17:12:09

Yes it is. Many of the large corporations are using <a href="https://golang.org/">Go</a>. Switching to Go is a trend now. Some examples of how big corporations use Golang:

* Netflix 
* Uber
* Adobe

Big companies process a lot of data and Go is very good with data. It can reduce server load time (Cost) and is great for microservices.

If you can save 80%-90% of the infrastructure costs of running <a href="https://nodejs.org/">NodeJS</a> with Go, why would you stick with NodeJS?

But enterprises often move slow, so a lot is in Java and will stay in Java for the coming time (why change what works?)

For large enterprises where costs to support millions of users get up into the millions of dollars, why wouldn't you take the money and use Go?

At this point the Go ecosystem is not as large as the one of Java and is thus not suited for every purpose (yet). But over time there will be more software written in Go.

One of the things is that there are many Java programmers, but Go is the new kid on the block and developers need to <a href="https://golangr.com/">learn Go</a>.
JavaScript DOM - Part 1 - What is it and what can we do with it? [video + article]
Tags: javascript, webdev, codenewbie, beginners
Published: 2020-05-15 17:11:56

> This is going to be a multi-part Video + article tutorial series on JavaScript DOM. You're reading Part 1

{% youtube I0JDbrg4VdY%}

## Intro

Those of us who do not know Web Development, have always wondered how the website responds to you instantly. Gone are those days where you just had static web pages and the days where the page has to actually reload completely to show any change in them. 
JavaScript DOM is like the basic knowledge that any web developer should have. Irrespective of whether you're gonna apply them directly or not.

## What is JavaScript DOM?

Before we answer this, you need to know what DOM is. **DOM stands for Document Object Model**. So when a browser loads a webpage, the entire HTML content of the webpage is made into a tree-like structure consisting of nodes. The structure of the tree depends on the HTML code itself. So **JavaScript DOM** is where we use JavaScript to access and modify the DOM.

So this is how the DOM Tree would look like for the example HTML Code

![DOM Tree](https://dev-to-uploads.s3.amazonaws.com/i/b9p9br0ojfbhcep0gwsy.png)

## What can we do with the DOM?

1. Change or Remove the elements from the DOM
2. Change or Add CSS properties to the elements
3. Read or change the element attributes like src, alt, href
4. Attach event listeners to the elements and make them respond to events
5. Create a new element and insert it anywhere 

We will learn more about each one of these in this series.

Read Part 2 here
{% link https://dev.to/tharunshiv/javascript-dom-part-2-the-document-and-window-object-video-article-6pi %}
Written by,
{% user developertharun %}

# Thank you for reading, This is Tharun Shiv a.k.a Developer Tharun

![Tharun Shiv](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xtxq6bdms36fmn62450h.png)
Suggest a tool for wiring paper prototypes
Tags: help, discuss, watercooler, design
Published: 2020-05-15 17:05:12

Hey!
I have a bunch of hand-drawn screens and I want to make them interactive.

A perfect solution would have the following flow:
1. Upload screens(or take a photo) and name them
3. Mark interactive elements on a screen with some set of primitives and link them to another screen
4. Generate a link to the project for sharing
Free Coil trial for all #gftwhackathon participants
Tags: gftwhackathon, webmonetization
Published: 2020-05-15 17:03:22

---
title: Free Coil trial for all #gftwhackathon participants
published: true
description: Coil is offering all Grant for the Web hackathon participants a free 3-month trial.
tags: gftwhackathon, webmonetization
---

In case you missed it, last week we announced the Grant for the Web Hackathon right here on DEV:

{% link https://dev.to/devteam/announcing-the-grant-for-the-web-hackathon-on-dev-3kd1 %}

As we shared in the post, there are [few options for wallets](https://webmonetization.org/docs/ilp-wallets) that can _receive_ payments via the Web Monetization API.  But what about the other side of the equation?

While there will be more wallets for _sending_ payments as the ecosystem grows, right now **the first and only Web Monetization provider is [Coil](https://coil.com)**.

The team from Coil is generously offering all [#gftwhackathon](/t/gftwhackathon) participants a **free, 3-month trial to Coil**.  This offer gives you the opportunity to experience Web Monetized browsing from the user side, and will allow you to thoroughly test your own hackathon submission as you continue building.

To take advantage of this free trial, **please leave a comment right here in this thread**.  We’ll get in touch by messaging the email associated with your DEV account.

We’re thankful that the Coil team is making this offer available to the community, and we hope that it helps you make even more progress on your submission.

_P.S. DEV will be big experimenters in the field of web monetization in order to help indie creators get paid in this less centralized way. We'll have more info coming soon in the form of posts and PRs, in the meantime take advantage of this Coil trial to get in on the ecosystem early._

Happy Coding!
Promisified node.js file system utilities
Tags: node, javascript, fs
Published: 2020-05-15 16:46:29

---
title: Promisified node.js file system utilities
published: true
description: "Utility for using promisified node.js file system utilities with async/await and promises"
canonical_url: https://davidwells.io/snippets/node-file-utilities
tags:
  - node
  - javascript
  - fs
---

> Originally published on [davidwells.io](https://davidwells.io/snippets/node-file-utilities)

Node introduced the `promisify` utilities in back in version 8.

Using `promisify` you can use the node.js file system utilities with `async/await` and `promises.`

There are a couple of bits missing from the core node.js filesystem.

Below are the promisified file system calls I use a bunch in projects.

I've added `createDir`, `fileExists`, and `deleteDir` to smooth over some of the core `fs` methods that can be a little awkward to work with.

```js
/* ./utils/fs.js */
const fs = require('fs')
const mkdirp = require('mkdirp')
const rimraf = require('rimraf')
const { promisify } = require('util')

const fileExists = (s) => new Promise(r => fs.access(s, fs.F_OK, e => r(!e)))

module.exports = {
  // Check if file exists
  fileExists: fileExists,
  // Read file
  readFile: promisify(fs.readFile),
  // Write file
  writeFile: promisify(fs.writeFile),
  // Recursively create directory
  createDir: mkdirp,
  // Read directory file names
  readDir: promisify(fs.readdir),
  // Recursively delete directory & contents
  deleteDir: promisify(rimraf),
}
```

Install `mkdirp` and `rimraf` npm packages for `deleteDir` & `createDir`

```
npm install mkdirp rimraf
```

Then you can use it in your project

```js
const path = require('path')
const { fileExists, readFile } = require('./utils/fs')

async function doIt(filePath) {
  const exists = await fileExists(filePath)  
  let contents
  if (exists) {
    contents = await readFile(filePath)
  }
  return contents
}

const file = path.resolve('foo-bar.json')
doIt(file).then((contents) => {
  console.log('Yay 🎉', contents)
})
```

Hope this helps!

Let me know if you have other file system utilities you like to use in the comments below.