teleren/devto huggingface dataset:
What is Clean Code? How to Write - 2020
Tags: codenewbie, writing, computerscience
Published: 2020-11-28 17:12:55

The more complex and longer the codes are, the more it reduces the productivity of the software developers. Complicated programs emerge when teams and people work together in harmony. While the people in the project are in control of the project detail, the people who will be involved in the project after the field are unaware of the code structure of the project. The person involved in the post must first read and understand the existing codes in order to benefit the project. At this point, clean code enters the circuit.
Source:https://sirnode.com/what-is-clean-code-how-to-write-2020
Anonymous Generator in PHP
Tags: php, code
Published: 2020-11-28 16:37:26

Recently, I wanted to create an anonymous generator. The good news is that it is possible, the syntax is not the most obvious one, though.
You need to use a technique called **"immediately invoked function expression"** mostly known from JavaScript of the jQuery era.

Here it is:
```php
$iterable = (function (): Generator {
  yield 42; // yield any number of values
})();
```
<!-- 
  yield 33;
  yield from ['5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0',]; -->

Explanation:
1. the anonymous function itself is not a generator, it's just a callable and can not be iterated over
2. the function is invoked immediately after it is created and must be enclosed in parentheses `(function(){ ... })()` if we want to invoke it right away
3. the invocation results in a Generator, which can be iterated over
```php
$func = function(): Generator { yield 42; };
$iterable = $func(); // this is when the generator is created

foreach($func as $item){ }     // error, $foo is not iterable
foreach($iterable as $item){ } // iterates over the generator
```

Generators have been in PHP since version `5.5`. I have since used them rarely, but they are good for solving some edge cases, like _generating_ a sequence of unknown length.

A generator can be used to replace code like the one below. Yeah, for two items it might be useless, but for multiple such extractors it does make sense. Especially when you know only the first extractor will be used in 99% of cases.

```php
function getDefaultExtractors(
  string $headerName, 
  string $cookieName
): iterable {
  #<  code here  >#
  return $extractors;
}
```

Code with `if`s and array push:
```php
$extractors = [];
if ($headerName !== null) {
  $extractors[] = Make::headerExtractor($headerName);
}
if ($cookieName !== null) {
  $extractors[] = Make::cookieExtractor($cookieName);
}
```

Code with `array_filter` and ternaries:
```php
$extractors = array_filter([
  $headerName !== null ? Make::headerExtractor($headerName) : null,
  $cookieName !== null ? Make::cookieExtractor($cookieName) : null,
]);
```

Code using a generator:
```php
$extractors = (function () use ($headerName, $cookieName): Generator {
  $headerName !== null && yield Make::headerExtractor($headerName);
  $cookieName !== null && yield Make::cookieExtractor($cookieName);
})(),
```


The key idea behind the generators is that the execution is actually paused on each `yield` statement, until the next iteration is initiated. For cases where the iteration is interrupted before all of the generated items are consumed, this saves some computation resources.


<!-- https://stackoverflow.com/questions/44869934/generator-cannot-be-in-a-closure -->
How to hash a password before save into DB with JavaScript and bcrypt.
Published: 2020-11-28 16:30:11

When you save data from users, such as username, email, phone numbers, and other data, is usually save these data in plain text, however, for user passwords, it is not secure, because, if your DB is compromised, all passwords its exposes.

So, hash all password before save into DB,  usually is a good practice. bcrypt, is a JavaScript Library for this propose. 

Remember init your npm project with npm init and install the library with npm install bcrypt. 

Now implement your library. 

```javascript
const bcrypt = require('bcrypt'); // import the Library. 
const saltRounds = 10; // The number of rounds for encrypt the passwords. 
const myPlaintextPassword = 'examplePassword';

// Now, use bcrypt for encrypt the plain Password. 

bcrypt.hash(myPlaintextPassword, saltRounds, function(err, hash) {
    // Store hash in your password DB.
    console.log(hash); 
});

``` 
If you need compare un plain Password with your saved password, you can use the function compare. 

```javascript
bcrypt.compare(myPlaintextPassword, hash, function(err, result) {
    // result == true
if(result==true){
 // The Password is Correct!
}
else {
 // Your password is not correct. 
}
});

``` 

It's All, 

Thanks!
Best Light Weight Code Editor's For Developer's.
Tags: python, javascript, css, vscode
Published: 2020-11-28 16:27:20

![Sublime Text](https://dev-to-uploads.s3.amazonaws.com/i/y17e30lcblacgi46qtr1.jpg)
<h3>Many of us loves to use light weight code editors rather than using heavy weight IDE's. Light weight code editors are really useful for beginners and also for those who have a low end PC but want to code.</h3>
<h4>How will this post help you??</h4>
<h5>If you have a low end pc or you don't want to use any IDE & looking for a good code editor then this blog can help you, in here I'll be telling you about some good code editors you can use.</h5>

<h2>1. Sublime Text</h2>
![Sublime Text](https://dev-to-uploads.s3.amazonaws.com/i/42rgqbvxtzedcww8lbzv.jpg)

<h4>Sublime Text is one of the best code editor's that I would recommend you if you even have a really slow PC than also Sublime Text will work super smoothly without any lag, Sublime Text has a huge support for packages to install + it support's multiple coding language's such as Java, JavaScript, Python, C/C++, and many more, the list is big.</h4>

<a href="https://www.sublimetext.com/">Download Sublime Text</a>

<h2>2. Visual Studio Code</h2>
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/k6d041ugqu2i5du5aj2p.jpg)

<h4>VS Code is a open source code editor developed by Microsoft. It is a free code editor with support for multiple languages, you just need to download extension for it and you are good to go. VS Code has it's own market place where you can get multiple extensions like Flutter, Dart, Python, etc. It's also a favorite code editor of many developers. It's an code editor with features of an IDE.</h4>

<a href="https://code.visualstudio.com/">Download VS Code</a>

<h2>3. Notepad++</h2>
![Notepad++](https://notepad-plus-plus.org/assets/images/notepad4ever.gif)

<h4>As I told this blog contains some best Code Editor's, So here's another one and it's the best one for low end/slow pc's. Notepad++ is a free source code editor and Notepad replacement that supports several languages. Running in the MS Windows environment, its use is governed by GNU General Public License. This editor is written in C++ and this also ensures you have a good executing speed & and also uses very low CPU power.</h4>

<a href="https://notepad-plus-plus.org/">Download Notepad ++</a>

<h2>4. Brackets</h2>
![Brackets](https://dev-to-uploads.s3.amazonaws.com/i/i3zgv896o9wwadfd7eet.png)

<h4>Bracket's is a light weight open source code editor, it's made for developer's by developer's like you. You can use this code editor to do web development and it also support's live server which allows you to edit your website and see the changes live and like this it has many other awesome feature's.</h4>

<a href="http://brackets.io/">Download Bracket's</a>
<hr>

<h3>My personal favorite code editor's are VS Code & Sublime Text. Those are my personal choice. They are also my recommendation.</h3>
Trying to implement Facebook Conceal method for saving encrypted password but didn't work?
Published: 2020-11-28 16:24:17



Trying to implement facebook conceal to save encrypted passwords, i removed all errors and android app runs but as i used insert method in Registration so when i click the registration button the app stops working. Before adding the crypto code the app was working fine and was saving passwords.

    public boolean insert(String email, String password, String uName, String pNo){
    SQLiteDatabase db =this.getWritableDatabase();
    Crypto crypto = new Crypto(new SharedPrefsBackedKeyChain(this,CryptoConfig.KEY_256),
            new SystemNativeCryptoLibrary(), CryptoConfig.KEY_256);
    byte[] cipherText =null;
    try {
        cipherText = crypto.encrypt(password.getBytes(),entity);
    } catch (KeyChainException e) {
        e.printStackTrace();
    } catch (CryptoInitializationException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    ContentValues contentValues = new ContentValues();
    contentValues.put("Email", email);

    String finalString = null;
    try {
        finalString = new String(cipherText, "ISO-8859-1");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    contentValues.put("Password", finalString);
    contentValues.put("UserName", uName);
    contentValues.put("PhoneNumber", pNo);
    long ins =db.insert("userTable", null, contentValues);
    if(ins==-1) return false;
    else return true;
}
Show current time using JavaScript
Tags: html, css, javascript, cwb
Published: 2020-11-28 16:08:29

Show current time is made with HTML, CSS and JS. They are usually used to show Time on our website. When a div shows time, it gives your site a nice look.
<a href="https://www.codewithbishal.com/how-to-get-the-current-time-javascript"> View it on our website </a>

At first, on our webpage, there is the overview of our blog then there is the example of our JS clock . When you click on view code after visiting our website the whole code will appear, there is a also a button to copy the codes (HTML, CSS and JS).

You can view and copy the source code files through the link given below. <a href="https://www.codewithbishal.com/how-to-get-the-current-time-javascript"> View and Copy Source Code</a>
Ebook: Camel Passo a Passo
Tags: java, portugues, camel, cloud
Published: 2020-11-28 16:02:49

Começando meu primeiro post no dev.to para compartilhar o link de um ebook, em português, sobre [integração de sistemas com Apache Camel](https://www.angusyoung.org/2020/11/28/ebook-gratis-camel-passo-a-passo/).
Python Streamlit Apps | GitHub
Published: 2020-11-28 16:02:33

Deploy Streamlit apps directly from within GitHub. It’s the best way to deploy, manage, and share your Streamlit apps with the world — all for free.
Request an invite now or, if you already have one, sign in below.

Streamlit Request Invite = https://streamlit.io/sharing
Streamlit Share Login (via GitHub) = https://share.streamlit.io/

** App 1 - Sports Leagues **

https://akashjeez-pysportz.streamlit.app

** App 2 | OpenCV (Image and Video Analysis) **

https://akashjeez-pyopencv.streamlit.app
BPM - why is it a great discipline for an organization?
Published: 2020-11-28 16:01:40

At first, when I started working in the company where I work, I really did not understand what was BPM and now I want to share my experience with it of 2 years. 

**_“[Business Process Management (BPM)](https://bpm.com/what-is-bpm) is a discipline involving any combination of modelling, automation, execution, control, measurement and optimization of business activity flows, in support of enterprise goals, spanning systems, employees, customers and partners within and beyond the enterprise boundaries.”_**

As the definition says BPM is a discipline and nothing has to do with the tool that you use to support it. Almost all companies model and execute processes to ensure the quality of their products or services and the resources used to achieve the objectives. A person doing BPM must consider a process at the scope of interrelated business activities which holistically cooperate to fulfil a business objective. 

The principal benefits of using a BPM tool in my opinion are 2:
- The universality in the notation of the definition of processes, any person that understands the BPM notation is capable of seeing your process and without much studying can comprehend it.
- All the information is digitized which means that is easier to manage and create statistics turning information into knowledge that can support decision-making

And I have to say that there are a variety of BPM tools that your company could use like:
- Progress Savvion BPM
- Intalio
- IBM Business Process Manager 
- Oracle Business Process Management Suite. 
But all of them have very similar or even the same notation so.

I wanted to give you a little example of how simple can be a process but how meaningful could be the correct management of the information obtained. In this case, we are going to model the process of performance evaluation.

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

In this simple example, we can see how first the leader decides to begin the employee's performance evaluation, and the first step is the self-assessment by the employee and next, the evaluation by the leader, this simple process can be overwhelming when the number of employees depending on one leader is more than 20 but is even worse try to analyze that information.

With the BPM tool we have all the information in the databases and is easier to have statistics like:
- which was the one that got the best score
- what was the area when people exceed expectation
- Or at the contrary, what was the worst-rated question and how the leader is going to help people to go better?

With this simple example, I just wanted to show that the benefits of BPM implementations aren't just for big companies, a little process can see the added value and can help the company to improve.

I hope that after reading this you could be less intimidate when you hear the term BPM, thank you so much for reading and have an excellent day!!
Developed Python Web Apps
Tags: python, heroku
Published: 2020-11-28 15:57:33

https://linktr.ee/akashjeez

GitHub Link = https://github.com/akashjeez/

Python Flask | Hosted on PythonAnywhere PaaS Cloud.
Blog Site = https://akashjeezpython.pythonanywhere.com

Python Streamlit | Hosted on Heroku PaaS Cloud.
Akashjeez Site = https://akashjeez.herokuapp.com
Tutorial Site = https://PyPhilonoist.herokuapp.com
Python | PYPI Modules | GitHub
Tags: python, pypi
Published: 2020-11-28 15:56:13

Developed below Python Libraries/Modules Hosted on **PyPI**.
https://pypi.org/search/?q=akashjeez.

**akashjeez** : A Python Package to Deliver a Lot of Useful Services!
PyPI Module Repository : https://pypi.org/project/akashjeez
GitHub Code Repository : https://github.com/akashjeez/akashjeez

**azurestapi** : A Python Package to List Azure Resources for Different Azure Services!
PyPI Module Repository : https://pypi.org/project/azurestapi
GitHub Code Repository : https://github.com/akashjeez/azurestapi

**awscloud** : A Python Package to List AWS Resources for Different AWS Services!
PyPI Module Repository : https://pypi.org/project/awscloud
GitHub Code Repository : https://github.com/akashjeez/awscloud
Entornos de desarrollo de software con Windows
Published: 2020-11-28 15:53:42

Si bien es cierto que los sistemas con base UNIX han demostrado ser los sistemas operativos más confiables para desarrollo de software, es muy cierto que Windows ha hecho un gran esfuerzo por posicionarse de buena manera. Y aunque siempre ha existido soporte para desarrollar con la mayoría de las tecnologías, teníamos ciertas desventajas como la dificultad para trabajar proyectos con diferentes versiones de tu lenguaje favorito (ya que cada versión tiende a venir con su propio ejecutable) y en ciertas ocasiones el rendimiento (dependiendo de las alternativas que utilizaramos).

Por ejemplo, una de las opciones a las que solíamos recurrir para solucionar este problema era virtualizar aquellos entornos de desarrollo, como lo son VirtualBox o VMware, sin embargo, solía ser muy costoso en recursos y seguíamos teniendo el problema de rendimiento.

Ante todo esto surgió la tecnología Windows Linux Subsystem (o WSL) quién haciendo uso de Hyper-v logró crear una capa que podía correr aplicaciones para linux de manera nativa, sin embargo, esto no se trataba más que emular un subsistema de linux en nuestro sistema operativo y teníamos ciertas limitantes de compatibilidad y también de rendimiento.

Cuando surgió la segunda versión de WSL estos problemas dejaron de existir, ya que realmente utiliza el núcleo de linux como base, haciendo posible el uso total de las características de shell y mejorando por mucho los temas de rendimiento en cuanto escritura y/o lectura, con la única desventaja de tener que mover todos nuestros archivos al sistema de directorios creado por el propio WSL.

La principal ventaja que trajo WSL2 fue su alta compatibilidad con docker y es que estas herramientas en conjunto resuelven la mayor parte de los problemas que teníamos, nos permiten ejecutar contenedores con las tecnología que necesitemos sin sacrificar el rendimiento.

Lo que es muy cierto es que WSL2 en conjunto con docker puede requerir ajustes adicionales para lograr configurar al 100% tu entorno de desarrollo habitual, algo con lo que yo tuve problemas, fue configurar un debugger y ciertamente hay poca información al respecto, sin embargo, espero que con el tiempo uso de estas tecnologías siga incrementando y con ello el soporte para la comunidad.

## Conclusión

Si eres desarrollador y por alguna razón sigues pensando que windows no es una opción, te invito a que pruebes WSL2, no es una experiencia igual a trabajar sobre linux nativo, pero sin duda es una experiencia satisfactoria y te permitirá tener aquellos ejecutables que tristemente no eran compatibles con sistemas linux.

Si ya tuviste experiencia utilizando WSL2 cuéntanos en los comentarios qué te ha parecido, o si tienes algún comentario o sugerencia, siempre son bienvenidos.

¡Hasta pronto!
Coding video game as a hobby
Tags: gamedev, csharp, dotnet
Published: 2020-11-28 15:32:37

At a young age, I liked to play video games. I remember my first Nintendo console, with games like Super Mario Bros, Zelda, or Contra. I always was thinking about how the Japanese can create such artifact when you push a button and make Mario jump or throw fire at the goombas. 

In college I discover something called "programming" with which we can create amazing things. And the part that I like the most: being able to create video games by writing code. 

Well, I used Unity for a while, but I feel that instead of helping me, that engine abstracts so much details, that I really don't understand what I'm doing. 

For this reason I decided to use only code, without IDE or engine to create my first video game. For example, I have more experience with C#, even though I'm working with Java at the moment. I think C# is more fluent than Java and LinQ is a very good library to work with. 

So I choose Casino card game, at least [the dominican version of this game](https://www.pagat.com/fishing/royal_casino.html#dominican), to start my journey. You can see my progress on [this repository](https://github.com/jjuanbj/Casino).  I'm also going to post some tips on the *how* and *why* related to design and code. 


Happy to be here!
My favorite pages on the whole internet
Tags: jokes, discuss
Published: 2020-11-28 15:16:41

I know it has little value to just dump links like that, but those have made me laugh so hard each time I visited them that I feel compeled to share them, in case you dont know them !


- [WAT ? talk](https://www.destroyallsoftware.com/talks/wat)  is by far my favorite. I Listened to it millions of times. Still funny.

- Learn [why unit testing is important](https://www.youtube.com/watch?v=jbwO1DYgsFY)

- Get some [inspiration here](https://stackoverflow.com/questions/184618/what-is-the-best-comment-in-source-code-you-have-ever-encountered) for your comments.

- Have [a wise advice](https://shouldideploy.today/) before deploying in production

- Be aware that [correlation](https://xkcd.com/552/) does not imply [causation](http://www.tylervigen.com/spurious-correlations)

- I sometimes find myself not liking XKCD... [then](https://xkcd.com/683/) [I](https://xkcd.com/323/) [remember](https://xkcd.com/303/) [these](https://xkcd.com/2236/)

- [Some](https://www.defprogramming.com/) [less](https://uhmmm.app/) [funny](https://developer.android.com/reference/android/util/Log.html#wtf(java.lang.String,%20java.lang.String)) [links](https://developer.android.com/reference/android/app/ActivityManager#isUserAMonkey()) [but](https://developer.android.com/reference/android/os/UserManager#isUserAGoat()) [still](https://dorey.github.io/JavaScript-Equality-Table/) worth a click

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

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

Dont hesitate to share yours ! 

(and check out [the lib I recently published](https://github.com/oguimbal/pg-mem) if you have some time to spare !)
[Tutorial Linux] Terminal: O sistema de permissões no Linux
Tags: linux, leitura, escrita, execucao
Published: 2020-11-28 14:59:15

O sistema de permissão no Linux dá possibilidade de alterar três propriedades de arquivos e diretórios. São elas:

## Leitura (R - read)

Se os usuários podem abrir um arquivo e fazer a leitura do conteúdo deste.

## Escrita (W - write)

Se os usuários podem alterar esse arquivo.

## Execução (X - execute)

Se os usuários podem executar esse arquivo.

## Interpretando as permissões

As permissões são descritas com uma sequência de 10 caracteres.

![usando comando ls -lh](https://dev-to-uploads.s3.amazonaws.com/i/heiriiajiv4xqhk5926d.png)

- O primeiro item é referente ao **diretório ou arquivo**:

![item 1](https://dev-to-uploads.s3.amazonaws.com/i/m5jjf0htbes6qp9ray7j.png)

- O segundo, terceiro e quarto itens são referentes as permissões do **dono** do arquivo:

![todas a permissões para o dono](https://dev-to-uploads.s3.amazonaws.com/i/nrhyrwdd9yim8b1kovua.png)

![dono pode ler e modificar](https://dev-to-uploads.s3.amazonaws.com/i/mhvjsbcz807r1enadqlu.png)

![dono só pode ler](https://dev-to-uploads.s3.amazonaws.com/i/cijknksmh1pjvtce13g1.png)

- O quinto, sexto e sétimo itens são referentes as permissões do **grupo** ao qual o arquivo pertence:

![todas as permissões para o grupo](https://dev-to-uploads.s3.amazonaws.com/i/6mmcvpmwiu7fx44dlafy.png)

![grupo pode ler e modificar](https://dev-to-uploads.s3.amazonaws.com/i/6hzbo8at31b3zr6lzrn3.png)

![grupo só pode ler](https://dev-to-uploads.s3.amazonaws.com/i/so3uf91rmfaj8qmj1y2q.png)

- O oitavo, nono e décimo (último) itens são referentes as permissões de outros **usuários** do sistema:

![todas as permissões para o usuário](https://dev-to-uploads.s3.amazonaws.com/i/b3y9uqlwbuo4c48l0m5l.png)

![usuários pode ler e modificar](https://dev-to-uploads.s3.amazonaws.com/i/0jxcylwso67epvvcvgut.png)

![usuário só pode ler](https://dev-to-uploads.s3.amazonaws.com/i/4f4ajkg75u25o8p8j6eu.png)