teleren/devto huggingface dataset:
Tanaman Porang Yang Mulai Mendunia
Tags: tanamanporang, tumbuhanporang, budidayaporang, menanamporang
Published: 2021-03-19 04:22:11

<a href="https://dev.to">Tanaman Porang</a> adalah umbi yang dahulu amat dibenci dan diremehkan. Umbi ini dahulu diakui hama dan banyak dimusnahkan, meskipun beberapa jadi digunakan untuk memenuhi keperluan pangan. Tanaman porang liar mampu tumbuh tinggi dan mempunyai banyak bibit, yang membuatnya cepat menyebar.

Budidaya <a href="https://rumahporang.web.id">Tanaman Porang</a> memang amat mudah, asalkan memenuhi suasana idealnya untuk tumbuh. Yaitu ketinggian, intensitas cahaya, dan perawatan. Dengan memenuhi tiga aspek diatas, maka porang dapat tumbuh subur dan besar. Hal ini dibuktikan dengan mudahnya porang liar tumbuh dilahan pertanian warga yang berada di lereng pegunungan.

Permintaan ekspor untuk porang waktu ini makin menggila, Jepang dan Cina adalah dua negara dari banyak negara yang punya permohonan tinggi dapat porang dan hasil olahannya. Baik umbi porang yang telah diolah menjadi chip, maupun tepung porang.

Dua negara ini produksi hasil olahan porang tersebut menjadi bahan basic kosmetik, atau makanan khas Jepang yaitu konyaku. Tidak heran, porang amat diminati waktu ini, apalagi kala kurangnya stok yang tersedia di Indonesia. Siapkah kita memenuhi permohonan tersebut?

Jawa telah jadi bergerak membudidayakan tanaman porang, siapa yang tidak kenal Paidi, sang petani porang yang berhasil setelah membudidayakan tanaman porang.Hal ini memperlihatkan bahwa kesempatan budidaya porang amat besar waktu ini, apalagi ditahun 2021 ini.

Budidaya porang juga memang tidak mengharuskan kita punya lahan yang luas, porang bsia dibudidayakan di polybag. Masih curiga dapat keuntungan budidaya tanaman porang ini?
State
Tags: react, state
Published: 2021-03-19 03:31:31

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

O estado de uma aplicação representa as características dela naquele momento. Por exemplo: os dados do usuário foram carregados, o botão está ativo, o usuário está na página de contato e etc.

```js
const App = () => {
  const ativo = true;

  return (
    <button disabled={!ativo}>{ativo ? 'Botão Ativo' : 'Botão Inativo'}</button>
  );
};
```

## Hooks

Hooks são funções especiais do React que permitem controlarmos o estado e o ciclo de vida de componentes funcionais.

### `useState`

É uma função que retorna uma Array com 2 valores. O primeiro valor guarda o dado do estado atual, pode ser qualquer tipo de dado como strings, arrays, números, boolean, null, undefined e objetos. O segundo valor é uma função que pode ser utilizada para modificarmos o estado do primeiro valor.

Quando a função de modificação do estado é ativada, todos os componentes que dependerem do estado, serão renderizados novamente e os seus filhos também. É isso que garante a reatividade de componentes funcionais no React.

```js
const App = () => {
  const [ativo, setAtivo] = useState(true);
  // É a mesma coisa que:
  // const ativoArray = useState(true);
  // const ativo = ativoArray[0];
  // const setAtivo = ativoArray[1];

  return (
    <button onClick={() => setAtivo(!ativo)}>
      {ativo ? 'Botão Ativo' : 'Botão Inativo'}
    </button>
  );
};
```

> O uso de setNome é uma convenção do React para a função de modificação do estado

### Múltiplos Estados

Não existem limites para o uso do `useState`, podemos definir diversos no mesmo componente.

```js
const App = () => {
  const [contar, setContar] = useState(0);
  const [ativo, setAtivo] = useState(false);
  const [dados, setDados] = useState({ nome: '', idade: '' });

  return <div></div>;
};
```
Adding Table of Contents to Dev.to Posts
Tags: productivity, writing, tips
Published: 2021-03-19 02:46:15

I uploaded another game design [article](https://dev.to/goldenxp/core-mechanics-of-fighting-games-24ej) which originally had Table of Contents (ToC from here on) and I wanted to recreate that section in my dev.to post.
Fortunately, every header tag on dev.to is nicely **a**nchored. Good job, Dev team!

So, Markdown data of headers like this...
```
## Section
## Another Section
### Sub-Section
```
...produces...
```html
<h2>
  <a name="section" href="#section" class="anchor"></a>
  Section
</h2>
<h2>
  <a name="another-section" href="#another-section" class="anchor"></a>
  Another Section
</h2>
<h3>
  <a name="subsection" href="#subsection" class="anchor"></a>
  Sub-Section
</h3>
```
And so, to produce ToC in Markdown, you can write something like...
```
## Table of Contents
1. [Section](#section)
2. [Another Section](#another-section)
    1. [Sub-Section](#subsection)
```
It's important to note how the reference gets converted. As you can see from the second and third headers, spaces become hyphens and hyphens are removed. Oh and it's all lowercase.

---

Of course, if you have many big articles, writing each ToC by hand might be tedious and prone to error. I quickly hacked up this script which seems to work "okay" when I run it in my browser's console with the Dev.to Preview tab up.
```js
var anchors = document.getElementsByClassName("anchor");
var outputMarkDown = "## Table of Contents\n";
var orderedNumbers = { };
for (var item in anchors)
{
    var anch = anchors[item];
    var pelm = anch.parentElement;
    var sibl = anch.nextSibling;
    // parent is necessary as this is the header tag used
    // next sibling is necessary as this is the header text
    if (!parent || !sibl) continue;
    // indent n times 4 spaces (considers h2 to be first, hence -2)
    var indent = pelm.nodeName.slice(-1) - 2;
    outputMarkDown += "    ".repeat(indent);
    // add number
    if (!orderedNumbers[indent]) orderedNumbers[indent] = 1;
    outputMarkDown += orderedNumbers[indent]++ + ". ";
    // add links
    outputMarkDown += "[" + sibl.textContent.trim() + "](" + anch.hash + ")\n";
}
console.log(outputMarkDown);
```
This is what it produced when I ran it on the article linked at the top of this post.
![Test Result ToC](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fnpwg4x6tw0znbb8g0ki.png)
Tableghi Jmaat Pakistan 
Published: 2021-03-19 01:51:51

کبھی عرش پر ، کبھی فرش پر
کبھی در بدر ، کبھی ان کے گھر 
غم عاشقی ، تیرا شکریہ 
میں کہاں کہاں سے گزر گیا.
کبھی راستوں میں تنھا 
کبھی رو بروے صحرا 
میں جنوں کا ہم سفر ہوں ، 
میرا کوئی گھر نہیں ہے..
Day 44: React Currency Converter
Tags: 100daysofcode, react, javascript
Published: 2021-03-19 00:34:12

```javascript
class App extends React.Component {

  render() {
    return /*#__PURE__*/(
      React.createElement(CurrencyConverter, null));

  }}


class CurrencyConverter extends React.Component {
  constructor() {
    super();

    this.state = {
      baseCurrency: 'GBP',
      convertToCurrency: 'USD',
      baseAmount: 100,
      rates: [],
      currencies: [] };


    this.changeBaseCurrency = this.changeBaseCurrency.bind(this);
    this.changeConvertToCurrency = this.changeConvertToCurrency.bind(this);
    this.changeBaseAmount = this.changeBaseAmount.bind(this);
    this.getConvertedCurrency = this.getConvertedCurrency.bind(this);
    this.callAPI = this.callAPI.bind(this);
  }

  componentDidMount() {
    this.callAPI(this.state.baseCurrency);
  }

  changeBaseCurrency(e) {
    this.setState({ baseCurrency: e.target.value });
    this.callAPI(e.target.value);

  }

  callAPI(base) {
    const api = `https://api.exchangeratesapi.io/latest?base=${base}`;

    fetch(api).
    then(results => {
      return results.json();
    }).then(data => this.setState({
      rates: data['rates'],
      currencies: Object.keys(data['rates']).sort() }));


  }


  changeConvertToCurrency(e) {
    this.setState({
      convertToCurrency: e.target.value });

  }

  changeBaseAmount(e) {
    this.setState({
      baseAmount: e.target.value });

  }

  getConvertedCurrency(baseAmount, convertToCurrency, rates) {
    return Number.parseFloat(baseAmount * rates[convertToCurrency]).toFixed(3);
  }

  render() {
    const { currencies, rates, baseCurrency, baseAmount, convertToCurrency } = this.state;

    const currencyChoice = currencies.map((currency) => /*#__PURE__*/
    React.createElement("option", { key: currency, value: currency }, " ", currency, " "));


    const result = this.getConvertedCurrency(baseAmount, convertToCurrency, rates);


    return /*#__PURE__*/(
      React.createElement("div", { className: "form-container" }, /*#__PURE__*/
      React.createElement("form", { className: "ui mini form" }, /*#__PURE__*/

      React.createElement("h3", null, "Convert from: ", baseCurrency), /*#__PURE__*/
      React.createElement("select", { value: baseCurrency, onChange: this.changeBaseCurrency },
      currencyChoice, /*#__PURE__*/
      React.createElement("option", null, baseCurrency)), /*#__PURE__*/


      React.createElement("h3", null, "Convert to: ", convertToCurrency), /*#__PURE__*/
      React.createElement("select", { value: convertToCurrency, onChange: this.changeConvertToCurrency },
      currencyChoice), /*#__PURE__*/


      React.createElement("h3", null, "Amount:"), /*#__PURE__*/
      React.createElement("input", { type: "number",
        id: "base-amount",
        defaultValue: baseAmount,
        onChange: this.changeBaseAmount })), /*#__PURE__*/


      React.createElement("h2", { id: "result-text" }, baseAmount, " ", baseCurrency, " is equal to ", result, " ", convertToCurrency)));


  }}



ReactDOM.render( /*#__PURE__*/
React.createElement(App, null),
document.getElementById('app'));
```
create a Modal System with Context API in React
Tags: react
Published: 2021-03-19 00:31:15

How to create a Modal System in React? 

React Portals might be good but personally I'd like to separate the Modals from Screens, because the order information is not fixed for a modal, yet push and pop actions have the order info naturally.

So I recommend using Context API to create a Modal System, here is my super rough demo code: https://codesandbox.io/s/suspicious-f...​

And here is a video explaining: 

https://www.youtube.com/watch?v=s20TOqXjVqk

Hope it helps.
Dataclasses in Python are nice!
Tags: python, beginners
Published: 2021-03-14 12:31:38

---
title: Dataclasses in Python are nice!
published: true
description: A small introduction to dataclasses feature in Python
tags: python, beginners
canonical_url: https://isabelcosta.github.io/posts/dataclasses-are-nice/
//cover_image: https://direct_url_to_image.jpg
---
Couple weeks ago I learned about [`dataclasses`](https://docs.python.org/3/library/dataclasses.html) feature in Python. This feature is a nice way to define classes in python. This was introduced in [Python 3.7](https://docs.python.org/3.7/whatsnew/3.7.html), in particular [PEP 557](https://www.python.org/dev/peps/pep-0557/). To use this feature make sure you are running python version 3.7 or above.

Previously, I knew about defining new classes in python using the `self.__init__()` function. Here's an example of me defining a class `Youtuber`.

```python
class Youtuber:
    def __init__(self, name: str, categories: list[str]):
        self.name = name
        self.categories = categories
```

Now we can use less boilerplate code to define classes. There is no need to install a separate python library, this will come with python standard library (as long as it's > 3.7).

Here's how you can define these now:
```python
from dataclasses import dataclass
 
@dataclass
class Youtuber:
   """Class for defining youtubers."""
   name: str
   categories: list[str]
```

In this example above, I am importing it first `from dataclasses import dataclass` and then defining it. I created a class definition and used `@dataclass` annotation to tell python how it should interpret this class definition.

Then I can create this in python, as I would do it anyway, regardless of using `@dataclass`:
```python
Youtuber("Chris Stuckmann", ["movie-reviews"])
```

Here's how you can try this out, using 3 of my favorite youtube channels :)
```python
youtubers = []
youtubers.append(Youtuber("Chris Stuckmann", ["movie-reviews"]))
youtubers.append(Youtuber("Double Toasted", ["movie-reviews"]))
youtubers.append(Youtuber("The Fitness Marshall", ["fitness"]))

for youtuber in youtubers:
    print(f"{youtuber.name}'s categories are: {youtuber.categories}")
```

Let's put this all together in a file called `youtubers.py` and run it! You can copy it from this [GitHub gist I created](https://gist.github.com/isabelcosta/c14c4c9a4a098a17807e5bda2df92ac3). You should get this output:
```
$ python youtubers.py  
Chris Stuckmann's categories are: ['movie-reviews']
Double Toasted's categories are: ['movie-reviews']
The Fitness Marshall's categories are: ['fitness']
```

Hope you enjoyed this short article!
You can find me on https://isabelcosta.github.io/
How to get the amount of free or available space using Node.js?
Tags: node
Published: 2021-03-19 00:00:00

---
  title: How to get the amount of free or available space using Node.js?
  published: true
  tags: Nodejs
  date: Fri Mar 19 2021 05:30:00 GMT+0530 (India Standard Time)
  canonical_url: https://melvingeorge.me/blog/get-amount-of-free-memory-os-nodejs
  cover_image: https://melvingeorge.me/_next/static/images/main-8cc3df25dcd3d9d9f358d59a2b3e4d4b.jpg
  ---
  [Originally posted here!](https://melvingeorge.me/blog/get-amount-of-free-memory-os-nodejs)
  
To get the amount of free or available memory space, you can use the `freemem()` method from the `os` module in Node.js.

```js
/* Get free memory space in Node.js */

// import os module
const os = require("os");

// check the available memory
const availableMemory = os.freemem();
```

- The method returns the available memory in `bytes` as `integers`.

See the above code live in [repl.it](https://replit.com/@melvin2016/get-free-memory-nodejs).

### Feel free to share if you found this useful 😃.

---
Humans are Turing complete
Tags: computerscience, devops, automation
Published: 2021-03-19 14:31:12

---
title: Humans are Turing complete
published: true
date: 2021-03-19 00:00:00 UTC
tags: computerscience, devops, automation
canonical_url: https://jhall.io/archive/2021/03/19/humans-are-turing-complete/
---

I want to propose an idea that’s so obvious that I think almost everyone misses its implications:

**Humans are Turing complete**

[![](https://jhall.io/archive/images/turing-machine.jpg)](https://simple.wikipedia.org/wiki/Turing_machine#/media/File:Turing_Machine_Model_Davey_2012.jpg)

What is Turing complete?

The concept, derived from the conceptual [Turing machine](https://en.wikipedia.org/wiki/Turing_machine), as described by [Wikipedia](https://en.wikipedia.org/wiki/Turing_completeness):

> [A] system of data-manipulation rules is said to be **Turing-complete** or **computationally universal** if it can be used to simulate any Turing machine.

We use this concept when describing programming languages, as a sort of litmus test for their completeness. Somewhat famously, [CSS is Turing-complete](https://stackoverflow.com/a/5239256/13860), which I guess angers some people, but I digress…

The point I want to make about humans being Turing complete is this:

Any task we can automate can be performed by a human (albeit, generally more slowly). This is probably pretty obvious, but has some interesting implications, like the idea that [we can do Continuous Deployment without any automated tests](https://jhall.io/posts/cd-without-ci/).
Humbug: Usage and crash reports for Python developer tools
Tags: showdev, python, analytics, devrel
Published: 2021-03-18 23:44:55

Developer tools are unlike any other kind of software. All your users are power users. This blurs the line between your users and your code.

GitHub issues and Slack conversations are a poor guide to real usage of your software. Only a small proportion of the people who ever used your tool will be motivated enough to speak with you through these channels. The issues that these users have may not be representative of the real issues - the ones, for example, that drive people away from your "Getting started" guide.

At https://bugout.dev, we are building a huge knowledge base of bugfixes to help developers overcome issues with the tools and libraries they depend on. We are also trying to help developer tool maintainers gain a better understanding of how their users use their software.

We have taken a big step forward this week with the release of [Humbug](https://github.com/bugout-dev/humbug), which helps developer tool maintainers collect usage and crash reports from their users **only with their full consent**.

Here is a short video showing how to use Humbug in your Python developer tool:
{% youtube -k2c8o_sXC4 %}

Find out more about how to set up Humbug on the GitHub repository:
{% github bugout-dev/humbug %}

Go and Javascript support are coming soon!
In which I Sing the Praises of Redux Toolkit
Published: 2021-03-18 21:52:21

Using Redux to store data that will be used across components has obvious advantages, but it also comes with some specific (at least potential) drawbacks.

Configuring, accessing, and updating the store all become significantly more dense as the store grows. This leads to an increasingly complex configuration and larger and larger chunks of boilerplate, not to mention the increase in potential for bugs that could become harder to trackdown in a dense and not inherently well managed codebase.

Enter Redux Toolkit. 

**First let's talk about some bonuses:**

* Redux Toolkit adds an immutability (courtesy of Immer) layer to take some of the mental overhead out of writing dispatches

* Redux Toolkit by default utilizes Redux Devtools to make it easy to view state and its changes during development. 

Redux Toolkit makes it easy to configure the store and easy to access and update only the parts of the store that any component needs to interact with. Each top-level segment of the store can be extracted to its own file, and much of the boilerplate can be abstracted away. These segments are referred to as [slices](https://redux-toolkit.js.org/api/createSlice). By thinking of each of these as their own mini store, and compartmentalizing them, we can separate the concerns of the various parts of the store and then bring them together easily when we [configureStore](https://redux-toolkit.js.org/api/configureStore). Since we can do so without the need for a root reducer, any troubleshooting later is that little bit less taxing. 

By bringing convention to the whole system, we can more quickly navigate to the code we're looking for, and make modifications to the codebase with less lines of code and less potential for errors. Those cleaner sections of code will also be easier for other developers to find, understand, and add to later. Our system will be easier to develop with, since we can use Redux DevTools to watch our state.

I realize I haven't shown any references in this post, that's because I could not hope to give a better understanding of using Redux Toolkit than the documentation does by going through [a sample project](https://redux-toolkit.js.org/tutorials/quick-start). Please, if you are starting a project and plan to use Redux, have a look at Redux Toolkit. Consider if it's right for your project. The ease of use, scalability, and convenience have absolutely made me a fan.
Toward an inclusive language in IT 🦸
Tags: career, a11y, writing, devops
Published: 2021-04-02 00:01:08

---
title: Toward an inclusive language in IT 🦸
published: true
date: 2021-03-18 23:15:00 UTC
tags: career, a11y, writing, devops
canonical_url: https://www.benjaminrancourt.ca/toward-an-inclusive-language-in-it
cover_image: https://www.benjaminrancourt.ca/temp/toward-an-inclusive-language-in-it.2274.jpg
---
Last month, the _Human Resources Department_ at my work (_[Université de Sherbrooke](https://www.usherbrooke.ca/)_) [announced](https://www.usherbrooke.ca/bulletins/version-web/10245/gestionnaires-lancement-de-la-campagne-institutionnelle-ensemble-contre-la-discrimination/8cc9aa7b7637a) that it would launch a new information campaign **against discrimination** in the coming weeks.

It got me thinking on how my department, the _[Information Technology Department](https://www.usherbrooke.ca/sti/)_, could get involved and add its _grain of salt_ to this campaign. So I remembered that last year, a lot of big compagnies (like [Twitter](https://twitter.com/twittereng/status/1278733305190342656) and [GitHub](https://www.cnet.com/news/microsofts-github-is-removing-coding-terms-like-master-and-slave/)) had started **replacing some terms** that were not really correct in 2020, like the words _master_ and _slave_.

At that time, I was not really paying attention to these actions as they did not seem to echo in Quebec, but I still added a mental note to myself that I should read more on that subject when I had the chance.

So I decided to take the necessary time to familiarize myself more on this subject and I quickly ask my general manager if we could take advantage of this new campaign to make our colleagues aware of these terms and start replacing some of these words with more **inclusive terms**. 🧑‍🤝‍🧑

Understandably in the COVID-19 context, I have no news yet on my proposal. 🤷‍♂️ But, I will **personally** start using more inclusive terms and gradually replace non-inclusive words in my personal projects from now on.

I have therefore chosen to replace the following terms that I frequently encounter on a weekly basis:

- whitelist / blacklist 🡒 **allowlist** / **denylist**
- [Database] master / slave 🡒 **primary** / **replica**
- [Git] master 🡒 **main**

Therefore, for my colleagues, do not be surprised if I use (and stick to) these words! 😉

I know it is only a small step, but we have to start somewhere, right? If you are interested in learning more about **inclusive language** , I recommend reading the excellent article [_How to Use & Promote Inclusive Language at Your Organization_](https://blog.hubspot.com/marketing/inclusive-language) by Caroline Forsey at HubSpot.

Have you personally started to use a more inclusive language?

> Psst! If you have **Git >= 2.28** , you can now configure it to create the initial branch with an alternate name instead of `master` with the following Bash command: `git config --global init.defaultBranch main`.
Benarkah Kerajaan Salakanagara ada ?
Published: 2021-03-18 22:42:50

Perdebatan terjadi di dunia pendidikan, terutama dalam materi pelajaran sejarah. Di mana para peneliti saling berbeda pendapat mengenai kerajaan tertua di Nusantara.
Sebagian orang tetap dengan pendirian mereka jika kerajaan pertama di Nusantara adalah kerajaan Kutai Martapura, tapi sebagian lagi memiliki Jawaban lain, yaitu kerajaan Salakanagara.
Kerajaan Salakanagara adalah kerajaan yang katanya berdiri pada  sekitar abad 2 Masehi, sedangkan kerajaan Kutai hadir pada tahun 400 M
Kerajaan ini berasal dari daerah Pandeglang, di Jawa Barat yang katanya pula menjadi awal dari beberapa kerajaan di Jawa barat seperti Kerajaan Tarumanagara dan Kerajaan Sunda Galuh.
Sampai saat ini, masih sedikit bukti konkrit tentang kerajaan ini.

Sumber : https://ilmusaku.com/fakta-kerajaan-salakanagara-yang-misterius/