teleren/devto huggingface dataset:
Create a Discord Bot in Minutes with Python
Tags: tutorial, python, programming, webdev
Published: 2021-11-11 14:48:03

Written by Lior Ben David. 

---

If there's any platform that's become the darling of online communities, it's Discord. Its intuitive UX, vibrant communities, and diverse feature set have allowed it to grow rapidly over the 6 years.

Among developers at least, a lot of the love for Discord comes from its high programmability. In this tutorial, we are going to be making a simple Discord Bot with Python that you can add to your servers.

---

###Setting Up Your Bot in the Developer Portal

To get started, first head to

https://discord.com/developers/applications

And Create a New Application

From there, head to the "Bot" tab and create a new bot.
Finally, to add our bot to a server, go to the oAuth2 tab, scroll down to scopes, check bot and visit the generated URL.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0fs7qd66s53m86kqeivd.gif)

You can then select the server you want to add the bot to and you should see it on your server under offline users

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

That's all we need to do from the Discord side!

---

###Project Setup

Now let's code our bot.
First, install discord.py with:

`pip install discord`

And create a new file called `main.py`

We can then authenticate our discord like so:


{% gist https://gist.github.com/LiorB-D/3531c79498bef68dee5b737edf39820e %}

You can find your authentication token in the Bot Tab in your developer portal

---

###Responding to Messages

Now let's read and respond to messages that people send in channels

{% gist https://gist.github.com/LiorB-D/3f92e04b18a65c2054f00b3f6dc151a5 %}

We need to include the bot.process_commands at the end in order to make sure the bot also checks if the message is a valid command.

And here you can see it working:

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

---

###Creating Commands
Now let's add commands. Commands are just responses that are specifically invoked. We designated at the beginning that each command has to start with '!', which will act as the "Alexa" to start listening for a command.

We are going to add two commands, one that returns the square of a number, and one that tells us the scrabble points for a specific word.

{% gist https://gist.github.com/LiorB-D/0b601976a382df93e7d272269ea3b03a %}

And here we can see it working!

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

### Deploying Your Bot

Now, of course, you're not going to want to be running your script from your local machine 24/7. That's why it's crucial to deploy your script in the cloud.

If you want to skip the whole cumbersome cloud setup process, try out [Codesphere](https://link.codesphere.com/FS). On Codesphere, you can just import your project and run it from a virtual machine as if it was being deployed locally.

It only takes minutes to deploy!

So what are you going to build? Let us know down below!
Creating a new language for logic circuits
Tags: javascript, node, verilog, opensource
Published: 2021-11-11 13:45:39

Building electronic circuits can be difficult especially the bigger ones,as there is no printf to check if wire is properly connected. Being an electrical engineering ,I have tried to build tools that would help understand and design electronics faster and better. [Chip.io](https://play.google.com/store/apps/details?id=com.Codnet.ChipdotIO) 
 is one such android app that would give a virtual experience of using a 8085 trainer kit.
 
But in this project I want something more complex😈, 
something like a code that would define a logic circuit. I know what you are going say now, there is verilog for that ?  Ya ,there is .. but in my opinion it could be made more simpler and easy to use. More over my main focus is not to create a language to program a FPGA, instead to a language to define a logic circuit for simulation, so I believe there could some compromises which I could utilise to make it more understandable.

However, I don't discourage the possibility of using it to program integrated circuits🤔.

### How is it implemented?
It's basically a nodejs project which utilizes nearley and Moo to parse the code which is then converted to a particular javascript format that simulates logic circuit.
### Where it started?
All of this began while I was trying to design a circuit in [logisim](http://www.cburch.com/logisim/) and was not able to do in the way I wanted it to be. Also at that time i had already started messing out with lexer and parsers, which finally led to this project. 

### Milestones 🗿 and targets
* Build an interpreter that can run the code
* Multiple libraries that implements complex circuits.
* A graphic interface which can generate the code by drag n drop ( Similar to logisim )
* Ability to program integrated circuits ( sometimes 😜)

#Sample program
Let me show you a sample of the program
```javascript
module HalfAdder([a,b]=>[s,c])
{
    init{
        [s] = [0];
        [c] = [0];
    }
    process {
        [s] = XOR([a,b]);
        [c] = AND([a,b]);
    }
}
HalfAdder Adder;

Input [A] = [0];
Input [B] = [0];
Output [S];
Output [C];

wire(A => Adder.a);
wire(B => Adder.b);
wire(Adder.s => S);
wire(Adder.c => C);

```
And this would produce a circuit like 
![logic circuit](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aqtszovviio4kvrayo54.png)


### Explanation
> I don't want to go deep into the explanation but in simple terms we created a blue print for HalfAdder ,whose inputs are a and b, outputs are s and c. After which we instantiated a HalfAdder ( as Adder) which is connected to input ports A and B , Output Ports S and C


Any suggestions and feedbacks is greatly appreciated.
Thank you ❤️ for reading.
Hi, I'm Do Hai Duong
Published: 2021-11-11 14:42:25

I have been coding for 5 years, I am a student who's actively involved in several open source projects.

You can find me on GitHub at HDuong1803

You can also find me on Twitter as @haiduongdev 

I live in Ha Noi, Viet Nam.

I mostly program in these languages: C/C++, Java, SQL.

I am currently learning more about Spring Framework.

Nice to meet you.
Format date in JS/React without any Library.
Tags: javascript, react, tutorial, beginners
Published: 2021-11-11 14:41:52

This is a simple utility function that I wrote for my Ecommerce Dashboard it takes the unformatted standard ISO 8601 date time string and formats it into a more readable format. 

Something like this 
![readable date format](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f1tay0aq8ewlkx3s7a1z.png)

So lets get started. 
Create a new .js file called`getDateHandler.js`

```
export default function getDateHandler(date) {
    const months = [
        "Jan",
        "Feb",
        "Mar",
        "Apr",
        "May",
        "Jun",
        "Jul",
        "Aug",
        "Sep",
        "Oct",
        "Nov",
        "Dec",
    ];
    const newDate = new Date(date);
    const getMonth = months[newDate.getMonth()];
    
    let time;
    if (newDate.getDate() === new Date().getDate()) {
        time = `${newDate.getHours()}:${newDate.getMinutes()}`;
    }
//What this does is if the current date matches the date entered it displays the time else it displays the date
    const fomattedDate = time
        ? ` Today at ${time}`
        : `${getMonth} ${newDate.getDate()}, ${newDate.getFullYear()}`;
    
    return fomattedDate;
}
``` 
Using the above function is simple. Import it into wherever you need to use it. In my case within a order map function in react. wrap the function around the date that requires formatting. `getDateHandler("2021-11-04T08:37:13.099+00:00")`


Below you can see a demo of how it works. 
 
```
import React from "react";
import getDateHandler from "../utils/getDateHandler";

export default function UsingDateFormatScreen(props) {
    const createdAt="2021-11-04T08:37:13.099+00:00";
    return (
    <div>
      <h1>Example Date : <br /> {getDateHandler(createdAt)} </h1>
    </div>
  );
}

```

Do let me know if you found this useful :)

{% codesandbox 0hwym %}
UI Dev Newsletter #82
Tags: html, css, javascript, webdev
Published: 2021-11-11 14:06:22

## Links


[Transitions](https://bit.ly/3bQSRO2)
Chrome Developers share a module where you will learn how to define transitions between states of an element and use transitions to improve user experience by providing visual feedback to user interaction.


[Developer Tools secrets that shouldn’t be secrets](https://bit.ly/3wpyil3)
Christian Heilmann shares DevTools tips that could help you log and debug your code more efficiently.


[A Deep Dive Into object-fit And background-size In CSS](https://bit.ly/303i7h2)
Ahmad Shadeed explains how object-fit and background-size work, when and why we can use them and discusses practical use cases and recommendations.


[Favicons: How to Make Sure Browsers Only Download the SVG Version](https://bit.ly/3BTSUDl)
Chris Coyier explains how to prevent browsers from downloading both .ico and .svg icons by adding sizes attribute.


[Record, replay and measure user flows](https://bit.ly/3CWyD13)
Jecelyn Yeen introduces User Flows support in Chrome DevTools and Lighthouse to help you record, replay, and measure interactions beyond page load.


[Lazy loading JS by visibility](https://bit.ly/3COsP9T)
Jonathan Neal shares Fred K. Schott’s solution for dynamically loading JS using “Islands Architecture,” a strategy where small HTML placeholders are progressively upgraded with dynamic or interactive content as needed.


[Parametric Color Mixer](https://bit.ly/3ETTcfm)
Dawid Woldu shares a color palette composer inspired by audio parametric equalizers to create beautiful color palettes with scientific precision.


[Happy Hues](https://bit.ly/3bOB3De)
Mackenzie Child shares color palettes where every color gives you the context of how that color could be used for your design or illustration projects, plus an explanation of color terminology and the psychology of color.


## Popular on Twitter

[What HTML tag do you use to mark up Kicker/Eyebrow/Whatever?](https://bit.ly/3bOB4qM)
Brad Frost asks questions about those text elements that appear above the title but are styled like standard text or smaller.

## Discussion

[Can you solve this interview problem?](https://bit.ly/3kfhN6m)
Shuvo shares a (ridiculous) question from his interview. It might be worth reading the comment section, too.


**Happy coding!**

[Subscribe to the newsletter here!](https://buttondown.email/starbist)
Articulate Storyline 3 vs Adobe Captivate vs iSpring Suite Max
Published: 2021-11-11 13:56:11

I found an interesting post comparing the three most popular solutions for building eLearning online courses. Read here: [https://www.ispringsolutions.com/blog/adobe-captivate-9-vs-articulate-storyline-2-vs-ispring-suite-8-1](https://www.ispringsolutions.com/blog/adobe-captivate-9-vs-articulate-storyline-2-vs-ispring-suite-8-1)
Sample code for Deno 1.16 (Fetching file URLs & New unstable signal listener API)
Tags: deno
Published: 2021-11-11 13:54:43

Deno 1.16 has been released.

[Deno 1.16 Release Notes](https://deno.com/blog/v1.16)

In this article, I will write a sample on two features included in the 1.16 release of Deno.

## fetch now supports fetching file URLs

Starting from 1.16, fetch can be used to read files from the local file system.
When reading a file, the path must be an absolute path starting with `file://`.

The file contents are read in chunks, so it seems that file units can be used without reading them into memory.
According to the release notes, this is the best way to stream large files over HTTP.

First, I have writting a simple sample that just reads a local file.

First, prepare the file `hello.txt`.

```
hello world!
```

Next, I will write a sample code using fetch.
The file path should be written as a full path, but it is omitted here.

```typescript
// sample.ts
const resp = await fetch('file:///Users/~/hello.txt');
const text = await resp.text();
console.log({text});
```

Run this code.

```sh
deno run --allow-read sample.ts
```

The output will look something like this.

```
{ text: "hello world!\n" }
```


### With import.meta.url

However, as mentioned in the official release notes, you can specify the path relatively by using `import.meta.url`.

(If you use `import.meta.url`, you can specify the file path by using the method starting with `file://`, so you can specify the file path directly using this method.)

I have rewritting the above code using `import.meta.url`.

```typescript
import { dirname, join } from 'https://deno.land/std/path/mod.ts'

const filePath = join(dirname(import.meta.url), 'hello.txt');

const resp = await fetch(filePath);
const text = await resp.text();
console.log({text});
```

Please refer to the release notes for more details on the behavior.

## New unstable signal listener API

It seems that a new (and unstable) API for reading OS signals has been added.

As the name "unstable" implies, it seems to be in an experimental stage and may be changed in the future, so be careful when using it.

It is said to be a replacement for the existing Deno.signals API.

I have written a simple sample code to terminate the process with `Ctrl + C`.

```typescript
// sample.ts
const listener = () => {
  console.log("SIGINT!");
  Deno.exit();
};

const sleep = (sec: number) => {
  return new Promise((resolve) => setTimeout(resolve, sec * 1000));
};

Deno.addSignalListener("SIGINT", listener);

let count = 0;
for (const _ of Array(10)) {
  count++;
  console.log(count);
  await sleep(1);
}

Deno.removeSignalListener("SIGINT", listener);
```

Run this code.

```sh
deno run --unstable sample.ts
```

In this sample, the numbers are displayed every second, and you can see that the process can be interrupted by pressing `Ctrl + C`.
Circuit Breaker Pattern in 30 seconds
Tags: cloud, programming, tutorial, architecture
Published: 2021-11-11 13:47:00

In a microservice architecture, remote services may be unavailable for a long time. Retrying a request won’t help in this case.

The Circuit Breaker pattern offers a solution to this problem.

The CB has three states: *closed*, *half-open*, and *open*.

- It starts in *closed* state. Your service executes all calls to the remote service.
- CB switches to *open* if many requests fail. Your service starts a timer and does not execute any calls to the service. It returns a default answer or throws an exception instead.
- CB switches to *half-open* when the timer is up. Your service executes a fraction of the calls. If all pass, it switches to “closed”. If one fails, it switches to “open” again and restarts the timer.

To summarize, the Circuit Breaker prevents the execution of calls which are doomed to fail. Look [here](https://docs.microsoft.com/en-us/azure/architecture/patterns)/circuit-breaker) for more information.

[Learn four more patterns here!](https://verbosemode.dev/4-really-helpful-and-important-cloud-design-patterns-explained-in-short-time-4b087bebb97b)

[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/Y8Y1EKYJI)
What are your tips to success in migration from SVN to GIT ?
Tags: svn, git, beginners
Published: 2021-11-11 13:45:49

I all for my first post in DEV i  will need your help.

In the next days i will be in charge of the migration of all our software project (more than 15 years of development) from svn to git. This will be a big change and a lot of work. 

So I open a thread here to get advice form your if you have already experience this type of migration to get this project a success and not a highway to hell.



Thanks all.
Completed Hacktoberfest 2021
Tags: hacktoberfest, hacktoberfest2021, digitalocean, devops
Published: 2021-11-11 13:17:14

IT WAS A GREAT EXPERIENCE TO DO THE HACKTOBERFEST CONTEST,I HAD LEARNT MANY THINGS DURING THE TIME OF HACKTOBERFEST LIKE HOW TO RUN GITHUB,HOW TO MAKE PULL REQUEST,HOW TO MAKE CONTRIBUTION IN A REPO AND MANY MORE THING SO THANKYOU DIGITAL OCEAN AND VARIOUS OTHER ORGANISATION FOR GIVING ME THE WONDERFULL OPPORTUNITY.
Best Java IDEs
Tags: java, ide, programming, tutorial
Published: 2021-11-11 13:16:32

Java is perhaps the most impressive and flexible programming language. A significant number of the work area programming and practically all the Android applications that you are utilizing are made utilizing Java. Since its introduction to the world in 1995, Java has overwhelmed the programming scene.

However numerous specialists currently accept that Java doesn’t have an extremely brilliant future, we suspect something. There are numerous business and free Java IDEs accessible, and here we will talk about the best Java IDE to use in 2022.

![java IDEs](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ruazxx432fjom6v9j0qr.png)

[Best Java IDE](https://www.techgeekbuzz.com/best-java-ides/) for Java Coding

1. Eclipse

![Eclipse](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c38gr9pvgy00ybyzb9nu.png)

2. IntelliJ IDEA

![IntelliJ IDEA](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a4ymok1cmir9xy5kr9k6.png)
 
3. BlueJ

![BlueJ](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x5dajs75yagt1nzzbsra.png)

4. DrJava

![DrJava](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ng49l51ne0p8j7f5qsid.png)

5. MyEclipse

![MyEclipse](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/brz6u0do9jn70ggetj1z.png)

6. JDeveloper

![JDeveloper](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hbh0p0dycikg11icsja8.png)

7. NetBeans

![NetBeans](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ccx5iq5h441uaeaqsbn7.png)

8. JCreator

![JCreator](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/32wcjxxl56iq8y405yyj.png)

9. jGRASP

![jGRASP](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8zdykymlb6ivbii2215c.png)

10. Greenfoot

![Greenfoot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ovx3m1y5l8c4vufpv52z.png)

## Conclusion

That sums up our list of the best Java IDEs. There are many Java IDEs, but these are the best ones to program and develop software in Java.
Getting Started with Java - Installation
Tags: java, codenewbie, programming, tutorial
Published: 2021-11-11 13:15:52

You can install the latest version of java for Windows and macOS from its official site. For Linux-based distributions command line is the recommended option. Follow the instructions:
- Install java for [MacOS](https://www.oracle.com/java/technologies/downloads/#jdk17-mac)
- Install java for [Windows](https://www.oracle.com/java/technologies/downloads/#jdk17-windows)
- Install java for [linux](https://www.oracle.com/java/technologies/downloads/#jdk17-linux)
Note: Though you can download and install JDK for Linux from the official site, I would highly recommend you to use the official package manager for your distribution.

#### Java on Linux distributions
- Ubuntu, Debian, and distributions that use **apt** as the package manager
    Open your terminal and follow the guide

    Update the package index
    ```
    $ sudo apt-get update
    ```
    Check if Java is not already installed:
    ```
    $ java --version
    ```
    If Java is already installed we'll get output similar to below
    ```
    openjdk 17.0.1 2021-10-19
    OpenJDK Runtime Environment (build 17.0.1+12)
    OpenJDK 64-Bit Server VM (build 17.0.1+12, mixed mode)
    ```
    If not, then install java
    ```
    $ sudo apt-get install default-jdk
    ```
- For arch and arch-based distributions

    Update the system
    ```
    $ sudo pacman -Syyu
    ```
    Check if Java is not already installed:
    ```
    $ java --version
    ```
    Search for available JRE in the arch repository
    ```
    $ pacman -Ss java | grep jre
    ```
    ![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1636607547791/t-klDRH8W.png)
    Install the latest jre
    ```
    $ sudo pacman -S jre-openjdk
    ```
    Similarly, search for the latest JDK and install it
    ```
    $ pacman -Ss java | grep jdk
    ```
    ![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1636607674128/WRL8RwQJ4.png)
    ```
    $ sudo pacman -S jdk-openjdk
    ```
The next thing you may want to install is an Integrated Development Environment (IDE). There are so many IDE's available for Java development. One of the best being [IntelliJ IDEA](https://www.jetbrains.com/idea/download). You may even consider setting a Java Development Environment in your preferred text editor such as [VSCode](https://code.visualstudio.com/) or [Atom](https://atom.io/), etc. I leave these things to your liking.

That's all for this one. Feel free to connect with me
[![Twitter logo](https://img.shields.io/badge/Twitter-Profile-informational?style=flat&logo=twitter&logoColor=white&color=1CA2F1)](https://twitter.com/Raj_Pansuriya7)

[![LinkedIn Badge](https://img.shields.io/badge/LinkedIn-Profile-informational?style=flat&logo=linkedin&logoColor=white&color=0D76A8)](https://www.linkedin.com/in/raj-pansuriya/)
Workflow to apply a Eslint check before merging the Pull Request
Tags: actionshackathon21
Published: 2021-11-11 12:53:38

### Submission Category: Maintainer Must-Haves

If you have a javascript based projects, then maintainers must check code quality through eslint checks before merging the PRs.

### My Workflow

```
name: Check ESLint on Pull Request

on:
  pull_request:
    branches: [ main ]

jobs:
  fix:
    runs-on: ubuntu-latest
    steps:
      - name: Check out Git repository
        uses: actions/checkout@v2
      - name: installing eslint 
        run: npm i -g eslint
      - name: Fixing Files
        run: eslint . --ext .js --fix
```
Mantenimiento del Sistema, Parte 2
Tags: mantenimientodelsitema, soporte, reingenieria, software
Published: 2021-11-11 12:48:33

Los 5 aspectos claves del Mantenimiento del Sistema de acuerdo a la lectura del capítulo 29 del libro de Ingeniería de Software Un Enfoque Práctico, séptima edición de Roger Pressman, en mi opinión son:

**Soportabilidad del Software**
Los sistemas deben ser desarrollados pensados con la capacidad de permitir modificaciones, realizar integraciones con otros sistemas, poder migrar a una versión mas reciente de algun componente interno del sistema o externo, tener la capacidad de ejecutrse en diversos entornos, etc.

**Reingenieria de Software**
Debido a las constantes modificaciones realizadas a un sistema, ya sea por fallas reportadas, mejoras a los procesos del sistema, optimizar el rendimiento, etc. El area de TI debe evaluar la opción de realizar una reingeniería en el software, es decir reconstruir el artefacto de manera que el funcionamiento sea el óptimo.

**Reestructuración de código**
Se lleva acabo para escibir código con mayor claridad conservando la misma funcionalidad que el programa original, una de las tecnicas que se emplea es la simplificación ed lógica, ademas con la reestructuración de código se busca tener un minimo de aclopamiento entre módulos.

**Reingeniería inversa de interfaces de usuario**
Una interfaz es la forma en que el usaurio ingresa los datos al ssitema, es por eso que considero que es un tema importante, ya que la GUI es el medio por el cual se almacenan los datos al sitema, de forma correcta o incorrecta segun sea su nivel de restricciones. Se debe comprender la función de la interfaz de usuario para poder realizar una adecuada reingeniería inversa de la GUI

**Reingenireía de procesos de empresa**
Importante aspecto ya que dentro de la empresa, personal, recursos materiales, equipo etc. se combinan para producir un resultado específico, que luego se deberá plasmar en la creación de un sistema empresarial.