teleren/devto huggingface dataset:
PHP for Loop with code examples
Tags: php, for, loop, webdev
Published: 2022-06-30 15:48:00

PHP for loop is more like C or JavaScript if you already know these programming languages then PHP for loop must feel familiar to you. I am quickly going to show PHP for loop example code with PHP array data. But first let's understand how the PHP for loop looks and works. However, in practice; people use PHP foreach loop and PHP while while more often than the PHP for loop. Nevertheless, let's have a look at it. 

## PHP for loop stucture

/* example 1 */

`for ($i = 1; $i <= 10; $i++) {
    echo $i;
}`

/* example 2 */

`for (expr1; expr2; expr3):
    statement
    ...
endfor;`

## PHP for Loop with Array Data Example
Here is a PHP multidimensional array and below this array there is a PHP for loop that is looping through the array and printing fruit names and fruit price that you can see in the image below this for loop. Or you can simply copy this code block and run it on your system or on online PHP compiler. 

`$fruits = array(
    array('name' => 'Apple', 'price' => 5.0),
    array('name' => 'Orange', 'price' => 4.0),
    array('name' => 'Guava', 'price' => 3.50),
    array('name' => 'Banana', 'price' => 2.50),
    array('name' => 'Grapes', 'price' => 3.0)
);

for($i = 0; $i < count($fruits); ++$i) {
    echo 'Fruit Name: '. $fruits[$i]['name'] . ", Price $ " . $fruits[$i]['price'] . ' | ';
}`


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

## PHP foreach loop structure

### To loop over php array
foreach (iterable_expression as $value)
    statement

### To loop over php key-value pair array
foreach (iterable_expression as $key => $value)
    statement
Azure AD Refreshing Tokens in background
Published: 2022-06-30 15:19:45

What I need is to ‘Refresh the Token’ before it expires. 
This would allow the users to complete their work without being promoted to login again. The main issue is when the user is working on a popup form and just before he/she hits the ‘Save’ button, the token expires and then the only option (As of now) available is to lose the changes and refresh the page for the login to AAD. What would be best is the keep refreshing the token in the background (Just before access token expiry) to avoid being prompted to AAD login.
Looking for feedback: Tired of spending hours setting up the infra for open sourced tools?
Tags: discuss, productivity, opensource, cloud
Published: 2022-06-30 14:48:21

Hi, I recently heard a lot of developers complain about how much time it takes to setup open source tools like Metabase or sentry within their infrastructure. Hence wanted to do a dipstick survey with this community as well to see if it's a large enough problem worth solving for? 

If you believe this is a problem please feel free to fill this form up https://my.forms.app/form/62bdab12bd94a175bbbacfdc , it will help me shape my thinking around how to solve for this.
Open-sourcing django-swap-user to simplify custom user models
Tags: opensource, python, django, writing
Published: 2022-06-30 14:44:22

By default, the user model in Django framework includes an email, username, and password. But there are often situations where it is necessary to extend and replace the default user model. So our Python Teamlead wrote such a wrapper and open-sourced it.

Are you tired of copying a custom user model from one project to other ones? [Use django-swap-user package by Evrone!](https://evrone.com/django-swap-user)
Node.js fundamentals allegorically
Tags: node, programming, javascript, webdev
Published: 2022-06-30 14:40:00

### Stream vs. Buffer

<u>Stream is an abstract interface</u> (<i>“abstract” meaning it made for beginner users i.e. relatively easy-to-use</i>) <u>primarily to work with</u> streaming (which means <u>“in-memory”) (session) data</u> rather than in-disk (persistence-like) data . 

> EXAMPLE : Pipe is an important mechanism connecting two & more <u>processes (streams</u>, _processes are mounted onto PCB, RAM by kernel_) without storing anything on the disk for persistency [backed up by [baeldung](https://www.baeldung.com/linux/anonymous-named-pipes#:~:text=A%20pipe%20is%20an%20important%20mechanism%20in%20Unix-based,pipes%29%20and%20FIFO%E2%80%99s%20%28also%20known%20as%20named%20pipes%29.)] ;

**Readable** – earth , that generates water ;

| **Stream** (continues in time) FIFO-like                                          |   | **Buffer** (discrete in time) STACK-like                                                                                       |
|--------------------------------------------------------------------------|---|---------------------------------------------------------------------------------------------------------------------|
| Example: Constantly running water in your **mouth (consumer, writable)** in small gulps (chunks) |   | Example: Water as ice cubes, the measured units of water to prevent clogging                                        |
| How long can you drink without taking a breath (discrete pause of time)  |   | Buffer as stream optimization gives discrete pauses between "swallowing" big ice cube chunks (blobs) by one's mouth as a writable (consumable) |
|                                                                          |   |                                                                                                                     |

> **NOTE** : Stream can be readable, but not mandatory writable – water can be generated, but not consumed;

> **KEEP IN MIND** : Buffer does pack stream in discrete units, giving a measuring feature, that sounds like optimization, however streaming ensures plausibly un-interrupted consumption . Inter-process-communication (IPC) messaging is a real life example of buffering, whereas I/O over Network (e.g. video, audio, or both) is a real life example of streaming .

---
### Refs

- Node.js fundamentals et al. [link](http://book.mixu.net/node/ch9.html)

---

Stay tuned, more is coming shortly !
Testando datas mais facilmente com Jest
Tags: javascript, jest, node, typescript
Published: 2022-06-30 14:01:05

Quem desenvolve em Javascript | Typescript (e outras linguagens também 😜) sabe a dor de cabeça que é trabalhar com datas.

Uma coisa é certa, do juninho ao sênior em algum momento você vai precisar formatar uma data (e não vai saber 😬) ou vai ficar (muito) estressado porque o diabo da data que você criou está ficando com 3 horas a menos (kkk). 

O primeiro problema é normal. Já o segundo se deve a forma como o Node trabalha com timezones. Nesse caso, ao criar um objeto Date com o comando `new Date('2022-05-21')` e tentar utilizar algum método como `.toString()`, o Node vai trazer esse valor acrescido (ou subtraído) do valor timezone da nossa máquina (normalmente aqui no Brasil seria de -3 horas). Por isso ocorre de criarmos uma data e ao tentarmos exibí-la, o valor retornado ser a data do dia anterior às 21h.

Exemplo:
```js
const date = new Date('2022-05-21')

date.toString() // deveria retornar Sat May 21 2022 00:00:00
// mas retorna Fri May 20 2022 21:00:00
```

Para resolver esse problema na execução de testes com Jest e evitar programações alternativas 🤭, podemos fazer uma simples configuração que lhe salvará vários fios de cabelo. 

Vamos lá. Primeiramente precisamos criar um arquivo de configuração global para o jest (não é o jest.config). O nome não importa mas nesse exemplo vamos chamá-lo de `globalJestSetup.ts` e ele terá uma simples função exportada como default.

![globalJestSetup.ts](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r6igpue5to76yatx9crb.png)

Nesse arquivo estamos simplesmente dizendo para o Jest sempre utilizar a timezone UTC, assim ao trabalhar com datas não haverá o problema de termos o valor diferente dependendo da timezone.

Feito isso agora só precisamos adicionar esse arquivo nas configurações do Jest (no arquivo jest.config) como mostrado na imagem abaixo, utilizando o atributo `globalSetup`:

![jest.config.ts](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kmwxm3khtjrosw4xxzch.png)

Lembrando que o nome que você deu ao arquivo deve ser igual ao usado na configuração do Jest.

E é basicamente isso. Agora ao fazer seus testes, as datas sempre terão o valor que você esperava hehe, independente do ambiente em que eles sejam executados.

**Bônus:**
Você pode adicionar um teste que verifica se essa configuração funcionou realmente:

![timezone.test.ts](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/152xmsvgf79v4uigiya1.png)
06 - Cloud Solution Architect – Is knowing programming mandatory
Tags: cloud, csa, techtalks, career
Published: 2022-06-30 14:38:19

A lot of us come from pure infra background. Having programming language helps but is it a necessity? 

https://youtu.be/iWOpeWIVulo

{% youtube iWOpeWIVulo %}

For more please subscribe 
https://www.youtube.com/c/TechTalksWriju?sub_confirmation=1
Firebase/Firestore is becoming too complicated of a product. Am I the only one?
Tags: webdev, javascript, firebase, typescript
Published: 2022-06-30 14:29:09

Does anyone feel like Firestore is becoming too complicated for the average user? I used Firestore for my most recent project and the amount of [customization and options](https://firebase.google.com/docs/reference/js/firestore_) is just overwhelming. From security rules, cache vs. server fetch, snapshots, pending writes, etc. The product is not as beginner-friendly as it used to be before.

Am I the only one who feels this way?
#Event – Let’s Build an App without Using any Code with Microsoft Power Platform at the Toronto Reactor
Tags: englishpost, event, microsoftreactor
Published: 2022-06-30 18:37:46

---
title: #Event – Let’s Build an App without Using any Code with Microsoft Power Platform at the Toronto Reactor
published: true
date: 2022-06-30 14:21:52 UTC
tags: EnglishPost,EnglishPost,Event,MicrosoftReactor
canonical_url: 
---

![Event banner](https://brunocapuano.files.wordpress.com/2022/06/image-1.png?w=600)

Hi !

Next week I’ll be at the Microsoft Reactor, learning how to build apps using Power Platform. I have a couple of ideas that I want to test, so if you want to join me, come to the Toronto Reactor !

We will have food 🍕 and drinks ! And hey, I have some personal goals about learning Power Platform, so this is a good chance to learn something new together 😁

### [Register here](https://www.meetup.com/microsoft-reactor-toronto/events/286613891/)

Thursday, July 7, 2022  
5:30 PM to 7:00 PM EDT  
[Microsoft Reactor Toronto](https://www.google.com/maps/search/?api=1&query=101+College+St.+%2C+Toronto%2C+on%2C+M5G+1L7%2C+ca)  
[101 College St. Suite 120 · Toronto, on](https://www.google.com/maps/search/?api=1&query=101+College+St.+%2C+Toronto%2C+on%2C+M5G+1L7%2C+ca)

See you there !

Happy coding!

Greetings

El Bruno

More posts in my blog [ElBruno.com](https://www.elbruno.com).

* * *
Paracetamol.js💊| #158: Explica este código JavaScript
Tags: javascript, webdev, spanish, programming
Published: 2022-06-30 14:19:52

## **<center>Explica este código JavaScript</center>**
#### <center>**Dificultad:** <mark>Básico</mark></center>

```js
const perro = {
  id:1,
  nombre:"Dogge",
  edad: 4,
  color: "cafe",
  cola:false,
}

console.log(Object.keys(perro));
console.log(Object.values(perro));
```

A. `[ "id", "nombre", "edad", "color", "cola" ]`, `[ 1, "Dogge", 4, "cafe", false ]`
B. `[ 1, "Dogge", 4, "cafe", false ]`, `[ "id", "nombre", "edad", "color", "cola" ]`
C. `Ninguno de los anteriores`

Respuesta en el primer comentario.

---
Basics-Benefits- Problems- RPA
Tags: rpa, rpabots, processautomation
Published: 2022-06-30 05:23:06

## What is RPA?

Robotic process automation is a type of business process automation technology that uses artificial intelligence or software robots. It is a software technology that makes it easy to build, deploy, and manage software robots that replicate humans actions while interacting with digital systems and software.

Now a days RPA is being used in various industry such as finance, call center, manufacturing, healthcare and IT operations. 

## Benefits of RPA in Businesses

1. Reduced costs
2. Improved efficiency
3. Increased productivity
4. Improved customer services
5. Increased security
6. Optimized resource source

## What are the problems with RPA?

1. Poor Script

RPA is a great at automating mundane, repetitive and rules-based tasks. RPA is not a actual robot that performs task but it is script that are programmed to execute instruction.

2. High Expectation

Implementation of RPA requires planning, research, knowledge of tasks that have to automate. After a task is automated, it's frequently realized how dynamic the process really is (especially when multiple applications are involved). This happens when organization automate each and every task to save time and costs.

3. Ambiguity at Scale

RPA technologies have limited tracking features, making it challenging to identify who built which bot and what datasets and programs those bots used. Therefore, it becomes impossible to forecast which processes would stop working next when RPA tools are quickly introduced at scale throughout the firm.

## Conclusion
RPA tools is highly effective if implemented correctly considering task in details and accordingly develop script. Success with RPA depends on where and how it is applied.
I Published the Python Package on PyPi : pip install google-address-to-latlong-csv
Tags: pypi, python, shriekdj, geocoding
Published: 2022-06-30 13:59:00

So today I Published an python package first time in my life.

Now This is a Python 3 Package which gets the list of data of addresses from an csv file and gives an output as csv with additional fields of latitude and longitude of the address provided by google GeoCoding API.

I Created this Package With very simple program of Poetry.

So Now `Poetry` is an Virtual Environment Manager Just Like Pipenv or Virtual Env But with It's Own Way of creating wheel for our Project and also it helps us to publish the package.

How to Publish a Python package with help of poetry

- Make your project in a folder with `__init__.py` file and goto parent of that **package_name_folder**
- run `poetry build`
- run `poetry publish`
- It will ask credentials of pypi.org so fill it and your package published

{% github shriekdj/google_address_to_latlong_csv %}

you can install the package by running

```python
pip install google-address-to-latlong-csv
```

[pip install google-address-to-latlong-csv](https://pypi.org/project/google-address-to-latlong-csv/)

I Know I Am writing this post after too much time, because i actually didn't have that many article topics so i just didn't published some unnecessary stuffs. But I Have Now some topics to cover so just wait for it.

Thanks bye, 👋
Electronics And Communication Engineering Projects
Tags: webdev, javascript, programming, tutorial
Published: 2022-06-30 13:40:19

For their purpose, we've listed a large number of project ideas. These are especially collected and published then for ECE scholars. These are collected from different sources for the convenience of students. However, feedback, commentary and new ideas in the contact us page, If you're interested you may formerly check the list of all these projects and give your suggestions. Also check out the huge collection of electrical symbols.

Engineering student projects for B.Tech and M.Tech final year students. Takeoff Edu Group offers a wide range of projects best for [electronics and communication engineering projects](https://takeoffprojects.com/electronics-and-communication-engineering-projects) looking for magnificent final projects at low cost. 

We have successfully delivered a final year project for electronics and communication to our engineering students. Our programs are specially designed by experts for best results of final year projects for electronics and communication students. max of the B.Tech, M.Tech, PhD and Diploma scholars.

Takeoff Edu Group provides the most creative conceptions and ideas that can make very effective final year projects for scholars, experimenters, and engineers. So browse through our list of [electronics and communication engineering projects](https://www.youtube.com/watch?v=emadvM3FJcI) and choose the smart final year projects for your requirements.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hrvgj8g114xa0ua1dqcy.png)
<u>Electronics Project Categories</u>

- 8051 Microcontroller Projects
- Arduino Projects
- Mini Projects
- Raspberry Pi Projects
- PIC Microcontroller Projects
- Robotics Projects
- AVR Microcontroller Projects
- Wireless Communication Projects
- RF & RFID Projects
ECE refers to Electronics and Communication Engineering. This one of the most demanded branches in engineering as the scholars who join in this branch would have numerous openings in their career. Every engineering pupil should complete their project successfully in final year to get their engineering certification. They've numerous choices in opting the projects similar to microcontroller based, solar, electrical, robotics, detector rested, etc.
Nervos Network’s Hackathon BlockJam Invites Developers, Entrepreneurs and Web3 Enthusiasts
Tags: nervos, hackathon, blockjam, web3
Published: 2022-06-30 13:40:00

BlockJam, a 16-day online event, goes live to educate the next generation of crypto enthusiasts and create a meeting point for their interaction and socialization.

**Nervos Network’ BlockJam virtual conference kicks off**

According to the official statement by the Nervos Network team, its Blockjam conference launched on June 17th, 2022. Within the framework of the first section of this conference, DeFi, NFT and GameFi professionals and newbies were invited to attend talks and sessions with high-reputable speakers.

Together with other industry leaders, [GetBlock’s](https://getblock.io/) business development guru Maria Key will speak about blockchain nodes and their role in Web3 development. Ms. Key will also cover GetBlock’s USP and its next steps of the roadmap.

Also, Nervos Network’s partners from Chainsafe and Filecoin, will be holding the discussions about ERC-1155 token standard and its role in new dApps’ development. The attendants will learn about the opportunities ERC-1155 standard unlocks for DeFi and Play-to-Earn designs.

Inter alia, [BlockJam hackathon ](https://globalblockjam.com/)is focused on strengthening Nervos- and Godwoken-based ecosystem of decentralized applications. Nervos representatives will spread the word about last milestones accomplished by Nervos and its features for retail clients.

**Introducing GameJam, a novel virtual hackathon for Play-to-Earn projects**

On June 20 – July 4, 2022, BlockJam attendees will also be invited to take part in GameJam hackathon focused on blockchain-based gaming and various use-cases crucial for progress and adoption.

For instance, GameJam participants will be able to suggest their solutions for gameplay designs, in-game stores’ economical architecture, community building, value creation, and so on.

Top-tier GameFi experts will select the most promising products; $50,000 prize pool will be distributed between GameJam 2022 winners in various tracks.
Code Smell 145 - Short Circuit Hack
Tags: webdev, beginners, programming, tutorial
Published: 2022-06-30 13:37:51

*Don't use boolean evaluation as a readability shortcut*

> TL;DR: Don't use Boolean comparison for side effect functions.

# Problems

- Readability

- Side Effects

# Solutions

1. Convert [short circuit](https://dev.to/mcsee/code-smell-140-short-circuit-evaluation-20kc) into IFs

# Context

Smart programmers like to write hacky and obscure code even when there is no strong evidence for this improvement.

Premature optimization always hurts readability.

# Sample Code

## Wrong

[Gist Url]: # (https://gist.github.com/mcsee/be2e697d71cfb438110d911c9e4751dc)
```javascript
userIsValid() && logUserIn();

// this expression is short circuit
// Does not value second statament
// Unless the first one is true

functionDefinedOrNot && functionDefinedOrNot();

// in some languages undefined works as a false
// If functionDefinedOrNot is not defined does
// not raise an erron and neither runs
```

## Right

[Gist Url]: # (https://gist.github.com/mcsee/5c48bd13ce74f1605cf8d6a8ed2de4d9)
```javascript
if (userIsValid()) {
    logUserIn();
}

if(typeof functionDefinedOrNot == 'function') {  
    functionDefinedOrNot();
}
// Checking for a type is another code smell
```

# Detection

[X] Semi-Automatic 

We can check if the functions are impure and change the short circuit to an IF.

Some actual linters warn us of this problem

# Tags

- Premature Optimizacion

# Conclusion

Don't try to look smart. 

We are not in the 50s anymore.

Be a team developer.

# Relations

{% post https://dev.to/mcsee/code-smell-140-short-circuit-evaluation-20kc %}

{% post https://dev.to/mcsee/code-smell-06-too-clever-programmer-37lb %}

{% post https://dev.to/mcsee/code-smell-149-optional-chaining-jk %}
 
# Credits

Photo by Michael Dziedzic on Unsplash

* * *

> A computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are, in short, a perfect match.

_Bill Bryson_
 
{% post https://dev.to/mcsee/software-engineering-great-quotes-26ci %}

* * *

This article is part of the CodeSmell Series.

{% post https://dev.to/mcsee/how-to-find-the-stinky-parts-of-your-code-1dbc %}
5 useful bash expressions to use with IF
Tags: bash, shell, linux, cli
Published: 2022-06-30 13:32:56

## 1. How to check if specific bash command is available:

```bash
if command -v CMD &> /dev/null; then echo "it exists"; fi
```

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

Edit or save [this code on github](https://github.com/Onelinerhub/onelinerhub/blob/main/bash/check_if_commmand_exists.md).


## 2. How to check if specific file exists:

```bash
if [ -f /tmp/file ]; then echo 1; fi
```

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

Edit or save [this code on github](https://github.com/Onelinerhub/onelinerhub/blob/main/bash/if_file_exists.md).

## 3. How to check if scecific directory exists:

```bash
if [ -d /tmp ]; then echo 1; fi
```

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

Edit or save [this code on github](https://github.com/Onelinerhub/onelinerhub/blob/main/bash/if_directory_exists.md).

## 4. How to check if variable is empty

```bash
if [ -z "$variable" ]; then echo "\$variable is empty"; fi
```

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

Edit or save [this code on github](https://github.com/Onelinerhub/onelinerhub/blob/main/bash/check_if_variable_is_empty.md).

## 5. How to check if variable is not empty

```bash
if [ ! -z "$variable" ]; then echo "\$variable is not empty"; fi
```

Edit or save [this code on github](https://github.com/Onelinerhub/onelinerhub/blob/main/bash/check_if_variable_is_empty.md).