teleren/devto huggingface dataset:
Running Psalm With Github Actions
Tags: staticanalysis, 100daysofcode, codenewbie, webdev
Published: 2021-04-23 08:27:46

---
title: Running Psalm With Github Actions
tags: StaticAnalysis, 100daysofcode, codenewbie, webdev
description: "I have written about Psalm here. Here, I share my workflow for running Psalm in Github Actions:"
cover_image: https://images.unsplash.com/photo-1618401471353-b98afee0b2eb?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1666&q=80
published: true
hidden: false
---

I have written about Psalm [here](https://faruknasir.com/2021/4/static-analysis-with-psalm). Here, I share my workflow for running Psalm in Github Actions:

```yaml
name: Psalm

on:
  push:
    paths:
      - '**.php'
      - 'psalm.xml.dist'

jobs:
  psalm:
    name: psalm
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: '7.4'
          extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick
          coverage: none

      - name: Cache composer dependencies
        uses: actions/cache@v2
        with:
          path: vendor
          key: composer-${{ hashFiles('composer.lock') }}

      - name: Run composer install
        run: composer install -n --prefer-dist

      - name: Run psalm
        run: ./vendor/bin/psalm --output-format=github
```

### Let's Discuss What's Happening Above

I start by specifying a name for the job. In this case, "Psalm". 

```yaml
name: Psalm
```

I, then, go on to describe when I want the job to run. I only want it to run when there is a new version of a php file or the psalm config file.

```yaml
on:
  push:
    paths:
      - '**.php'
      - 'psalm.xml'
```

Then, I go on to describe fully the actual job that needs to run. First, I specify the environment the job is going to run on. Then, I check out the code in the virtual machine.

```yaml
jobs:
  psalm:
    name: psalm
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
```

That is followed by setting up <code>PHP</code>(using a third party action) and <code>Composer</code>:

```yaml
- name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: '7.4'
          extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick
          coverage: none

      - name: Cache composer dependencies
        uses: actions/cache@v2
        with:
          path: vendor
          key: composer-${{ hashFiles('composer.lock') }}

      - name: Run composer install
        run: composer install -n --prefer-dist
```

Then, the job is finally executed:

```yaml
      - name: Run psalm
        run: ./vendor/bin/psalm --output-format=github
```

And, that's that!

This post first appeared [here](https://faruknasir.com/2021/4/running-psalm-with-gh-actions)
What are the going rates for Laravel developers ?
Tags: laraveldevelopment
Published: 2021-04-23 08:25:59

In India the rates are to hire a Laravel Developer is $15 to $30(per hours). As PHP enthusiasts are early adopters of the Laravel framework for web application development. We are among the top Laravel Development Company with extensive tech expertise in delivering more than 50 Laravel web applications. We have perfected the craft of solutions design with this technology and frequently use it in development projects for best web applications.
 
What can we develop in Laravel?
•	E-Learning Management System.
•	Payment gateway and Shipping module integration
•	Development of web applications with XML feed
•	Ad word and banner-based exchange functionalities
•	Real Estate portal
•	Social networking communities and website development
•	Online Hotel Booking and Comparison system
•	Auctions and Reverse auctions applications
•	E-commerce web-based systems
•	Online CRM Solutions
Our developers have good experience and follow latest standard for developing any application. Laravel is one of the most secure and popular PHP frameworks today. Contact Us.
Writing Maintainable Unit Tests In Print
Tags: books, tdd, unittests, softwaredesign
Published: 2021-04-23 08:17:16

I’m very happy to announce that **Writing Maintainable Unit Tests** is also available as a paper book. Both the ebook and the paper book have been completely self-published. I must say that this whole endeavour was quite an educational experience.

[![Paper book 'Writing Maintainable Unit Tests'](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dhlu0hm91hrrfusqpam6.png)](https://leanpub.com/writing-maintainable-unit-tests)

The ebook is still available on [LeanPub](https://leanpub.com/writing-maintainable-unit-tests). The paper book can be purchased at most leading book stores:

- [Amazon](https://www.amazon.com/Writing-Maintainable-Unit-Tests-Mastering/dp/9464334576)
- [Barnes & Noble](https://www.barnesandnoble.com/w/writing-maintainable-unit-tests-jan-van-ryswyck/1139103967)
- [Book Depository](https://www.bookdepository.com/Writing-Maintainable-Unit-Tests-Jan-Van-Ryswyck/9789464334579)
- [IndieBound](https://www.indiebound.org/book/9789464334579)
- [Alibris](https://www.alibris.com/booksearch?mtype=B&keyword=9789464334579)

For more information, you can have a look at the full [table of contents](https://leanpub.com/writing-maintainable-unit-tests).
PHP null-safe and null-coalescing operators
Tags: php, 100daysofcode, codenewbie, webdev
Published: 2021-04-23 08:10:50

---
title: PHP null-safe and null-coalescing operators
tags: PHP, 100daysofcode, codenewbie, webdev
description: "The null-safe operator supports method while the null-coalescing operator doesn't. The null-coalescing operator supports array while the null-safe operator doesn't."
cover_image: https://images.unsplash.com/photo-1599507593362-50fa53ed1b40?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1650&q=80
published: true
hidden: false
---

### Null-coalescing Operator (??)

PHP7 came with syntactic flavourings we all have been savouring ever since its release - One of which is the null-coalescing operator. If you have ever had to use the `ternary` operator together with `isset()` method, then this was <code>tailor-made</code> for you!

```php
$developer_status = $coding ?? $sleeping;

// is equivalent to
$developer_status = isset($coding) ? $coding : $sleeping;
```

It returns the first operand if true, otherwise returns the second. It is also chainable:

```php
$developer_status = $coding ?? $sleeping ?? $eating;
```

### Null-safe Operator (?->)

The null-safe is a PHP8 feature that, instead of throwing an exception, short-circuits to null when a chained property or method access is null and the rest of the chain is skipped. 

It is an <code>elegant</code> way of wrapping `is_null` around each property or method access.

Let's examine the following code snippet:

```php
$recentlyActive = null;

if (session()->has('user')) {
    $user = session('user');

    if (! is_null($user)) {
        $lastLoggedIn = $user->lastLoggedIn();

        if (! is_null($lastLoggedIn)) {
            $recentlyActive = $lastLoggedIn->withinLast7Days();
        }
    }
}
```

With null-safe operator, we can be more efficient by writing less and clearer code:

```php
$recentlyActive = session()->has('user')?->lastLoggedIn?->withinLast7Days();
```

### Versus

What is the difference between null-safe operator and null-coalescing operator. <code>Hint: it's not just in the syntax, it is also in the semantics.</code>

The null-safe operator supports method while the null-coalescing operator doesn't. The null-coalescing operator supports array while the null-safe operator doesn't.

```php
// this works
$array = [];

var_dump($array['mukulli']->kofa ?? null);


// this throws a warning
var_dump($array['mukulli']?->kofa);

// Warning: Undefined array key "key"
```

Null-safe with methods:

```php
class Order
{
    public function date(): ?Carbon { /* … */ }
    
    // …
}

$order = new Order();

var_dump($order->date()?->format('Y-m-d'));

// null
```

This post first appeared [here](https://faruknasir.com/2021/4/php-nullsafe-null-coalescing-operators)
Iconic developers | part 4  🤷‍♀️🐙🤑
Tags: webdev, discuss, programming, watercooler
Published: 2021-04-23 08:08:57

# Almost weekend!😎
But first another iconic developers 😊

Special thanks: @theowlsden and @technoglot 🦄

Feel free to join and show your creativity! 
#### Let's make the next one a monkey edition (🙈🙉🙊). 😎
___
## 🤷‍♂️ The WOMM developer
Works On My Machine is their go to answer. While this is true (mostly) they usually forgot to commit the changes in their package.json (or something else that breaks the code outside their own machine...).

#### Habitat
Their own machine. The rest of the machines are not good enough for them. 😲

#### Best to ask for 
What dependencies you're missing when his code doesn't work, again. 😅

#### Needs work on
Own up to their mistakes, keep calm when installing something new and do it the proper way. 😊

___

## 🐙 The unfortunate full-stack
They know the whole stack of a company. Not because they want to work as a full-stack, but because they have a small team.

## Habitat
You find them mostly in start-ups and scaleups. But you can also find them in specific departments of a mid-size company.

## Best to ask for
Advice on how you can implement a piece of logic. They most probably did something similar once upon a time. Oh, and about the frontend, ask them the basics.

## Needs works on
Delegating tasks. If they have a small team, they need to share the responsibilities, not take everything on themselves.

> https://dev.to/theowlsden/comment/1dicj

___


## 🤑 The Client's Butler 
That person in the team, (sometimes a team lead) who's motto is: "The client is KING!". They tend to be very client-centric and say NO to whatever brings no value to the client. All else be damned, including the developer experience. 😢

#### Habitat
This kind of developer is mostly found lurking around stakeholders and clients to obtain their wishes.

#### Best to ask for
What the client wants, they now every single wish by heart.

#### Needs work on
Accepting developer experience is king in getting the client what they wish for in time and with joy! 😍

> https://dev.to/technoglot/comment/1denl

___

Soooo that's three again 😁

Looking forward to your input

```markdown
## 💻 [name]

#### Habitat

#### Best to ask for

#### Needs works on
```
   
> Photo by <a href="https://unsplash.com/@girlwithredhat?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Girl with red hat</a> on <a href="https://unsplash.com/s/photos/nerd?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>
So, you want to call a program from vim?
Tags: vim, programs, tips
Published: 2021-04-23 08:07:53

Sometimes I'm editing a file and I need some part of the results of executing some program:

     [myMachine] > ~/somePath/someProgram someArgument | tee /somePlace

In [How do I run a C program from VIM?](https://stackoverflow.com/questions/2627886/how-do-i-run-a-c-program-from-vim) they tell us:

    :!~/somePath/someProgram someArgument | tee /somePlace

And it works.
5 JAVASCRIPT PROJECTS FOR BEGINNERS TO HELP YOU UNDERSTAND HOW TO MANIPULATE THE DOM (Document Object Model)
Published: 2021-04-23 08:07:01


If you want to become a web developer, you need to start practicing your JavaScript skills as soon as possible. However, I know it may sometimes feel difficult for beginners to find JavaScript project ideas that help them understand how javascript is used to manipulate the web.

To help you get started, I’ve put together a list of 5 easy and basics Javascript projects you can start building right now.

I want you to browse through the list and click through to any JavaScript project you find intriguing. If you find a project idea that matches your goals and skill level, start building it right away!

Each of these projects is open-source, meaning you can use the source code for guided learning as you go.

Let’s dive right in!

1: HIDDEN SEARCH


![hidden search.gif](https://cdn.hashnode.com/res/hashnode/image/upload/v1618320081580/WUD-1kxvy.gif)

2: PROGRESS BAR



![Progress Bar.gif](https://cdn.hashnode.com/res/hashnode/image/upload/v1618320178832/Bd33EF3pz.gif)



3: MODAL POPUP



![Modal pop up.gif](https://cdn.hashnode.com/res/hashnode/image/upload/v1618320250125/NtzCgzK5P.gif)



5: FAQ



![FAQ.gif](https://cdn.hashnode.com/res/hashnode/image/upload/v1618320291976/OjyCgZ7eN.gif)



6: NIGHT MODE (BONUS)



![Night Mode.gif](https://cdn.hashnode.com/res/hashnode/image/upload/v1618320333408/knJV3B2Y1.gif)


Please feel free to download all the folders from my GitHub repositories enjoy !.

https://github.com/mfuke92/5-javascript-DOM-project-for-beginers
Checking for a Palindrome using Javascript built-in functions
Published: 2021-04-23 07:55:15

#CHALLENGE

Return 'true' if a word is a palindrome and 'false' if not.

# EXPLANATION

What is a Palindrome? It is a word or a sentence that is spelled the same both forward and backward, ignoring the punctuation, casing, and spacing. An example is the word 'Racecar'. To check for a palindrome in Javascript, you will need to remove all non-alphanumeric characters(punctuations, symbols, and spaces)then turn all the letters into lowercase.

In order to remove the non-alphanumeric letters, we shall use a Regular Expression(Regex). Regular Expressions are patterns used to match character combinations in strings. The Regex used to match any non-alpha-numeric characters is '[\W_]' which can be expounded to read '[^A-Za-z0–9]'.

# SOLUTION

For this solution, we will use several methods:
a. toLowerCase() which will return all the characters in the string in lowercase.
b. .replace() which will return the replaced string(only alpha-numeric characters) by the Regular Expression we just created.
c. .split() which will split the returned string into and return an array of characters.
d. .reverse() which will reverse the order of the characters in the array.
e. .join() which will join the reversed characters into a string.

Here is the complete code for this:
```
const str = 'A man, a plan, a canal. Panama';

function palindrome(str) {

//Remove all the non-alphanumerics and turn the string to lowercase

var lowRegStr = str.replace(/[^0-9a-zA-Z]/g, '').toLowerCase();

// Split the returned string, reverse the characters ,join them, and return the reversed string.

var reverseStr = lowRegStr.split('').reverse().join('');
return reverseStr === lowRegStr;
}

console.log(palindrome(str));
```
This will log 'true' if the string is a palindrome and 'false' if otherwise.
Why you shouldn't hire clones. 
Published: 2021-04-23 07:40:18

We have all been there. One of your best employees hands their notice in and your stomach does a little flip as you know how important they are. 

You try your best to see if you can do anything to keep them but they explain this is an opportunity they can't turn down. So your attention turns to trying to find someone to replace them.  

You tell your recruiter we need another "Sarah"! You want someone with the exact same skills so they can come in and "hit the ground running".

Is this the right approach?

Pause for a moment and ask yourself why would someone move roles to do the exact same job they are doing now?

Of course, this does happen sometimes, for example, if someone has been made redundant. 

If you did hire that person how long will it take for them to get bored doing the same thing they have done for the last 3 years? Probably not long. This will likely mean after spending 1 year to 18 months with you they start looking for something more challenging and will provide better progression opportunities. 

Then you are left in the same place as they were before, looking to hire someone doing the exact same job because you need them to "hit the ground running". And so the cycle continues. 

Still, the biggest reason I hear for people looking to move roles is so they can learn and develop. If you can't provide that to a candidate then it will cause more pain further down the line. 

So rather than going for a like for like replacement consider if hiring someone who perhaps doesn't have all the skills just yet but has the potential, ambition and correct attitude to attain them. If someone has something to work towards or aim for my experience is that they are far more motivated in the position. 

Yes, this will mean a bit more time is needed on your part but that initial investment will usually lead to a brilliant new employee. I have seen it many times where people in this scenario have gone on to be a brilliant contributor to the business and they have more loyalty and appreciation for the business as they have profited as well. 

So, don't just mindlessly look for clones of your previous employees.
Look at your current roles and expectations. Are they realistic? Hire for potential.
Learn JS with me #000
Tags: javascript, learn, webdev, beginners
Published: 2021-04-23 07:22:02

Javascript, one of the most popular scripting languages we use.
Javascript unlike other languages doesn’t require any installation of some compiler or anything like that, it is just implemented by our regular web browsers.

Javascript also has some set of rules that every browser needs to follow. It is decided by ECMA.

ECMA releases something called as ECMAScript which is a document consisting of the updates that browsers need to implement. 

Since 2015, these updates have become more regular, they release updates like ES2015, ES2016, ES2018 etc.

Whenever updates (new release) are released it is not you who needs to update the Javascript of the browser, it is the browser that needs to implement that given release by ECMA.

That is the reason, web developers are pissed off of the Internet Explorer because, it is not keeping up with the new releases of JavaScript.

![Meme](https://i.redd.it/uyrnep7602i51.png)
Credits : r/ProgrammerHumor
4. Median of Two Sorted Arrays

Published: 2021-04-23 07:11:37

Problem #4: https://leetcode.com/problems/median-of-two-sorted-arrays/

Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays.
 
*Example 1:*
```
Input: nums1 = [1,3], nums2 = [2]
Output: 2.00000
Explanation: merged array = [1,2,3] and median is 2.
```
*Example 2:*
```
Input: nums1 = [1,2], nums2 = [3,4]
Output: 2.50000
Explanation: merged array = [1,2,3,4] and median is (2 + 3) / 2 = 2.5.
```
*Example 3:*
```
Input: nums1 = [0,0], nums2 = [0,0]
Output: 0.00000
```
*Example 4:*
```
Input: nums1 = [], nums2 = [1]
Output: 1.00000
```
*Example 5:*
```
Input: nums1 = [2], nums2 = []
Output: 2.00000
```

##Solution

```js
/**
 * @param {number[]} nums1
 * @param {number[]} nums2
 * @return {number}
 */
var findMedianSortedArrays = function(nums1, nums2) {
    let sortedArray = [...nums1, ...nums2].sort((a,b) => a-b);
    let median = 0;
    
    if (sortedArray.length % 2 !== 0) {
        median = sortedArray[Math.floor(sortedArray.length / 2)];    
    } else {
        median = (sortedArray[(sortedArray.length/2)] + sortedArray[(sortedArray.length/2) -1])/2;
    }
    
    return median;
};
```
Top 50 React JS Interview Questions.
Tags: react, webdev
Published: 2021-04-23 07:07:26

Q1: What is React?

Ans. React is a front-end JavaScript library that mainly follows the component-based approach for building a user interface (UI) components for a single page application. It is also used for handling the view layer in both mobile and web apps. Moreover, react plays a crucial role in developing interactive mobile and web UIs. It was created and developed by Jordan Walke; it was deployed first on the Facebook newsfeed in 2011.

Q2: Why React is used?

Ans: The following reasons make one to use React for building User Interfaces (UI), and they are:

Easy to learn nature
Simplicity
High scalability
Increase performance
Also Read: Full Stack Developer Interview Questions

Q3: How React works?

Ans. Below is the sequence of steps which gives an idea about how does react work

Firstly the react runs the diffing algorithm to identify the changes that are made in the virtual DOM.
Next step is reconciliation, this is used to update the DOM as per the new features.
Now, the virtual DOM, which is lightweight in nature and is detached from the specific implementation of the browser.
Followingly the ReactElements which are present in virtual DOM are used to build basic nodes.
Finally, if the ReactComponent changes the state; the diffing algorithm runs faster and identify the changes. After identification, it automatically updates the DOM with the change difference.
Q4: What are the features of ReactJS?

Ans: The features of React JS are as follows:

1. React improves SEO performance
React boost the performance of the SEO to higher levels as a search engine faces the problem while reading JavaScript of high loaded applications.

2. React acts as a standard for mobile app development
It provides a transition process as an ideal solution for both mobile and web applications for building rich user interfaces.

3. React makes the process of writing components easier
Using React along with JSX will make you write components and code efficiently and clearly.

4. React increases efficiency
As the React boost the efficiency of components by reusing them. This is the reason why it is considered as an ideal feature of React. It is considered as the most reusable system component.

5. React ensures stable code

It ensures the stability of the code of an application by making use of downward dataflow.

For more information vist :<a href="https://mindmajix.com/reactjs-interview-questions">Mindmajix React Interview Questions</a>.

Want to expert in react js then join our <a href="https://mindmajix.com/react-js-training">Mindmajix React JS Training</a> Now
Refactoring in the kitchen?
Tags: programming, productivity, testing
Published: 2021-04-23 06:59:52

---
title: Refactoring in the kitchen?
published: true
description: Kitchen sink and refactoring
tags: #programming #productivity #testing
cover_image: https://thumbs.dreamstime.com/b/messy-dirty-kitchen-compulsive-hoarding-syndrom-pile-dishes-178422415.jpg
---

Most people when they are cooking they create a lot of dirty dishes. They might even leave the dishes in the sink after dinner, but then in the morning they clean up everything because they know when they will want to cook again they need the clean dishes.

This is the same with programming.

You might be in a hurry to implement a feature or fix a bug and push it out to the customers, but then, once you are done you go back and clean up the mess you left because you know that next time you need to change this code you'd like to arrive to a clean environment.

To facilitate a safe refactoring environment you would write tests.
Laravel 8 Resize Image Before Upload Example Tutorial
Tags: laravel, php, tutorial
Published: 2021-04-23 06:52:54

Today, I will learn you how to resize image before upload in laravel 8. we will show example of resize image before upload in laravel 8.if you want to see example of laravel 8 generate thumbnail image then you are a right place. we will help you to give example of laravel 8 resize image before upload.I will explain step by step tutorial laravel 8 resize image.
more....
https://itwebtuts.blogspot.com/2021/04/laravel-8-resize-image-before-upload.html
Day 40 of 100 Days of Swift
Tags: swift
Published: 2021-04-23 06:45:15

I just completed day 40 of 100 days of code. Today I worked on implementing the list screen of the Moonshot app. Moonshot is an app that shows a list of Apollo launches.

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

Here's a link to the github [repo](https://github.com/sanmiAde/Moonshot)