teleren/devto huggingface dataset:
Using Git the First Time
Tags: github, opensource, git
Published: 2019-11-10 19:59:25

---
title: Using Git the First Time
published: true
description: Continuation of Understanding Git Article
tags: github,openSource,git
---

This is a Continuation of Understanding Git, Github and Contributing to open Source Projects article. [You can read it Here](https://dev.to/danladi123/understanding-git-github-and-contributing-to-open-source-projects-542l)

*Beginning Check List:*

-Create a github account
-Download the gitbash software 
-Configure your gitbash software with your full name and email
-Create a Repository in github online
-Clone the online repository to your PC

##Further Explanation of Checklist:

To get started you need to create a github account by Signing up [here] (https://github.com/join?source=header-home). 

You also need the gitbash software installed on your PC . Download it [here] (https://git-scm.com/downloads). 

*Make sure you install the gitbash software and configure it as well with Your Full name and Email. Using the Commands Below:*

Git config --global user.name "your username here"
Git config --global user.email "Your Email Here"

*Note: the above git commands should be typed in your gitbash software*

Now you need to create an online repository (Folder) from your github account See screenshot below :

<!-- Image for creating repo link below! -->
![Create Repo](https://thepracticaldev.s3.amazonaws.com/i/7rzwo2rbkgwnhqipnyph.PNG)

Then clone a copy of it(The new Repo) offline by copying its link and typing the git code below in your git bash software. See screenshot below:

![Copy repo link](https://thepracticaldev.s3.amazonaws.com/i/x1yaw69jhvsyhylop0p2.PNG)

After Copying the link as shown in the image above, type the command:
git clone *the_link_of_the_repository_here*

*The above commands should be typed in the git bash command line*


After successful clone to your PC. Check your default Github folder and you will see the new repository folder there.

From now onward you can do all your work related to that project in that folder and push it to the online github repository with the help of some git commands.

*Conclusion...*
At this point, i believe creating a repository and cloning it to your pc should be a simple task to do. 

I will continue this article in Part 3 where i will highlight some startup git commands with simple explanation that you can use to achieve a lot of things as far as github and open source contribution is concerned.

If you face any issues or you will like to share your opinion on this article, feel free to post it below in the comments section.

*Have a nice day....*
How to Access Firestore using Ionic
Tags: typescript
Published: 2019-11-10 16:27:09

When I created an app using Firebase and Ionic, I started my authentication
 journey by trying a few different packages: [firebase.js](https://www.npmjs.com/package/firebase), [firebaseui](https://github.com/firebase/firebaseui-web), [angularfire2](https://github.com/angular/angularfire2), [ionic-firebase-authentication](https://github.com/ionicthemes/ionic-firebase-authentication), and [ngx-auth-firebaseui](https://github.com/AnthonyNahas/ngx-auth-firebaseui).

 I found one that worked with Ionic, and used that for a while, only to
 discover when I moved to testing on my mobile device that the auth didn't
 work on the mobile device because it was using an in-app browser, and
 Google had cracked down on using those inside of apps to authenticate.

 I then found the [official Firebase Authentication plugin for Ionic](https://ionicframework.com/docs/native/firebase-authentication/)
 and was pretty excited. After a bit, I realized that although it allows you to sign in, *you can't actually access the Firestore database*.

 If you use another package, like the firebase.js package, to retrieve and
 store data and you've locked down the Firestore database [as you should](https://firebase.google.com/docs/firestore/security/get-started)
 you'll quickly find that as far as the firebase.js package is concerned,
 you aren't actually authenticated.

 I'm not thrilled with my current implementation, but to allow facebook
 logins it looks like this:

```typescript
  async loginWithFacebook() {
    const permissions = ['public_profile', 'email'];
    this.fb.login(permissions)
        .then(response => {
            const accessToken = response.authResponse.accessToken;
            const credential = firebase.auth.FacebookAuthProvider.credential(accessToken);
            firebase.auth().signInAndRetrieveDataWithCredential(credential).then(() => this.allowUserIn());
        });
  }
```

I'm using the [native Facebook Auth package](https://beta.ionicframework.com/docs/native/facebook) to prompt the user for permission to Facebook (this seems to be what can't be done via a browser on Android), and then using firebase.js to take care of the rest.
Laravel Authorization with Gates – Part 1
Tags: laravel, laravel58, laravel6, laravelcodesnippet
Published: 2020-01-02 18:50:06

---
title: Laravel Authorization with Gates – Part 1
published: true
date: 2019-11-10 19:30:39 UTC
tags: Laravel,Laravel 5.8,Laravel 6,Laravel Code Snippet
canonical_url: https://codebriefly.com/laravel-authorization-with-gates-part-1/
---

 ![Laravel Authorization Gates](https://codebriefly.com/wp-content/uploads/2019/11/laravel-authorization-gates.jpg)

In this article, we will discuss the “Laravel Authorization with Gates”. As you know, Laravel provided an Authentication solution that is Out of the box. Laravel provides two simple way to manage the authentications such as Gates and Policies. The basic difference between the gates and the policies, Gates provides a simple closure based approach […]

The post [Laravel Authorization with Gates – Part 1](https://codebriefly.com/laravel-authorization-with-gates-part-1/) appeared first on [Code Briefly](https://codebriefly.com).
Vim: Using math in substitution
Tags: vim, neovim
Published: 2019-11-10 19:01:30

---
title: Vim: Using math in substitution
published: true
description: Intead of using macros to do math in vim let's use something else
tags: vim, neovim
---


# Vim: Calculating age in substitution

Let's say you have:
source: https://sanctum.geek.nz/arabesque/advanced-vim-macros/

```markdown
    Stallman   Richard   GNU    1953  USA
    Wall       Larry     Perl   1954  USA
    Moolenar   Bram      Vim    1961  Netherlands
    Tridgell   Andrew    Samba  1967  Australia
    Matsumoto  Yukihiro  Ruby   1965  Japan
    Ritchie    Dennis    C      1941  USA
    Thompson   Ken       Unix   1943  USA
```

and you want to calculate how old each of these guys above
is right now:

My solution with no macros:

```viml
    :%s,\d\+,\=strftime("%Y")-submatch(0)
```

```markdown
    Stallman   Richard   GNU    66  USA
    Wall       Larry     Perl   65  USA
    Moolenar   Bram      Vim    58  Netherlands
    Tridgell   Andrew    Samba  52  Australia
    Matsumoto  Yukihiro  Ruby   54  Japan
    Ritchie    Dennis    C      78  USA
    Thompson   Ken       Unix   76  USA
```

## Tip 1: Use Regular Expressions to match the numbers
`\d\+` means: find a digit or more. That regex matches exactly our fourth column

## Tip 2: Exchange Delimiter
In my case typing comma is much easier than typing slash, so I have exchanged the substitution delimiter. 

## Tip 3: Not always we need the global substitution
In our case we just need the substitution once, so we omitted the final coma plus 'g'

## Tip 4: Use expression register in substitution
In order to use expression register in substitution just type `\=`


## Tip 5: To get current year 
We are using `strftime("%Y")`

## Tip 6: `Submatch(0)`
It matches the pattern we just referred on the search part of the substitution


For more information use the vim help system:
`:h regex`
`:h \=`
`:h submatch`
`:h strftime`
What is etcd ? Kubernetes bitesize
Tags: kubernetes, beginners, productivity, devops
Published: 2019-11-10 17:55:39


![](https://github.com/etcd-io/etcd/raw/master/logos/etcd-horizontal-color.svg?sanitize=true)

_"[**etcd**](https://github.com/etcd-io/etcd) is a **strongly consistent**, distributed key-value store that provides a reliable way to store data that needs to be accessed by a distributed system or cluster of machines. It gracefully handles leader elections during network partitions and can tolerate machine failure, even in the leader node."_


![](https://kubernetes.io/images/blog/2018-06-05-11-ways-not-to-get-hacked/kubernetes-control-plane.png)
In K8s cluster, etcd is part of the master, it stores all its data – its configuration data, its state, and its metadata. Since K8s is a distributed system, it needs a distributed data store like etcd. etcd lets any of the nodes in the Kubernetes cluster read and write data. 

It gets more complicated than that since in real-world **etcd** is deployed as a cluster of its own. The cluster will contain at least 3 nodes for the sake of good replication, durability and high availability.
The nodes communication are handled by the Raft algorithm, watch animation [here](http://thesecretlivesofdata.com/raft/). 

__ProTip:__ _use at least 5 nodes for production etcd cluster._





### **Security is everyone job !!!**
![](https://media.tenor.com/images/6ade0f049b0459a87d2516826cca19ac/tenor.gif)

**Access to etcd is equivalent to root permission in the cluster.** Due to the sensitivity of the data, it is recommended to grant permission to only those nodes that require access to etcd clusters.
Make sure to set up firewall rules or use security features by etcd.

Plan for:
* Securing communication with certificates
* Limiting access of etcd clusters with authentication



### **Scale**

![](https://media.tenor.com/images/c6769d075cc4fa04ad9eef4ca364e7ac/tenor.gif)
You will probably won't need more than 5 nodes. Scaling etcd increases availability but reduces performance pretty drastic due to it being **strongly consistence**. Don't overdo it.


![](https://github.com/adipola/my-posts/blob/master/pictures/kubernetes_sun_bitesize.gif?raw=true)

**That was "_what is etcd in 2 minutes or less_"**.
 Enjoyed it? check out the [Kubernetes bitesize series](https://dev.to/adipolak/kubernetes-in-bitesize-2blm).
What is the one tip you would give to new bloggers out there?
Tags: discuss, blogging, webdev
Published: 2019-11-10 17:50:12

---
title: What is the one tip you would give to new bloggers out there?
published: true
description: Imagine you had to start your blog over again. What things have you learned in your path so far that you think would make the biggest difference this time around?
tags: discuss,blogging,web development
cover-image: https://cdn.pixabay.com/photo/2019/11/03/16/50/water-4599103_960_720.jpg
---

I've been blogging for about a year now, and feel like I've learned a lot of things in this time, even though I'm nowhere near as experienced as those big-time guys I see on social networks.

The few things I'd say to a newcomer are:

- Make a plan and stick to it: posting consistently over a long period of time is better than making bursts of content every once in a while (I wish I had the discipline to follow this advice, it really pays off).

- Focus on promoting your content almost as much as you focus on writing it. At least if you really care about it reaching a big audience.

- Don't spend too much time focusing on improving your site speed. As developers, I think we have a tendency to want to optimize every last inch of website performance. I know I do. And I've spent countless hours, enough to write like five good quality articles, just optimizing those last points in Google PageSpeed, or those few points in GTMetrix. My advice? Get a few plugins to do the job for you, get to like 90 or 95 pagespeed and then just focus on content. 
I wish I'd known that from the start.

By the way, if you're using WordPress, the PageSpeed Ninja plugin was a gamechanger for me. It's a lot better than Autoptimize, which is what Google suggested to me most of the time.

So what about you? Bloggers of the tech world, lords of the web, which pearls of wisdom do you think every other blogger should receive?
The Journey Begins
Tags: books, beginners, github, opensource
Published: 2019-11-10 16:57:30

*"A long time a ago in a Galaxy far away begun a Journey to create a group of Coding Jedi with extra ordinary skills and regain the Balance in the Force."*

But to become a Jedi we need a Jedi master like Master Yoda :pray::pray:, who will teach us the secret lessons of code and life, but unfortunately all masters are gone a long ago :pensive: leaving behind their knowledge in the form of books :books:, so that the people like you and me :two_men_holding_hands: can find those books and follow the journey to become a Coding Jedi.

![](https://bayart.org/wp-content/uploads/2017/11/star-wars-wisdom-quotes.jpg?ezimgfmt=ng:webp/ngcb1)

So, the plan is to read at least three books of different categories every month.
The list of categories and books is on github here,

####https://github.com/sksaifuddin/jedi-journey

We will not only read about the coding books but also the books which teaches us philosophy, meaning of life and wisdom, so that we truly become **The Jedi**.

I will also try to write Important takes from the books in the form of summary, so the folks who doesn't time can also make use of our journey. 

I will be doing the research on good books and add them in list, you all can also suggest and contribute the list of books and summary.

Follow along and remember,

> *Do or Do Not, There is No Try.* – Master Yoda

##:collision: MAY THE FORCE BE WITH YOU :collision:
Hugo - How to Filter Posts With a Tag
Tags: go
Published: 2019-11-10 16:22:36

While recently working on a website, I wanted to display a subset of my posts based on a particular tag. I hadn't had any prior experience with the go templating engine, so this took me a bit longer to figure out than I'd care to admit, so I thought I'd share it with all of you.

This example applies anytime you want to filter any list of pages with a taxonomy.

```go
    <ul>
      {{ range where .Paginator.Pages ".Params.tags" "intersect" (slice "popular")}}
      <li>
        <span>{{ .Date.Format (.Site.Params.dateFormat | default "January 2, 2006" ) }}</span>
        <a href="{{ .URL }}">{{ .Title }}</a>
      </li>
      {{ end }}
    </ul>
```


The first line is really all that matters. We're `range`-ing over the pages, grabbing the tags from each of those pages and seeing if they intersect with a new slice that only contains `popular`.

 A `contains` operator is what I would expect to use here, but as far as I can tell there isn't one, so you have to use this `intersect` workaround.

I hope that was helpful! If you have any questions please let me know.
Google Cloud Functions and the File System
Tags: go
Published: 2019-11-10 16:20:48

If you want to write a cloud function, and you need to write temporary data to the file system, how do you do it?

Using `/tmp`. Under the hood, it's actually [just storing it in memory](https://cloud.google.com/functions/docs/concepts/exec#file_system) but if you must simulate reading and writing to the file system it'll work.

I was cloning a repo programmatically and parsing JSON files from that repo, so it made sense for my situation.

To write:

``` go
func write() error {
    text := "Hello World"
    filepath := "/tmp/file"
	fmt.Printf("writing file %v\n", filepath)
	b := []byte(text)
	err := ioutil.WriteFile(filepath, b, 0644)
	switch  {
	case err != nil:
		fmt.Printf("error encountered writing file %v, %v\n", filepath, err)
		return err
	default:
		fmt.Printf("file wrote successfully\n")
		return nil
	}
}
```

To read:
```go
func read() (string, error) {
    filepath := "tmp/file"
	fmt.Printf("reading file %v\n", filepath)
	content, err := ioutil.ReadFile(filepath)

	switch {
	case err != nil:
		fmt.Printf("error encountered reading file %v, %v\n", filepath, err)
		return "", err
	default:
		fmt.Printf("file %v read, content: %v\n", filepath, string(content))
		return string(content), nil
	}
}
```

You can find a complete sample [here](https://github.com/ZakMiller/cloudstorage/blob/master/cloudstorage.go).

If you care about preserving the files you're writing, then don't use this solution. Instead, use something [like this](https://cloud.google.com/storage/).
Your preference between Apache and NGINX?
Tags: discuss, server
Published: 2019-11-10 15:59:49

Hello Practical Devs 👋

* What do you like about **Apache** and **NGINX**? 
* What are their strongness and weakness?


[![Photo by Taylor Vick on Unsplash](https://thepracticaldev.s3.amazonaws.com/i/3picbezdcvoeaenl0wdd.png)](https://unsplash.com/photos/M5tzZtFCOfs)
Union Types 2.0 has been accepted for PHP 8.0
Published: 2019-11-10 15:55:14

Recently Union Types version 2.0 was [accepted](https://wiki.php.net/rfc/union_types_v2) for PHP 8.0. It will be a cool feature for the next version of PHP. In this post, I'll be discussing the good and the bad of it.

# Introduction to Type Declarations

In PHP, [type declaration](https://dev.to/robdwaller/how-php-type-declarations-actually-work-1mm5) has two usages.

```php
// in functions (argument and return types)
function hello(string $text) : string {
	return $text;
}
```

This code says the $text argument should receive a string (`string $text`) and the function should return a string (`: string`). This is what we occasionally deal with. Additionally, type declaration for class properties will be available from PHP 7.4.

Currently [supported types](https://tutorials.supunkavinda.blog/php/functions#argument-type-declaration) are: array, callable, int, float, bool, and string.

Type declaration is there for two main purposes.

1. Low-level data / Code integrity: it is more difficult to misuse methods and type checking is reduced.
2. Code readability: it is clearer what a method accepts and what it will return.


# Union Types


*Union Types* suggests type declaration to have multiple types combined with "OR". For example, one type hint can be _string or int_ 

In the current version of PHP, there are two supported union types.

1. *Type or null*  - Use `?` before the type.
```php
function foo(?int $x) {
	// ...
}
```

2. *array or Traversable* - Use `iterable`.
```php 
function loop(iterable $arr) {
 	// ...
}
``` 

Except for these two types, arbitrary union types are not yet supported. If needed, we have to use laggy PHPDoc annotations as following.

```php
/**
* @param int|float $number
*/
function processScore($score) {
	return floor($score / 2);
}
```

# Union Types 2.0

* Union Types 2.0 suggests using arbitary union types. 
* The syntax format is as simple as `type1|type2|...`. 
* These can be used in all above mentioned places of type declarations.

The above code can be written as follows.

```php
function processScore(int|float $score) {
    return floor($score / 2);
}
```

# The Good

* PHPDoc can be ditched (Unless you use `@throws RandomException`)
* Type declarations are more readable.
* New proposal supports the psuedo-type `false`. This is extremely useful for functions that returns false on a failure. (`$mysqli -> prepare()`)


Let's discuss your thoughts!
Changing Primary Language/Stack Experiences
Tags: discuss, watercooler, career
Published: 2019-11-10 15:48:19

I've been a Java/Spring Boot developer for the majority of my professional career and I'm working to broaden my skill-set beyond that so I've been learning JS and web development in my spare time. 

The web development ecosystem seems large to say the least, and I feel like it's a tough move out of the back-end space given the problem sets and things to learn. 

What's been the dev communities experiences changing primary language/tech stack, has it been easy for you to switch it up?
Anyone using ASP.NET Core 3.x on a Linux shared web host?
Tags: discuss, hosting
Published: 2019-11-10 14:49:54

---
title: Anyone using ASP.NET Core 3.x on a Linux shared web host?
published: true
description: 
tags: #discuss #hosting
---

First post and unfortunately it's not some sharing of knowledge, but rather some desperate questions. Not sure I got the syntax for tags right.

Long story short, my web host has apparently been hit by ransomware and I'm looking at alternatives.

My web site is currently PHP and MySQL, but I'm rewriting it using ASP.NET Core and - so far - a SQL Server back end. That host was able to provide these features without breaking the bank(...)

I've been looking at other ASP.NET Windows hosts and the features are either lacking, outdated, or out of my price range. So, I'm beginning to wonder if I could deploy my ASP.NET Core web site (if I ever get around to finishing it) to a Linux shared host (there's talk of nginx in the Microsoft documentation) and possibly targeting MySQL instead of SQL Server.

So... questions:

1) Has anyone here had any experience with deploying an ASP.NET Core site to a Linux shared host?

2) Any experience with EF Core 3.0 and MySQL? I'm not married to SQL Server, it's just usually easier to use with .NET.

Bonus question (3) Any hosting recommendations?

This was supposed to be a relaxing weekend where I'd be experimenting with Vue.js...
What should I write blog posts about?
Tags: discuss, blogs, helpwanted
Published: 2019-11-10 15:15:14

---
title: What should I write blog posts about?
published: true
description: Nhost, BaaS. What would help you get started?
tags: discussion, blogs, help-wanted
---

I've been given a writer account for the blogging platform of the startup [Nhost](https://nhost.io).

Nhost is a hosted, GraphQL-based, Hasura-backed altermative to databases-as-a-service, like Google Firebase. 

It's really new, and really awesome, and I think it would be cool to make some examples demonstrating what you can do with it, but I need project ideas!

Everything seems to have a 'todo app' example, but that doesn't always help people in the real world.

**What are some simple projects I could make that would be useful to you, if you were going to get started with Nhost?**