teleren/devto huggingface dataset:
Stop using if else 
Tags: javascript, webdev, oop, tutorial
Published: 2021-10-14 12:34:45



Recently, I had a take home assignment for a front end role, and I had to make a sort of Dashboard. I thought I did everything right,  but I was rejected,  partly on my carelessness, and also due to my code. I was using too many if/else statements everywhere! And I didn't know any better. But now I do, and I'm here to share that with you.

Most of us use if/else and switch statements whenever there is some conditional logic to handle. Although it might be a good idea to do that for one or two conditions here and there, using multiple if else statements chained together or big switch statements will make your code look very ugly, less readable and error prone.
```js
function whoIsThis(character) {
    if (character.toLowerCase() === 'naruto') {
        return `Hokage`
    } else if (character.toLowerCase() === 'sasuke') {
        return `Konoha's Strongest Ninja`
    } else if (character.toLowerCase() === 'isshiki') {
        return `Otsutsuki being`
    } else if (character.toLowerCase() === 'boruto') {
        return `Naruto and Hinata's son`
    }
}
whoIsThis('')
```

You see that we are repeating ourselves many times by writing multiple console.logs and if statements.

But there's an Object-Oriented way of doing this, and that is by using Objects.
Instead of writing if else blocks we just define an object which has the values we use in comparisons as keys, and the values we return as values of the objects, like so:
```js
function whoIsThis(character) {
    const listOfCharacters = {
        'naruto': `Hokage`,
        'sasuke': `Konoha's Strongest Ninja`,
        'isshiki': `Otsutsuki being`,
        'boruto': `Naruto and Hinata's son`
    }

    return listOfCharacters[character] ?? `Please provide a valid character name`
}
```
By using objects, we were able to make a sort of dictionary to look up to, and not use multiple if-else statements. 

We can also make this better by using the **Map** object instead of using an object. Maps are different from normal objects:
- They remember the original order of insertion
- Unlike objects, we can use any type of data as key/value, not just strings, numbers and symbols.
```js
function whoIsThis(character){
const mapOfCharacters = new Map([
['naruto', `Hokage`],
        ['sasuke', `Konoha's Strongest Ninja`],
        ['isshiki', `Otsutsuki being`],
        ['boruto', `Naruto and Hinata's son`]
])
return mapOfCharacters.get(character) ?? `Please provide a valid character name`
}
```
Thanks for reading this short article, if you liked it, you can support my work at https://www.buymeacoffee.com/rishavjadon
Why Django For Backend Than PHP(Laravel)
Tags: beginners, python, programming
Published: 2021-10-14 13:48:00

The topic really interested me in Quora as developers from both groups defended their tools. Before developing a system, you must select the best tools to use. Have in mind the effects of each, both the advantages and disadvantages.

Don’t be too choosy. Each tool was created for a specific purpose. What you might accomplish with PHP might or might not happen with Django. But both are server languages. I have never touched PHP because of the negative talks from people. But from the compilation I have made, here is my reason why I would rather work with Django than PHP.

Easier Integration with AI, DS, and ML projects

Of course, we are living in the world of AI where people are developing projects using artificial intelligence. Machine learning technology is trending daily. Since the most common language used is Python, it becomes easier to integrate with that application. Django as a python framework makes the work look much simpler than you might work with PHP.

Security

Many people have abandoned the use of WordPress because they have a PHP backend. The language has leaked and is most of the time prone to hackers. Django comes with strong built-in security. This is a rare case where you will hear about a leak in the Django server application

Django is easier to Learn

Yes, both PHP and Python are easier to understand when you dedicate your maximum time to them. Python syntax is much easier to read and understand. While in a rush for server language, opt to pick python Django. If you have the basics of python, it will be much simpler.

Django is faster than PHP

Python is powerful in general. So it can be used for complex projects, with its numerous libraries. It’s faster when developing a site and also the running time. If you are new to server language, kindly work with Django. But when it comes to deployment, things turn out different. I would rather advise you to stick to what you have been doing if you ever worked with PHP. Django calls upon a specific environment in order to run.

Time management

If you want to build a web application quickly and deploy it, then Django might be your best choice. Although you might face a variety of problems, that is common to almost everyone. Are you comfortable using Django, then come solve problems as fast as possible?

Handle complex tasks

This is an attribute related to the vast community of python Django. The framework keeps growing daily as new packages are added. Python is a memory efficient language that takes up less space.

Although the comparison might sound biased, the fact remain we can’t compare Django with PHP. One is a framework while the php is programming language. However, both can build awesome backend servers. Have a tool then dig deeper to understand what it can do.

All the same, AI projects are the most popular technologies. This means Django will have space to exist in the coming years.
Choosing a future career as a programmer
Published: 2021-10-14 16:54:32

Hello guys! My name is Olim and as you know I want to explain to choose your future horizon as a programmer. You may have different options like IOS, Android, Web developer and maybe .Net developer.
Actually, what is .Net developer? .Net is a free, open-source, cross-platform for building many different types of applications. Moreover, you can build web, mobile, desktop, games.

What about programming language?
Do not worry C# is armor for your applications and Object-Oriented Language as well as it is easy to learn compared to C++.

All information taken from (https://dotnet.microsoft.com/).
SPO600 - Lab 2
Published: 2021-10-14 17:16:12

Hey guys, to whoever's reading this, here's some context. 
This is my 2nd lab for my course SPO600 (open source development). This lab involves assembly language, specifically 6502.

```
        lda #$00        ; set a pointer at $40 to point to $0200     
        sta $40 
        lda #$02 
        sta $41

        lda #$05        ; green color
        ldy #$00        ; set index to 0

top:  
        sta ($40), y    ; set first y pixel to green
        iny             ; increment y
        cpy #$20        ; stop when it hits y20

        bne top		

        sta $41         ; point at last page 

        ldy #$e0        ; set index to last row
        lda #$06        ; blue color

bottom: 

        sta ($40), y    ; set pixel to blue
        iny             ; increment y  

        bne bottom  

left_right: 

	lda #$07         ; yellow color 
        sta ($40), y     ; set pixel to yellow 

        tya              ; transfer y to a  

        clc              ; clear carry
        adc #$1f         ; add with carry

        tay              ; transfer a to y  

        lda #$04         ; purple color 

        sta ($40), y     ; set pixel to purple          
        iny              ; increment y 

        bne left_right

        inc $41           ; increment page    
        ldx $41           ; get current page number  
        cpx #$06          ; compare with 6

        bne left_right    ; continue until done all pages
```

This is the result produced:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k60xq45sh45y9tw8ubse.png)



I gained a lot of experience into assembly language from this lab. It was very difficult at first but the more I looked into it, the simpler it got.
Arquitetura Hexagonal... É arquitetura? É hexagonal?
Tags: architecture
Published: 2021-10-14 20:01:32

Nas últimas semanas estou vendo algumas discussões relacionadas a confirmação da arquitetura hexagonal e outros modelos como DDD como arquitetura ou não. Acredito que a discussão é bem válida, e achei pertinente dar meus 2 centavos sobre o assunto. Diferente de alguns outros posts, acredito que o conteúdo desse é mais um ponto de vista do que uma resposta definitiva sobre o assunto, portanto cabe a você que lê, guardar aquilo que faz sentido.

Só para contextualizar, a arquitetura hexagonal consiste em dividir a aplicação em camadas separando o código em categorias diferentes (são geralmente usadas as camadas de infraestrutura, aplicação e domínio). Ela é baseada no famoso desenho da arquitetura de cebola ou arquitetura em camadas muito usado para representar a Clean Architecture” ou no bom português “Arquitetura Limpa”, mas é chamada arquitetura hexagonal por causa dos primeiros desenhos usados em sua representação.

Leia o artigo na íntegra no meu (blog)[https://diegoborgs.com.br/blog/arquitetura-hexagonal-%C3%A9-arquitetura-%C3%A9-hexagonal].
The future of Jamstack  is Less JS!
Tags: javascript, jamstack, webdev, tutorial
Published: 2021-10-14 22:24:09

Yang Zhang hosted a Jamstack session where he discussed the functions of Plasmic, a visual builder that can plug into your own code base similar to a headless CMS but has a no-code page builder that allows you to style landing pages the way you want.

A little before knowledge we dive in! I signed up for the Jamstack Conf 2021 but had no idea what Jamstack was or even did for that matter. So before listening into a few sessions, I did some research on Jamstack and here's what I learned. Jamstack is an architecture that builds on many of the existing frameworks and workflows that developers use today. Jamstack allows you to build beautiful website easier with JavaScript frameworks, Static Site Generators, Headless CMSs, and CDNs.

Back to what I learned. One concept I learned while listening to Yang speak was the term "Streaming Render". So how rendering works is you fetch all the data you need to render the page, your render the full page, than you send the result out to the browser. This can take some time as different data takes less/more time to render. Streaming render allows your to mark certain parts of your page as lazy loaded and a place holder is rendered instead, and the server will continue to render the rest of the page. This cuts back on the render time.

As someone who know the basics of coding web based projects. My main question on these topics would be, how do these frameworks and software affect the average developer? With all these new programs that allow most everyday users to create a project without any prior coding knowledge, how does this affect developers and the field?

In conclusion I was very pleased to attend Yang Zhang's session on Plasmic. Plasmic uses all the best practices around images, text, etc. like streaming rendering, API's, plugins, etc. All in all a great learning experience where I was able to further my knowledge in web development.
Week3 SPO600 Math Problem Solving
Published: 2021-10-15 00:19:20

Hello everyone, welcome back to the 4th week of SPO600(Software Portability and Optimization) reflection and extra exploration blog! In this blog, I'm going to use 6502 assembly language to do some math problems.

In 6502 assembly language, we use [ADC(add with carry)](https://wiki.cdot.senecacollege.ca/wiki/6502_Math#Addition) and [SBC(subtract with carry)](https://wiki.cdot.senecacollege.ca/wiki/6502_Math#Subtraction) to add and subtract the value which is stored in the accumulator. 

With the basic ideology, let's create a simple program to calculate numbers.

```
LDY #$05	;Load Y register with 40 in hexadecimal

SEC		;Set carry flag
TYA 		;Transfer Y register to the accumulator
SBC #$02        ;Do the subtraction 2 
CLC             ;Clear carry flag
ADC #$01
TAY		;Transfer the A register to Y
```
In this simple program, we load a number 5 to the Y register in hex decimal. For subtraction, we have to use the SEC to set up a carry flag. Next, we transfer the value which is stored in Y to the accumulator for processing calculation. Afterwards, we subtract carry 2 to the number in the accumulator, then CLC is used to clear the flag for the addition with carry 1. Lastly we transfer the result from the accumulator to the Y register. In this little program we simply do a 5-2+1 calculation by using assembly language. As we expected, the answer is 4 in the Y register!
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kneeqkk9ykt46q6e0864.png)

My thoughts about the math problem in the assembly world. Personally, I start the programming with a high level programming language, creating a program to do the calculation above is the easiest thing for me. But in assembly language, numbers are stored in registers. If we want to access them and modify the number we have to set them into the accumulator, then create or clear carry flags for addition or subtraction. It shows the property of a low-level programming language which has to actually access the memory by the programmer every single time during the programming.
Array en PHP
Published: 2021-10-15 20:33:17

![php con código de fondo](https://tutorialesenpdf.com/wp-content/uploads/2016/06/php-tutorial-pdf.jpg)

### Declarar un array vacío 
 
```php

//Sintaxis con array() 
$lista_de_series=array();

//Sintaxis short array valida a partir de PHP 5.4
$lista_de_series=[];
```
### Declarar un array con elementos

```php
//Sintaxis con array() 
$lista_de_series=array('El juego del calamar','Cobra kay','Love, Death and Robots','Sweet Tooth');

//Sintaxis short array
$lista_de_series=['El juego del calamar','Cobra kay','Love, Death and Robots','Sweet Tooth'];
```

[Ver ejemplo 1](https://onecompiler.com/php/3xeh47dpq)

### Acceder a un elemento de un array simple 

```php

$indice=3;

echo $lista_de_series[$indice];

```



### Declarar un array asociativo con elementos

```php
//Sintaxis con array() 
$jugador=array('nombre'=>'Lionel',
               'apellido'=>'Messi',
               'nacionalidad'=>'Argentina',
               'edad'=>34);

//Sintaxis short array
$jugador=['nombre'=>'Lionel',
               'apellido'=>'Messi',
               'nacionalidad'=>'Argentina',
               'edad'=>34];
```
### Acceder a un elemento de un array asociativo con claves

```php
//Sintaxis con array() 
echo $jugador['nombre'];

```

[Ver ejemplo 2](https://onecompiler.com/php/3xeh4ng5h)

### Acceder a un elemento de un array asociativo con claves

```php
//Sintaxis con array() 
echo $jugador['nombre'];

```

[Ver ejemplo 2](https://onecompiler.com/php/3xeh4ng5h)

### Agregar elementos a un array

PHP nos proporciona la funcion array_push() para agregar elementos a un array

Sintaxis: array_push($array, $elemento);

También es posible agregar mas de un elemento 
array_push($array, $elemento1,$elemento2,$elemento3,$elemento4);

```php

$lista_de_series=array('El juego del calamar','Cobra kay','Love, Death and Robots','Sweet Tooth');

array_push($lista_de_series,'La casa de papel');

array_push($lista_de_series,'Sweet Home','De yakuza a amo de casa');

FIN
DEL
POST

```
[Ver ejemplo 3](https://onecompiler.com/php/3xeh8fake)
Learn with me:Apple's Swift
Variables and Constants
Tags: programming, swift, ios, tutorial
Published: 2021-10-15 06:43:37

Hey guys,Welcome to 2nd part of Learn With Me:Apple's Swift.In previous tutorial you learned how to write Hello World in Swift and in this tutorial we are going to learn about Variables and Constants in Swift.I will highly recommend to read the first part of Swift tutorial [here](https://dev.to/thisisanshgupta/learn-with-meapples-swift-o21).So let's get started.

#Variables
In programming,variable is a storage area to store data.For eg:
```swift
var name="Swift"
```
Here **name** is a variable storing "Swift".

#Declaring Variables in Swift
In Swift,variables are declared using **var** keyword.
For example,
```swift
var name:String
var id:Int
```
Here,
•name is a variable of type String. Meaning, it can only store textual values.
•id is a variable of Int type. Meaning, it can only store integer values.

You can assign values to a variable using **=** operator.
```swift
var name:String
name="Swift"
print("My favorite programming language is:",name)
```
**Output**
```
My favorite programming language is:Swift
```
**Note:**You can also assign a variable directly without the type annotation.
For example,
```swift
var name="Swift"
```

#Constants in Swift
A constant is a special type of variable whose value cannot be changed. A constant is declared using **let** keyword.For example,
```swift
let name="John Doe"
print(name)
```
**Output**
```
John Doe
```
If you'll try to change the value of **name** then you will get an error.For example,
```swift
let name="John Doe"
name="Jonathan"
print(name)
```
**Output**
```
error: cannot assign to value: 'name' is a 'let' constant
```
**Note:**You cannot declare constant without initializing it.

#Conclusion
Thanks for reading.I hope it will help you a lot in achieving your dreams.And in next part we are going to learn about Literals in Swift.
Types of html inputs
Published: 2021-10-15 09:31:54

There are lot of **html** syntaxs for allowing inputs in our projects. 
2day let take them one after the other for better understanding..

###  Text input
```html
   <input type="text">
```
#### _input_: 
Input are reserved word in html enclosed with the opening and closing tag (< >).

#### _type_: 
Type is one of html attributes in html, they are generally use specify the type of input needed.

#### _text_:
Text is one of type_value for the input attribute **_Type_**. It's use for getting input data in form of strings or characters.

** **

### Number input
```html
   <input type="number">
```
#### _number_:
Number is one of type_value for the input attribute **_Type_**. It's use for getting input data in form of numbers.


** **

### Email input
```html
   <input type="email">
```
#### _email_:
Email is also one of type_value for the input attribute **_Type_**. It's use for getting email address. Other input aside a correct email address throw error.

** **

###  Button
```html
   <input type="button">
```
#### _button_:
Button is also one of type_value for the input attribute **_Type_**. It's use for creating buttons

** **

### Password input
```html
   <input type="password">
```
#### _password_:
Password is also one of type_value for the input attribute **_Type_**. It help to hide sensitive data.


** **

### Option input
```html
   <input type="radio">
```
```html
   <input type="checkbox">
```
```html
   <input type="range">
```
#### _radio, checkbox and range_:
They are type_value for the input attribute **_Type_**. It's use for getting multiple data at a time.

** **

### Color input
```html
   <input type="color">
```
#### _color_:
Color is also one of type_value for the input attribute **_Type_**. It's use to get color value.

** **

### Url input
```html
   <input type="url">
```
#### _url_:
Url is also one of type_value for the input attribute **_Type_**. It's use for getting url as input data.

** **

### Date input
```html
   <input type="date">
```
#### _date_:
Date is one of type_value for the input attribute **_Type_**. It's use for getting date as input from a form.

** **

### Media input
```html
   <input type="image">
```
```html
   <input type="file">
```
#### _image and file_:
These are also type_value for the input attribute **_Type_**. They are use for getting media data such as;
* Music file
* Image file
* Document e.t.c
A simple CSS Grid System
Tags: css, react, javascript
Published: 2021-10-15 15:11:46

# sc-css-grid-system

Simple CSS grid system component built with styled component for react. 
sc-css-grid-system utilizes the power of CSS grid and styled-components to easily create responsive grids.

## key features
1. responsive breakpoint xs,sm,md,lg,xl
2. responsive gutter/gap option
3. really easy to use

### Responsive Grid Example:

```javascript
import {Grid} from 'sc-css-grid-system';

function CssGridSystem() {
    return (
        <Grid xs={2} sm={3} md={4} lg={6} xl={12} gap={30}>
            <div>1</div>
            <div>2</div>
            <div>3</div>
            <div>4</div>
            <div>5</div>
            <div>6</div>
            <div>7</div>
            <div>8</div>
            <div>9</div>
            <div>10</div>
            <div>11</div>
            <div>12</div>
        </Grid>
    );
}
```
render as:
![Hnet-image (1)](https://user-images.githubusercontent.com/21342152/133593532-e4ba26fd-19e9-4b14-a919-d6d23b39a1bb.gif)

###for complete documentation and demo:
[Github repo](https://github.com/madeelahsan/sc-css-grid-system) 

### NPM
[SC-CSS-Grid-System](https://www.npmjs.com/package/sc-css-grid-system)
Emailing a user when they are assigned a case using Power Automate
Tags: dynamics365, powerautomate, powerplatform
Published: 2021-10-16 01:29:52

---
title: Emailing a user when they are assigned a case using Power Automate
published: true
date: 2021-10-11 11:50:00 UTC
tags: Dynamics365,PowerAutomate,PowerPlatform
canonical_url: https://waiholiu.blogspot.com/2021/10/alerting-user-when-they-are-assigned.html
---

Requirement - When a user is assigned a case, alert them on their personal email. 

This can be accomplished using a Power Automate flow

#### Prerequisite 

- This is done within a Power Apps environment with Dynamics 365 Customer Service (but arguably this will work for any table and not just the Case table)
- Create a cloud flow with a service account that has access to the DataVerse and ability to send email

  

#### Step 1 - Trigger when assigned user changes

  

  

| [![](https://lh3.googleusercontent.com/-zhMjhYbxr8Y/YWQjaZrp6KI/AAAAAAACb0w/-pV-EWeOi1k_0_1Vwv1JpOPhU2bLjYbdQCLcBGAsYHQ/w481-h298/image.png)](https://lh3.googleusercontent.com/-zhMjhYbxr8Y/YWQjaZrp6KI/AAAAAAACb0w/-pV-EWeOi1k_0_1Vwv1JpOPhU2bLjYbdQCLcBGAsYHQ/image.png) |
| This trigger will only be triggered when ownerid field changes  
  
  
 |

  

#### Step 2 - Identify the Assigner and Assigned user

  

[![](https://lh3.googleusercontent.com/-Cxp0mNaMvYw/YWQj7IRS3AI/AAAAAAACb04/TSuKxy5Rh70K337WCgVRcMd8v218JEmGACLcBGAsYHQ/w485-h344/image.png)](https://lh3.googleusercontent.com/-Cxp0mNaMvYw/YWQj7IRS3AI/AAAAAAACb04/TSuKxy5Rh70K337WCgVRcMd8v218JEmGACLcBGAsYHQ/image.png)
  
  

#### Step 3 - Check if the Assigned user actually has a personal email

  

[![](https://lh3.googleusercontent.com/-TGwuAGr5Mjs/YWQkMVyZodI/AAAAAAACb1A/Xvre_iylxDAeavdwBJGTi2YoeJj2_U6CgCLcBGAsYHQ/w600-h167/image.png)](https://lh3.googleusercontent.com/-TGwuAGr5Mjs/YWQkMVyZodI/AAAAAAACb1A/Xvre_iylxDAeavdwBJGTi2YoeJj2_U6CgCLcBGAsYHQ/image.png)
  
  

#### Step 4 - If so, then send them an email

[![](https://lh3.googleusercontent.com/-kAroUPEE9u4/YWQkamY_VtI/AAAAAAACb1E/gvfgu9sDkTcDNhDVInhezjJRfVdQ5ex2ACLcBGAsYHQ/w557-h444/image.png)](https://lh3.googleusercontent.com/-kAroUPEE9u4/YWQkamY_VtI/AAAAAAACb1E/gvfgu9sDkTcDNhDVInhezjJRfVdQ5ex2ACLcBGAsYHQ/image.png)
  
  

All of the fields populated in the email you'll be able to find from the steps above. The one thing is Domain Name - this is an environment variable I've created so that this solution will work as I migrate it through the various environments up to production.