teleren/devto huggingface dataset:
My understanding of  Event loops in Node.js
Published: 2020-01-24 08:23:28


I have been hearing about Node.js for quite some time and whenever they talk about it, my mind is filled with a lot of different questions as to what it exactly is, what it does, it’s limitations and whether it will remain useful in the future.

Node.js is a Javascript runtime environment which means that its environment has everything that is required to run app programs written in javascript, I think of it as an extension to  to make it more worthy as new technologies are being built eventually. A few years ago all that javascript could do was making websites interactive but with Node.js it can do much as a standalone application.  

Sticking to the point, let us talk about  event loops in Node.js. This is what makes Node.js perform non-blocking Input/Output operations. Usually, when Node.js starts, it first initialises the event loop, processes the input script and then begins processing the event loop.
Node.js is asynchronous and circular with event loop at its core looping at a constant frequency and with high-speed processing callbacks during each phase of that loop. I personally think that when a Node app seems to feed out steps that are out of order it’s probably the developer that didn’t clearly understand the event loop and its phases. Someone could wonder if one can write Node apps without solid prior knowledge to event loops, yes you can but you would write far better applications with a good understanding of event loops in mind.
As we said earlier every Node.js event loop application runs through phases. When I was writing this series I found an overview from the Node team(nodejs.org) and decided to take it a little further as it highlights the most important phases and their uses in  event looping.
Make the collection find using Go bongo.
Tags: go, mongodb
Published: 2020-01-24 08:20:14

---
title: Make the collection find using Go bongo.
published: true
description: 
tags: go, mongodb
---

For example, we have a collection of users and we want to find all `users` from this collection.


**If you don't have bongo installed, you can install it as follows.**

    go get github.com/go-bongo/bongo


```golang
package main

import (
  "log"

  "github.com/globalsign/mgo/bson"
  "github.com/go-bongo/bongo"
)

type User struct {
  bongo.DocumentBase `bson:",inline"`
  Username          string
}

func main() {

  // Bongo Connection Config
  config := &bongo.Config{
    ConnectionString: "localhost",
    Database:         "test",
  }

  connection, err := bongo.Connect(config)

  if err != nil {
    log.Fatal(err)
  }

  // Let's see how we can get the user list using bongo.

  user := &User{}
  users := []User{}

  find := connection.Collection("users").Find(bson.M{})

  for find.Next(user) {
    users = append(users, *user)
  }

  log.Println(users)

  /*
    2020/01/24 11:12:51 [{{ObjectIdHex("5e29cd071c291d4f567c482c") 2020-01-23 16:42:47.276 +0000 UTC 2020-01-23 16:42:47.276 +0000 UTC true} Testy McGee male} {{ObjectIdHex("5e2a9e84e30560746c0459c9") 2020-01-24 07:36:36.02 +0000 UTC 2020-01-24 07:36:36.02 +0000 UTC true} yasiari İÇLİ ERKEK}]
  */
}
```

It's simple and short.
Laravel clear all cache with one command
Tags: laravel, php, artisan, console
Published: 2020-01-24 07:49:19

---
title: Laravel clear all cache with one command 
published: true
description: A nice little helper command to clear all kinds of cache in Laravel
tags: laravel, php, artisan, console
---

Today I learned about a Laravel Artisan command which helps clear all kinds of cache at once.

Behold,

`php artisan optimize:clear`


Let's see the output of this command:


![laravel-optimize-clear-command](https://thepracticaldev.s3.amazonaws.com/i/m7k7bgobcva76xti5jdh.png)

That's right! Laravel has all sorts of caching to make it speedy that it is.
Creating a project/web application of student test in which we collect inputs from “Form” and will store them in DB
Tags: javascript, php, webdev, jquery
Published: 2020-01-24 07:39:28

I am Creating a project/web application in which we collect inputs from "Form" and will store them in DB. Will access data in future for further calculation and show the result.

So i want to know in what language i should start that project in php or java?

Details of project/web application:

1. First there will be a pre form which will just create a little entry in db
2. then on the bases of that little entry new complete full test will be started
3. After completion of test from step 2 result will be stored in same data entry for further calculation
4. After calculating result will be shown to user

So how do we plan this kind of project, do we need sessions in them to change those form windows or normal jquery will do that.

Most importantly if someone can relate me with the structure of this project or if someone have same pre created any project, link, website, web application anything they can refer that will be really helpful.

I know i am sounding lame but yes i am beginner in this.

Thanks.
Sass backgroung img issue
Published: 2020-01-24 07:33:58

{% stackoverflow 59890870 %}


I used this code painted all items on body, I need only image on the body background

$fondo: url(/grid/assets/img/backimage.png);

{ padding: 0; margin: 0; } body { ::before{

content:"" ; height: 1008px; width: 100%; display: flex; position: absolute; 
background-image: $fondo ; background-repeat: no-repeat ; background-position: 
center; background-size: cover; filter: blur(1.6rem);

}

}
Creating a stopwatch in Javascript and learning something
Tags: javascript, opensource
Published: 2020-01-24 07:09:19

Hello, this is my first blog post on this site. I'm planning to have some content on here apart from Medium. So, here goes.

I've been thinking of getting back into web development. Specifically, web app development consisting of Node.JS and the rest of the javascript world. So, I've decided to make small websites here and there just to refresh my memory. In this post, I will talk about a bug I encountered when I was building a stopwatch.

This is the code for the main functionality controlling the stopwatch.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/dkq7dz2xqv832esgux3b.png)

I thought it was okay until this happened.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/ta5ceg6z38qyowajgxk6.png)

As you can see, the seconds is okay. But the minutes and hours are not. My code appended "0"s each time it passes through this part here.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/3brtkcyd8mrpzvrw9rub.png)


When I looked at the code, I expected minutes to remain at 0 since "0" + minutes is equals to 0. And I also expected minutes to go "00", "00" and so on and so forth.

So, when I look at this behaviour, I realise only strings have this behaviour, not Numbers.

I added some console logs to the code and checked for type.


![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/cvw5d7jyynyxgemllotj.png)

And this was what showed up.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/dr5sn5s6nsg38bnfanaf.png)

Now it is starting to make sense. That was why it appended the "0" instead of adding. 

In conclusion, I still do not know what to expect when I add 2 variables together. But now, I know a little more.
EF Core Migration Commands
Tags: efcore, dotnet, entityframework, entityframeworkcore
Published: 2020-01-24 06:59:58

---
title: EF Core Migration Commands 
published: true
description: Entity Framework Core Migration Commands
tags: efcore, dotnet, entityframework, entityframeworkcore
---

EF Core Migration (Commands using either Visual Studio, CLI )


![Commands](https://thepracticaldev.s3.amazonaws.com/i/ailqrpl12qnp5ckqdarf.PNG)
Eye-Opening Cybersecurity Statistics for 2020
Tags: security, showdev, beginners
Published: 2020-01-24 06:50:04

We did extensive research about Cybersecurity and picked quite a few of the most relevant and reputable Cybersecurity statistics for 2020: 

https://topvpn.review/cybersecurity-statics/

Here is the glimpse from that article: 

1: NEARLY HALF of the American small businesses suffered a cyber-attack last year.

2: MOST of those small businesses fail to act after an attack.

3: Over 85% of the email was spam in July 2019.

4: The most common malicious attachments in email are Microsoft Office files.

5: Cybercriminals have been a more pervasive threat than hackers recently.

6: Phishing has been the most common attack type.

7: One in ten URLs are malicious.

8: Most Internet-of-Things (IOT) attacks hit routers.

9: Over a QUARTER of internet users worldwide use a VPN or proxy.

10: Network vulnerabilities are far more common than application vulnerabilities.

There are lots of stats out there on cybersecurity, but the game is constantly changing, and that’s why we found the most reliable recent stats and put them here.

Read Cybersecurity Statistics for 2020 to know more: https://topvpn.review/cybersecurity-statics/

These are our stats and finding, what are yours?

Share in a comment!
git clone a repository to multi directories
Tags: git
Published: 2020-01-24 06:15:53

## 🤔 Situation
There is a repository.

```sh
$ ls -l
scene-saver
```

Is it possible to have another directory of the same git repository?

## 👍 YES
```sh
git clone git@github.com:n350071/scene-saver.git scene-saver-2
```

Then,

```sh
$ ls -l
scene-saver
scene-saver-2
```
Spring batch - changing default data-source
Tags: spring, batch, java
Published: 2020-01-24 05:51:33

I had recently started learning [Spring-Batch](https://spring.io/projects/spring-batch) and followed the very first Getting started [guide](https://spring.io/guides/gs/batch-processing/).
The default datasource used by Spring-batch is HSQL as an in-memory database, good enough for local development. But you may not only use that in production code. You can change that datasource to yours with the following configurations:

```properties
spring.datasource.url=<jdbc:url:for-your-database>
spring.datasource.username=<db-username>
spring.datasource.password=<db-password>
```

All `spring.datasource.*` properties are bound to the fields of `org.springframework.boot.autoconfigure.jdbc.DataSourceProperties` class.
Google I/O 2020 will take place from May 12-14
Tags: news, google
Published: 2020-01-24 15:51:43

---
title: Google I/O 2020 will take place from May 12-14
published: true
date: 2020-01-24 05:38:10 UTC
tags: News,Google
canonical_url: https://www.xda-developers.com/google-i-o-2020-may-12-14/
---

Google is known for using cryptic puzzles as a way to announce the date of its annual Google I/O developer conference. Back in 2017, the search giant published an online brain teaser containing the dates of Google I/O 2017. The next year, the company [shared a puzzle](https://www.xda-developers.com/google-i-o-2018-may-8-shoreline-amphitheater/) through the Google Developers Twitter account, which redirected users to the Google I/O 2018 website that had been turned into an escape room-style Google Maps Street View experience in a Google campus building. Last year, the company [released another cryptic message](https://www.xda-developers.com/google-io-2019-may-7-9/) to announce the dates for Google I/O 2019 and fans were expecting the company to share a similar enigma this year as well. However, it seems like Google has now given up on this annual ritual as the company’s CEO, Sundar Pichai, recently took to Twitter to announce the dates for Google I/O 2020.

> Cosmos aligned. We’ll be back at Shoreline Amphitheatre in Mountain View for this year’s [#GoogleIO](https://twitter.com/hashtag/GoogleIO?src=hash&ref_src=twsrc%5Etfw) on May 12-14! [pic.twitter.com/3bZqriaoi1](https://t.co/3bZqriaoi1)
> 
> — Sundar Pichai (@sundarpichai) [January 24, 2020](https://twitter.com/sundarpichai/status/1220497572898340864?ref_src=twsrc%5Etfw)

<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

Pichai, who was [appointed as the CEO of both Alphabet and Google](https://www.xda-developers.com/larry-page-sergey-brin-make-sundar-pichai-ceo-alphabet-google/) towards the end of last year, shared a short GIF on the micro-blogging platform along with the dates for Google I/O 2020. As per his tweet, Google I/O will be held at the Shoreline Amphitheatre in Mountain View, California from May 12-14. At this year’s I/O developer conference, we expect Google to showcase the next major Android release — Android 11. Much like last year, the company is also expected to share new features and updates for its vast portfolio of apps. The company might also [release new hardware](https://www.xda-developers.com/google-confirms-new-hardware-announcement-io-2019-trouble-selling-pixels/), including an update for the Pixel 3a series which was [showcased at the event last year](https://www.xda-developers.com/google-pixel-3a-3a-xl-specs-features-price/).

The post [Google I/O 2020 will take place from May 12-14](https://www.xda-developers.com/google-i-o-2020-may-12-14/) appeared first on [xda-developers](https://www.xda-developers.com).
Oscars 2020 Ballot - My Coding Adventures - Ep 1
Tags: googleappsscript, javascript, oscars
Published: 2020-01-24 05:03:56

---
title: Oscars 2020 Ballot - My Coding Adventures - Ep 1
published: true
description: Follow along as I create a Google Forms-based Oscars ballot for a 2020 pool, with web scraping and Google Apps Script.
tags: google-apps-script,javascript,oscars
---

Hello.

Today, I posted my first ever ["coding follow-along" to YouTube](https://youtu.be/jhf5KJdQZsg). My goal was to create a Google Forms hosted Oscars ballot that I could share with my 2020 pool members. 

To create this form, I used a combination of web scraping and the Google Apps Script Form Service class. The web scraping piece was inspired by some of the great Wes Bos' videos.

As this was my first ever video, the quality **isn't amazing**. I don't own a nice mic (used AirPods) and I left in all of my "uhhs" and "umms". 

All feedback is welcome. I've shared my [finished code here](https://gist.github.com/cashlion/279de14edcf380c7eaf3918d68ead4ce) and anyone interested in joining the pool for fun can [enter here](https://docs.google.com/forms/u/0/d/1yHxOo1HqdP8ar9ALBbSMrMS3uMrs1-2x4OHwzJ0SeI8/edit).

Thanks. 👨‍💻
Doubly Linked List Data Structure and operations
Tags: data, structure, computerscience
Published: 2020-01-24 04:27:30



![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/p22fxcm9jo11sbc3lytw.png)

A Doubly Linked List Data Structure will have nodes that have:

1. Data
2. Address which points to the **next** node
3. Address which points to the **previous** node

So navigation is possible both ways (forwards and backwards).

##  Operations
| Operation Name    | Operations          
| ------------- |:-------------:| 
| Insertion    | Insertion at the start,end and after a particular node| 
| Deletion     |Deletion at the start,end and of a particular node|  
| Traversing | Going through each node and performing some action|    
| Searching| Comparing each data node with some item being searched for| 
| Reverse| Reverse the entire list|    
| Update| Modify a data node with a given value|       

## Implementation in C++

We know that each node in a doubly linked list (DLL) has 3 parts:

1. Data
2. previous pointer 
3. next pointer

So let's code the basic structure/blueprint of a DLL

```
#include <iostream>
using namespace std;

//declare a structure data called Node
struct Node { 
//declare integer data type called data
   int data; 
//declare the previous & next pointer of the *Node* structure data type
   struct Node *prev; 
   struct Node *next; 
}; 

```
Swift Lesson 12 Discussion
Tags: swift, codenewbie
Published: 2020-01-24 04:14:25

1.	<h3><em><i>How is a method different from a property?</em></i></h3>

A function that can be defined as a part of a type. An example of a “method” would be 
“.hasSuffix()”, 

in use, you would use an instance in a variable or constant, for example “let example = “Hello”” 

immediately followed by a period, and then the method: example.hasSuffix() 
and the method would return a Boolean.


2.	<h3<em><i>What is the difference between a type and an instance?</em></i></h3>

An instance is always related to the type. If your code is 
“let example = “String”” 
your TYPE(example) is a string, and the instance would be in the parenthesis(String). 

If it were numerical, it would be 
“let numberedExample = 100”” 

the type(numberedExample) would be an integer, and the instance would be “100” without the quotations.
Google is a ad company, make no bones about it.
Tags: protech, search, advertising, seo
Published: 2020-01-24 03:22:46


SAME SAME BUT DIFFERENT

google blurs the line between paid and organic serps in new search listing results design,

oh boomers gonna love this….

<img src="https://media-exp2.licdn.com/dms/image/C5122AQFGZiKdc9bZaw/feedshare-shrink_2048_1536/0?e=1582761600&v=beta&t=bpYkcpZbCkAlz5aBOltaxv_lbUMijquqxSsVaF_FLdk" />

you’re welcome.

On January 13, Google rolled out a new design for search results on the desktop. Of course, this design isn’t exactly new, it has been around on mobile since last year.

<img src="https://thepracticaldev.s3.amazonaws.com/i/qp3qxz61enfztzfvdd9y.png"/>

One of the most significant changes to come from the desktop redesign is the new favicons that appear next to URLs.

This was in an effort to help (#dontbeevil) sites with branding and made it possible to see if the results are coming from one of your favorite or most trusted sites with a quick look instead of having to read the URL.

However, this redesign also blurred the lines between organic search results and ads by placing an “Ad” icon next to advertisements in the results. While the ads are still clearly labeled, the streamlined design now makes it easier for some users to mistake ads for actual search results. 

<a href="https://diakrit.com>PropTech</a> company DIAKRIT said it will cause confusion with users who have trouble choosing between the two.


https://www.youtube.com/watch?v=hxZh3XMna20

Make no bones about it, google is a ad company.

SERGIO
enjoy….
Sitecore sometimes doesn't throw an exception when item creation fails
Tags: sitecore
Published: 2020-01-24 03:01:21

In Sitecore, you would use the `Item.Add(string name, TemplateID templateID, ID newItemID)` method to create an item. This method has a strange behavior when item creation fails.

There are three causes of failure:

1. An inexistent template is specified.
2. An invalid item name is specified.
3. A context user has no creation rights.

In those cases, only the first one is when **the method returns null without throwing an exception**. See the next examples.

```csharp
var home = Context.Database.GetItem("/sitecore/content/Home");

// An inexistent template is specified
home.Add("case1", new TemplateID(ItemIDs.Undefined)); // => null

// An invalid item name is specified
home.Add("case/2", new TemplateID(TemplateIDs.Folder)); // => InvalidItemNameException

// A context user has no creation rights
var user = User.FromName("sitecore\\access denied user", isAuthenticated: true);
using (new UserSwitcher(user))
{
    home.Access.CanCreate(); // => false
    home.Add("case3", new TemplateID(TemplateIDs.Folder)); // => AccessDeniedException
}
```

Furthermore, one more unusual behavior appears when supplying null to argument. We typically expect the method to throw the `ArgumentNullException` in that case. But it returns null when specifying `ID.Null` to the `newItemID` argument.

```csharp
var home = Context.Database.GetItem("/sitecore/content/Home");

// Specify null to item name
home.Add(null, new TemplateID(TemplateIDs.Folder)); // => ArgumentException

// Specify null to template ID
home.Add("test", null, ID.NewID); // => ArgumentNullException

// Specify null to item ID
home.Add("test", new TemplateID(TemplateIDs.Folder), null); // => ArgumentNullException

// Specify ID.Null to item ID
home.Add("test", new TemplateID(TemplateIDs.Folder), ID.Null); // => null
```
This result is due to be used `Assert.ArgumentNotNull` instead of `Error.AssertID` for the argument assertion.

In conclusion, it goes without saying, we must not only handle an exception thrown but also check whether the return value is null.

Thank you.
Refactoring "if" statements with lookup arrays in PHP/Laravel
Tags: php, laravel, lookuparrays, refactoring
Published: 2020-01-24 02:58:03

---
title: Refactoring "if" statements with lookup arrays in PHP/Laravel
published: true
description: Refactor if statements with lookup arrays in PHP/Laravel
tags: php, laravel, lookup-arrays, refactoring
---

Let's dive right into an **example**.

I was working with third party JSON data which arrives from Webhook request. That data contains information about a Customer. Our interest was to get the "Phone Number" of that customer. 

**NOTE: this is third party data and we have no control over it.**

There were **four** possible places where we could find Phone Number in that data.
 
* Directly on incoming data object ( first level )
* In "Customer" object inside data object
* In "shipping_address" object inside data object
* In "billing_address" object

**These objects may or may not exist all in same time in a Webhook** therefore I had to check with `property_exists`.


```php
    protected static function extractPhone(object $webhookData): ?string 
    {
        if($webhookData->phone){
            return $webhookData->phone;
        }


        if(property_exists($webhookData,'customer') && $webhookData->customer->phone){
            return $webhookData->customer->phone;
        }

        if(property_exists($webhookData, 'shipping_address') && $webhookData->shipping_address->phone){
            return $webhookData->shipping_address->phone;
        }

        if(property_exists($webhookData, 'billing_address') && $webhookData->billing_address->phone){
            return $webhookData->billing_address->phone;
        }

        return null;
    }

```

Now let's refactor this code with "lookup" array. 

We can make an array of "properties" that we need to check, right?

```php

$lookupProperties = ['customer', 'shipping_address', 'billing_address'];

```

and then loop over these properties like below:

```php
foreach ($lookupProperties as $lookupProperty){
    if(property_exists($lookupProperty, $webhookData) && $webhookData->{$lookupProperty}->phone){
                return $webhookData->{$lookupProperty}->phone;
     }
}
```

Now our method looks like below:

```php
    protected static function extractPhone(object $webhookData): ?string 
    {
        if($webhookData->phone){
            return $webhookData->phone;
        }

        $lookupProperties = ['customer', 'shipping_address', 'billing_address'];

        foreach ($lookupProperties as $lookupProperty){
            if(property_exists($lookupProperty, $webhookData) && $webhookData->{$lookupProperty}->phone){
                return $webhookData->{$lookupProperty}->phone;
            }
        }

        return null;
    }
```

Less lines of code and we have the ability to just add new property in `$lookupProperties` if third party data changes in future.