teleren/devto huggingface dataset:
REDIS OPEN-SOURCE GRANT PROGRAM
Tags: redis, opensource, monetization, github
Published: 2020-05-24 16:43:19

“In real open source, you have the right to control your own destiny.”
Linus Torvalds

Source and full article: https://blog.xscode.com/782/announcing-the-redis-open-source-grant-program/

------- xs:code – Redis Labs collaboration -------

We believe that keeping a sustainable open source ecosystem, means getting open source developers the resources they need to continue developing the amazing free software we all use.

At xs:code, we’ve made it our mission to connect open source developers with the software companies that use their projects. With more and more companies using xs:code to find paid solutions, support and licensing for the open source components they use – we aim to help as many open source developers discover the potential of offering paid products and services on top of their free code, and turn their open source projects into steady sources of revenue.

This is why we’ve collaborated with Redis Labs to offer open source developers a unique opportunity to kick-start the monetization of their projects, and start offering paid items with their Redis-related open source repositories.

We’re happy to announce a $15,000 fund that is dedicated solely to open source developers working on Redis related projects. If you are developing a Redis related open source project and you want to start monetizing it, you’re automatically entitled to participate in our grant plan, where we match the revenue your project generates on xs:code. For every dollar you make – we’ll pay you a dollar. No need to apply or qualify – just develop an open source project that is Redis-related and monetize it with xs:code.
-------
More details:
https://blog.xscode.com/782/announcing-the-redis-open-source-grant-program/
Retrieving Files with the 'fetch' API
Tags: javascript, fetch, files, api
Published: 2020-05-24 16:34:05

---
title: Retrieving Files with the 'fetch' API
published: true
description: Fetch is usually used to get data from APIS, but it can also be used to retrieve files!
tags: Javascript, Fetch, Files, API
---
Javascript's [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch) is usually used to get data from an API. But it can also be used to retrieve files!


# Fetch a .txt file 
The [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) object that is returned from 'fetch', has a few methods that let you retrieve the data returned from the request
- .json(): returns json
- .text(): returns a string of all the text in the response

We use the .text() method to get a string of the text from a file.
```javascript
fetch('example.txt')
.then(response => response.text()) 
.then(textString => {
  	console.log(textString);
});
```

The process is identical if we wanted to retrieve a .csv file and do something with the data that's in the file. But we have some extra code to break up the file into rows.
```javascript
fetch('example.csv')
.then(response => response.text()) 
.then(csvString => {
	//Split the csv into rows
	const rows = csvString.split('\n');
  	for (row of rows) {
	//Split the row into each of the comma separated values
  		console.log(row.split(","));
  	}
});
```

Look at this GitHub repo for example code:
https://github.com/jpowell96/readFilesWithFetch
Smart Patient Information System for cross-hospital data sharing and Heart disease prediction.
Tags: 2020devgrad, octograd2020, githubsdp, machinelearning
Published: 2020-05-24 16:27:38

---
title:  Smart Patient Information System for cross-hospital data sharing and Heart disease prediction.
published: true
description: I just graduated from Kwame Nkrumah University of Science and Technology, and this was my final project!
tags: 2020devgrad, octograd2020, githubsdp, machinelearning
---

## My Final Project

Going though university for 4 years is no joke! Especially if you're a CS student. However I didn't let that prevent me from reaching my goals. One of my goals was to finish university with a good project that I'd be proud of. And considering that I'm a huge fun of machine learning, I convinced my parter that we should build something with machine learning. We decide to tackle a serious problem in Ghana : inconsistency in patients' medical records across hospitals. We set out to build a platform that will enable various hospitals in Ghana to securely share patient data. We also wanted to develop a machine learning model that predict chronic diseases such as heart disease.


## The Project

The system consists of a module for hospitals to securly transmit patient information to prevent inconsistencies in data. The system also has a machine learning component that predicts heart disease of the patients' data.
The project is quite big so it's still in development.


##How I built it:
1. React JS for web app frontend
2. Firebase for backend and authentication
3. Python and Tensorflow for Machine learning model

I ran into a lot of issues especially with the machine learning model. However, stackoverflow saved me a lot of the times!


##Link to Code
This article will be updated with the link to the github repo.



## Additional Thoughts / Feelings / Stories

This was one challenging project I loved buiding!


[Final Note]: # (CONGRATULATIONS!!! You are amazing!)
What’s your alternative solution? Challenge #50
Tags: challenge, javascript, codenewbie, learntocode
Published: 2020-05-24 16:24:13

# About this series

This is series of daily JavaScript coding challenges... for both beginners and advanced users.

Each day I’m gone present you a very simple coding challenge, together with the solution. The solution is intentionally written in a didactic way using classic JavaScript syntax in order to be accessible to coders of all levels.

Solutions are designed with increase level of complexity.

## Today’s coding challenge

```
Create a function to calculate the sum of all the numbers in a jagged array (array contains numbers or other arrays of numbers on an unlimited number of levels)

```

(scroll down for solution)

## Code newbies

If you are a code newbie, try to work on the solution on your own. After you finish it, or if you need help, please consult the provided solution.

## Advanced developers

Please provide alternative solutions in the comments below. 

You can solve it using functional concepts or solve it using a different algorithm... or just solve it using the latest ES innovations.

By providing a new solution you can show code newbies different ways to solve the same problem.

## Solution

```javascript
// Solution for challenge45

var ar = [1, 2, [15, [23], [5, 12]], [100]];

println(sumArray(ar));

function sumArray(ar)
{
    var sum = 0;
    
    for(var el of ar)
    {
        if (Array.isArray(el))
        {
            el = sumArray(el);
        }
        
        sum += el;
    }
    
    return sum;
}

```


To quickly verify this solution, copy the code above in this coding [editor](https://codeguppy.com/code.html) and press "Run".

> Note: The solution was originally designed for [codeguppy.com](https://codeguppy.com) environment, and therefore is making use of `println`. This is the almost equivalent of `console.log` in other environments. Please feel free to use your preferred coding playground / environment when implementing your solution.
Import Posts to dev.to via RSS
Published: 2020-05-24 16:10:55

---
title: Import Posts to dev.to via RSS
published: true
description: automatic import my posts from mmap.page to dev.to
tags: 
---

I imported most of my articles from [mmap.page](https://mmap.page) via the "Publishing to DEV from RSS" feature.

The automatic import feature works.
But there are still some issues left:

1. (expected) All imported post is published today. Because I just wrote some markdown files without writing any front matter meta data, including `date`. (Technically speaking, GitHub Pages (Jekyll) treat my markdown files as pages, not blog posts.)

2. (expected) No syntax highlight for code blocks. Because dev.to converts HTML back to markdown, thus all `span` tags for syntax highlight has been stripped. Anyway, there is no syntax highlight in the RSS reader either, because the RSS 2.0 specification does not support CSS style sheet and most RSS readers do not bother.

3. (unexpected) In some posts spaces after some punctuation marks, such as commas and periods, got stripped mystically. There may be a bug in the HTML to markdown converter used by dev.to.

4. (unexpected) Some posts are broken. It seems that dev.to will mistakenly treat triple backticks preceded by other characters (e.g. // &#96;&#96;&#96;rust) as start/end of code blocks.

So the proper way to import markdown files to dev.to is writing a script invoking the API of dev.to, which uses the markdown source directly, without the unreliable process of `markdown (source) -> html (rss) -> markdown (dev.to)`. I will leave this trivial task to my future self.
How to cd to a directory with a space in the name? 
Tags: Terminal, help
Published: 2020-05-24 15:52:01

Hi, I'm trying to navigate my folders using terminal and want to go into a folder called 'Front end'. I googled and found 2 solutions :

-Put quotes around the directory name. (cd ~/"Front end"/) 
-Escape the directory name with a backslash (cd ~/Front\ end/)

None of these solutions work for me. Am I missing something?

Thanks for help.

https://dev-to-uploads.s3.amazonaws.com/i/8fksvb5za17363gsjrgh.png
The Backend-for-frontend Pattern For Monoliths
Tags: laravel
Published: 2020-05-24 15:44:13

The [majestic monolith](https://twitter.com/dhh/status/962452557502201856) is how I build backends since I started. Microservices seemed like too much work for the small teams I worked with. However, some of the patterns used to build and service applications running in a microservice architecture can be useful for monoliths.

One of these patterns is the backend-for-frontend pattern. The idea is to have a dedicated backend for your frontends. It can be a separate backend for each type of frontend or one backend for all frontends.

To understand how this pattern can be useful, let's imagine we're building an online store. We have our backend exposing a public REST API, this API can be consumed by our web UI, mobile apps, and other 3rd party consumers. Authentication to our backend is done using OAuth2.0, all consumers must send a bearer token to protected routes.

Authentication
--------------

Storing the authentication token in the mobile app is fine, but there's [no way to store the tokens in the browser securely](https://www.rdegges.com/2018/please-stop-using-local-storage/). Using a dedicated backend for our web frontend, we can use that BFF (Backend For Frontend) as a gateway to the actual backend and store the token in it.

So to log the user in to our web frontend, the frontend will make a request to the BFF which will send a login request to the backend, receive the token, and then store it in the session.

Communication between the web frontend and the BFF is authenticated using sessions, while the BFF communicates with the backend using token-based authentication.

Authorization
-------------

Roles and permissions for an app that's used to make orders and browser products are different from ones for an app that's used to manage inventory and suppliers.

Using a BFF for each type of client, we can run the authorization checks in the BFF and keep our backend as much open as we want it to be. Allowing us to build more clients in the future without having to change the backend.

Aggregation
-----------

To render a screen that displays all products, featured products, and recommended products. A client may need to make 3 requests to 3 different backend endpoints. Even if these requests are made concurrently, the client still has to send 3 requests and wait for the responses.

Using a BFF, the client can make a single request to a /products-list endpoint on the BFF and the BFF will aggregate the response needed by making the 3 requests to the backend.

Server-to-server communication will experience less latency and we can add a caching layer in the BFF which will make things even better.

BFF and Laravel
---------------

In the following video, I discuss the BFF pattern and explain how we can implement it using Laravel.

{% youtube zazeGmFmUxg %}
Use npm without package.json
Published: 2020-05-24 15:35:12

---
title: Use npm without package.json
published: true
date: 
tags: 
canonical_url: https://mmap.page/dive-into/npm/
---

## Why NOT package.json?

`package.json` brings in unnecessary complexity.If you do not think so, have a look at [Go](https://pkg.go.dev/) and [Deno](https://deno.land/std/manual.md).

## Everyday Use without package.json

Tell npm to not save package:

```
npm config set save false

```

Install development tools as global packages:

```
npm i -g typescript
npm install -g eslint
npm i -g @zeit/ncc

```

For temporal usage or test, use `npx`:

```
npx cloc index.js

```

`npx` can also be used to test different node versions:

```
npx -p node@13 node -v

```

Install dependencies as devDependencies:

```
npm i -D express
npm i -D @types/express

```

Use [ncc](https://github.com/zeit/ncc/) to package runtime dependencies into a single JavaScript file:

```
# install dependencies according to resolved urls to tarballs in package-lock.json
@cat package-lock.json | jq '.dependencies[].resolved' | xargs npm i --no-package-lock
ncc build index.js --minify # output file: dist/index.js

```

Then you can move the bundled `index.js` file to any place where Node.js is installed,and run it with `node index.js` without installing any npm modules.

## Alternative to `npm run`

Just use plain old Makefile, e.g.

```
dist/index.js: index.js
	@cat package-lock.json | jq '.dependencies[].resolved' | xargs npm i --no-package-lock
	ncc build index.js --minify

```
You can hide sensitive data with '*'
Tags: javascript, privacy
Published: 2020-05-24 15:34:56

---
title: You can hide sensitive data with '*'
published: true
description: Hide some sensitive data with the character '*'
tags: Javascript, Privacy
---
## Privacy Holder

Hide some sensitive data with character '*'

### Features
1. Support hide common user data like: email, phone number, id card etc.
2. Support Custom rules (fragment method) to hide sensitive data.
3. Test Coverage 100%

### Install

```bash
yarn add privacy-holder
```

or

```bash
npm install privacy-holder
```

> PS: Do not install version `0.0.4, 0.0.5` these versions are break

### Usage

```javascript
 const privacy = require('privacy-holder')
```

Then

```javascript
 privacy.email("ihavecoke@163.com") // ih*******@163.com
 privacy.name("ihavecoke") // *
 privacy.name("i havecoke") // *havecoke
 privacy.idCard("510122199102132018") // 510***19******2018
 privacy.phoneNumber("13800000000") // 138****0000
 privacy.all('all-will-be-*') // *************
```


Also, you can custom rules like this

```javascript
 privacy.fragment('abcdefgi','####',2,6) // ab####i
```
more [privacy-holder](https://github.com/ihavecoke/privacy-holder/)
Gitlab CI script to deploy a .NET core Azure Webapp
Tags: azure, gitlab, dotnet
Published: 2020-05-24 15:34:44

Here is the `.gitlab-ci.yml` that I use to deploy my **.NET Core 3.1 azure web app** in Gitlab CI/CD.

Variables that I use in the scripts:
- **$AZ_SERVICE_PRINCIPAL_URL**
- **$AZ_SERVICE_PRINCIPAL_SECRET**
- **$AZ_SERVICE_PRINCIPAL_TENANT**
- **$AZ_APP_NAME**
- **$AZ_APP_RESOURCE_GROUP**

```yml
stages:
  - deploy

deploy:
  stage: deploy
  image: mcr.microsoft.com/dotnet/core/sdk:3.1
  script:
    - apt-get update && apt-get -y install zip
    - curl -sL https://aka.ms/InstallAzureCLIDeb | bash
    -  az login --service-principal -u $AZ_SERVICE_PRINCIPAL_URL -p $AZ_SERVICE_PRINCIPAL_SECRET --tenant
        $AZ_SERVICE_PRINCIPAL_TENANT
    - dotnet restore --configfile ./NuGet.config 
    - dotnet publish -c release -o out
    - cd out && zip -r app.zip .
    - az webapp deployment source config-zip -n $AZ_APP_NAME -g $AZ_APP_RESOURCE_GROUP --src app.zip
  only:
    - master
```

Hope it's useful
100daysofcode Flutter
Tags: 100daysofcode, flutter
Published: 2020-05-24 15:34:34

day 76/100 of #100daysofcode #Flutter
Learning Flutter , courses Udemy from
@maxedapps

Today learn about sqlite,preparing sqlite, sqlite insert, sqlite ConflictAlgorithm
https://github.com/triyono777/100-days-of-code/blob/master/log.md
RarCrack
Published: 2020-05-24 15:31:39

---
title: RarCrack
published: true
date: 
tags: 
canonical_url: https://mmap.page/dive-into/rarcrack/
---

This note is written for RarCrack 0.2.

RarCrack brute forces password for encrypted zip, rar, 7z files.

```
rarcrack FILE_NAME --threads 4

```

Note that if `--threads` is omitted, RarCrack will use 2 threads, no matter how many cores your CPU has.

You can cancel the brute forcing (e.g. via `Ctrl-c`) at any time,and RarCrack will resume cracking at next startup.This is because RarCrack uses a status file `FILE_NAME.xml` at the same directory to record progress.

And this mechanism can be used to speed up cracking.For example, if you remember that the password is 6 digits:

```
<?xml version="1.0" encoding="UTF-8"?>
<rarcrack>
  <abc>0123456789</abc>
  <current>000000</current>
  <good_password/>
</rarcrack>

```

For zip and 7z files, an alternative to RarCrack is fcrackzip.And it has more features, e.g. specifying password range and using a dictionary.However, last time I tried to fcrackzip a zip file,it reported that the zip file is corrupt.And RarCrack successfully cracks the very zip file.
Tinygo
Published: 2020-05-24 15:30:52

---
title: Tinygo
published: true
date: 
tags: 
canonical_url: https://mmap.page/dive-into/tinygo/
---

[Tinygo](https://tinygo.org) is a Go compiler for microcontrollers and WebAssembly.It also supports x86 32 bit and 64 bit Linux.

## Getting Started

### Install

```
sudo apt install llvm-7-dev libclang-7-dev
go get -u github.com/tinygo-org/tinygo

```

### Usage

To compile a Linux executable:

```
tinygo build -o hello_tiny hello.go

```

The output size of a hello world program is very impressive to me:

```
1.1M hello
12K hello_tiny

```

Or run it directly:

```
tinygo run hello.go

```

## Go Language Features

Not supported:

- Maps.
- Concurrency.
- Reflection.
- Cgo.
- Many parts of standard library (due to the above missing pieces).
- `recover()`
- `complex64`, `complex128`, and arithmetic on complex numbers.
- `defer` a call on a function pointer.
- 3-index slicing, e.g. `slice = array[2:4:7]`.
Deep Dive into the Single Responsibility Principle
Published: 2020-05-24 15:29:07

[Clean code](https://medium.com/@danielrusnok/deep-dive-into-the-single-responsibility-principle-3726c5bf736c?source=friends_link&sk=3e39cacf0805bd4b4e05649dfddee894) _is a software development discipline which aims to raise IT company’s vitality by introducing practises, principles and patterns to improve developer’s programming skills. Programmer’s who follows_ Clean Code _becomes professionals and leaders in their fields._

{% medium https://medium.com/@danielrusnok/deep-dive-into-the-single-responsibility-principle-3726c5bf736c?source=friends_link&sk=3e39cacf0805bd4b4e05649dfddee894 %}
Exception and Union Type
Published: 2020-05-24 15:27:37

---
title: Exception and Union Type
published: true
date: 
tags: 
canonical_url: https://mmap.page/dive-into/exceptions/
---

Java has checked exception, which is essentially union type.

Kotlin dislikes Java’s checked exception, and just removes it.

Ceylon also does not have checked exception, but it has union types.

Swift has something like semi-checked exception.Unlike Java, a Swift function can only declare if it may throw an exception or not.(Specifying `throws` in function signature.)But it cannot specify types of exception.Thus if the caller of the function tries to catch the exception,it must have a default catch all clause in the end.And since Swift only distinguish functions may throw and may not throw,it is straightforward to map a function’s throwability to optional type(via `try?`).

## Optional Type and Union Type

`T?` can be considered as a union of `T|Null`.

`(J|K) -> T` can be expressed as overloads.

## More on Exception and Union Type

> Checked exception is an imperfect, ugly implementation of union type.

– [Yin Wang](http://www.yinwang.org/blog-cn/2017/05/23/kotlin)

For example, `String f() throws NotFound` can be considered as a function returning a union type of `String | NotFound`.

From the viewpoint of union type, `String | NotFound` and `NotFound | String` is equivalent.Thus we can use exceptions as return value, and return value as exception in Java.

```
class DividedByZero {}

class IntRet extends Exception
{
	public int value;

	public IntRet(int value)
    {
      this.value = value;
    }
}

class CharRet extends Exception
{
	public char value;

	public CharRet(char value)
    {
		this.value = value;
    }
}

public class HelloWorld
{
	private static DividedByZero divide(int x, int y) throws IntRet, CharRet
	{
		if (y == 0)
		{
			return new DividedByZero();
		}
		else if (y < 0)
		{
			throw new CharRet('N');
        }
		else
		{
			throw new IntRet(x / y);
		}
	}

	public static void main(String[] args)
	{
		try
		{
			DividedByZero err = divide(10, 2);
			System.out.println(err); // handle error
		}
		catch (IntRet e)
		{
			System.out.println(e.value);
		}
		catch (CharRet e)
        {
			System.out.println("Divided by a negative number is not supported yet.");
        }
	}
}

```

This also applies Kotlin.Using exceptions as return values can spare return value for exception.The Kotlin compiler will warn us unused declared variable,so this in effect mimics checked exception for a language without checked exception in an exotic and ugly way.

```
object DividedByZero {}

class IntRet(val value: Int): Throwable(null, null) {}

fun divide(x: Int, y: Int): DividedByZero
{
    if (y == 0)
    {
        return DividedByZero
    }
    else
    {
        throw IntRet(x / y)
    }
}

fun main(args: Array<String>) {
    try
    {
        val err = divide(10, 2)
        println(err) // handle error
    }
    catch (e: IntRet)
    {
        println(e.value)
    }
}

```