teleren/devto huggingface dataset:
How to change the home directory of a user account in Linux?
Tags: resource
Published: 2021-08-02 00:00:00

---
  title: How to change the home directory of a user account in Linux?
  published: true
  tags: Resource
  date: Mon Aug 02 2021 05:30:00 GMT+0530 (India Standard Time)
  canonical_url: https://melvingeorge.me/blog/change-home-directory-of-user-account-linux
  cover_image: https://melvingeorge.me/_next/static/images/main-7dd28b17063ee7453fad37b82c3373bb.jpg
  ---
  [Originally posted here!](https://melvingeorge.me/blog/change-home-directory-of-user-account-linux)
  
To change the home directory of a user account, we can use the `usermod` command followed by the `-d` flag (home directory flag), then the path to the new home directory, and then the name of the user in the Linux.

Suppose we have a user or an account called `john` and we would like to change the home directory of the user to the following path: `/newhomedir/john`.

To do that we can use the `usermod` command like this,

```bash
# Change home directory of a user
sudo usermod -d /newhomedir/john john
```

- Sometimes you may need to use the `sudo` command before the `usermod` command to obtain the correct privileges to execute the command.

You can also move the contents of the current home directory of the user to the new home directory by using the `-m` flag (move contents flag). It can be done like this,

```bash
# Change home directory of a user
# Also, move the contents of the current
# home directory to the new directory
sudo usermod -d /newhomedir/john -m john
```

Try executing the above command in this [online terminal](https://copy.sh/v86/?profile=archlinux) to see the result.

### Feel free to share if you found this useful 😃.

---
How often do you manage your team?
Tags: continuousdeployment, cicd
Published: 2021-08-04 12:03:45

---
title: How often do you manage your team?
published: true
date: 2021-08-02 00:00:00 UTC
tags: continuousdeployment,cicd
canonical_url: https://jhall.io/archive/2021/08/02/how-often-do-you-manage-your-team/
---

If you are, or ever have been, in a leadership role, I have a question for you.

**How often do you manage your team?**

**☐ Once per year**
**☐ Once per quarter**
**☐ Once per month**

What a ridiculous question, right?

Any good manager is continuously managing.

Here’s the thing…

Continuous Deployment is Continuous Management. It’s about giving your team the ability to continuously manage your software delivery. If you’re not content managing your team once per quarter, why would you be content managing your software delivery once per quarter?

* * *
_If you enjoyed this message, [subscribe](https://jhall.io/daily) to <u>The Daily Commit</u> to get future messages to your inbox._
Performance comparison of iteration methods over arrays & lists
Tags: dotnet, csharp
Published: 2021-08-01 23:44:12

Hi there, .NET enthusiasts who care about performance!

I wondered whether it's worth writing `for` loops for iterating over random-access collections (arrays, lists) in .NET nowadays or the JIT compiler has got so smart by now that we can just use `foreach` loops in such cases without significant perfomance penalty.

So I did [some measurements](https://gist.github.com/adams85/9ce7322df796fd7bdd8d663812f26065) (by the help of [BenchmarkDotNet](https://github.com/dotnet/BenchmarkDotNet)) and seeing the results, I decided my findings might be worth sharing.

I benchmarked the following 3 types of iteration methods:

1. Plain old `foreach` loop: `foreach (var item in collection) { /*...*/ }`
2. `for` loop with `Length`/`Count` evaluated in stop condition: `for (int i = 0; i < collection.Count; i++) { /*...*/ }`
3. `for` loop with `Length`/`Count` cached in variable: `for (int i = 0, n = collection.Count; i < n; i++) { /*...*/ }`

I run tests for both arrays and lists, for small (10) and bigger (1000) item counts and for platforms .NET 4.8, .NET Core 3.1 and .NET 5.

You can view the results [here](https://htmlpreview.github.io/?https://gist.githubusercontent.com/adams85/9ce7322df796fd7bdd8d663812f26065/raw/05cf839e3992e0a80b3f5f79edc5f6a7832f1f67/results.html).

I drew the following conclusions:

* If you aim for maximum performance, use method 3 (`for` loop with `Length`/`Count` cached in variable). The only exception is direct access to arrays, in which case `foreach` seems a tiny bit faster. Looks like the JIT compiler optimizes the hell out of that.
* Avoid iterating over collections via interfaces if possible. The performance penalty is in the range of 4x-6x! Definitely avoid `foreach` over interfaces because that allocates too (as the enumerator is also obtained through the interface, thus, it gets boxed). In this case, `for`, at least, is still allocation-free.
Destructuring nested object
Tags: javascript, node
Published: 2021-08-01 23:40:41

## Introduction

Sometimes, we might run into situations where we need to get multiple properties from an object. You might have a function that accepts a nested object as a parameter. For example, the express (backend) functions that accept the `request` as the first parameter. We need to access multiple properties from the object to use in the function.

## Example

Here is an example of a nested object.

```js
const obj = {
  data: {
    day: {
      index: 1
    },
    week: {
      index: 1
    }
  }
}
```

If we want to get both the index of day and index of week, we could do something like this

```js
    const weekIndex = obj.data.week.weekIndex;
    const dayIndex = obj.data.day.dayIndex;
```

But with object destructuring, it will be like so

```js
    const {
      data: {
        week: { index: weekIndex },
        day: { index: dayIndex },
      },
    } = obj;
```

Here, we are destructuring the `data` from `obj`, then we are destructuring `week` and `day` from `data`, then destructure each of them to get the `index` and finally assigning each index to the variable we aim to use in the project.


It might be a few extra lines of code than if we access the object trough dot notation as above. However, it is more visual that we can see the structure of the object which makes it easier to read. As well as we avoid repetition.
How to enable a binary message format in your ASP.NET Core Web APIs
Tags: dotnet, csharp
Published: 2021-08-01 23:37:00

As for web APIs, JSON is ubiquitous nowadays but in some circumstances we may want to reduce the network traffic as much as possible. In such cases hardly anything beats a binary message format. So, usually I use [Protobuf](https://en.wikipedia.org/wiki/Protocol_Buffers) (to be more precise, [protobuf-net](https://www.nuget.org/packages/protobuf-net/)) for this purpose as it is a well-established data exchange format with multi-platform support.

To add some binary serialization capability to your web API project, first you'll need an `InputFormatter`/`OutputFormatter` implementation for the chosen format. In my ASP.NET Core template project I have [one for protobuf-net](https://github.com/adams85/aspnetskeleton2/tree/a442d686db209a255e155d5d519476ebc74b511e/src/Api/Infrastructure/Serialization).

After copying this over to your project and doing [a bit of configuration in your `Startup` class](https://github.com/adams85/aspnetskeleton2/blob/a442d686db209a255e155d5d519476ebc74b511e/src/Api/Startup.Mvc.cs#L28), you're good to go: just pass `application/x-protobuf` in the `Content-Type` and `Accept` HTTP headers when you invoke your API and the bits will come and go over the wire in a sexy binary format right away.

One more thing to remember: of course, your models need to be properly [decorated with attributes](https://github.com/protobuf-net/protobuf-net#1-first-decorate-your-classes) (preferably with `DataContract`/`DataMember` attributes to leave the door open for other serialization formatters) to get protobuf-net going. But that's all indeed!
Youtube Courses, Projects To Master Javascript
Tags: javascript, webdev, beginners, codenewbie
Published: 2021-08-01 23:33:45

Hello,
I'm [Aya Bouchiha](https://t.me/AyaBouchiha),
on this beautiful & amazing day,
I'm going to share with you Youtube courses & projects to study and master Javascript.

## Javascript Courses (Youtube)

+ [Javascript Fundamentals](https://www.youtube.com/watch?v=2Ji-clqUYnA)

+ [JavaScript Programming - Full Course (8h)](https://www.youtube.com/watch?v=jS4aFq5-91M)


+ [Javascript Tutorial for Beginners (8h)](https://www.youtube.com/watch?v=Qqx_wzMmFeA)

+ [Javascript course by Dave Gray (8h)](https://www.youtube.com/watch?v=EfAl9bwzVZk)

+ [Learn JavaScript - Full Course for Beginners (3h 30min)](https://www.youtube.com/watch?v=PkZNo7MFNFg)

+ [JavaScript Tutorial for Beginners (1h)](https://www.youtube.com/watch?v=W6NZfCO5SIk)

+ [Javascript course (4h 30min)](https://www.youtube.com/watch?v=t9dEgHpCNJE)


+ [Javascript Full Course for Beginners to Advanced (4h)](https://www.youtube.com/watch?v=dOnAC2Rr-6A)

+ [Javascript Crash Course by Traversy Media (1h 30min)](https://www.youtube.com/watch?v=hdI2bqOjy3c)

+ [Javascript Course by Academind (5h)](https://www.youtube.com/watch?v=2qDywOS7VAc)

+ [Javascript course by Edureka (3h 30min)](https://www.youtube.com/watch?v=o1IaduQICO0)

##  Javascript Projects (Youtube)

+ [Vanilla Js projects (playlist: 53 videos)](https://www.youtube.com/watch?v=hdI2bqOjy3c&list=PLillGF-RfqbbnEGy3ROiLWk7JMCuSyQtX)

+ [Learn Javascript by building 7 games (2h)](https://www.youtube.com/watch?v=lhNdUVh3qCc)

+ [building 10 Javscript projects (10h)](https://www.youtube.com/watch?v=dtKciwk_si4)

+ [building a calculator using Javascript (40min)](https://www.youtube.com/watch?v=j59qQ7YWLxw)

+ [building 15 projects using vanilla Javascript (8h)](https://www.youtube.com/watch?v=3PHXvlpOkf4)

+ [Javascript Projects - Shopping Cart (4h)](https://www.youtube.com/watch?v=90PgFUPIybY)

+ [To do list by dev ed (1h)](https://www.youtube.com/watch?v=Ttf3CEsEwMQ)

+ [Music player (45min)](https://www.youtube.com/watch?v=QTHRWGn_sJw)

+ [Weather App (40min)](https://www.youtube.com/watch?v=wPElVpR1rwA)

+ [Age Calculator (25min)](https://www.youtube.com/watch?v=Mz9COyHPVwA)

+ [Food Recipe (1h)](https://www.youtube.com/watch?v=x8EY0BlhPGk)

+ [Face detection (12min)](https://www.youtube.com/watch?v=CVClHLwv-4I)

+ [Tic Tac Toe by web dev simplified (40 min)](https://www.youtube.com/watch?v=Y-GkMjUZsmM)

+ [Tic tac to game by clever programmer (4h 30min)](https://www.youtube.com/watch?v=VjjZ2MaX0Ts)

+ [Javascript clock (6min)](https://www.youtube.com/watch?v=weZFfrjF-k4)

To Contact Me:

email: developer.aya.b@gmail.com

telegram: [Aya Bouchiha](https://t.me/AyaBouchiha)

Happy codding!
Dev log for Wonder Wanderer 2: Day 1 #LOWREZJAM 😁
Tags: devjournal, javascript, codenewbie, gamedev
Published: 2021-08-01 23:31:29

Today is the first day for me partecipating on #LOWREZJAM, and I will do it with Wonder Wanderer 2.

###Wait, is there a Wonder Wanderer 1?###
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qconwitvvd3ptt3b4ncr.gif)
<figcaption>Yes, it is and it's right there.</figcaption>
After JS1024, I partecipated to LospecJam 1, but that will be another story (waiting for the results to come) and I will do the post-mortem too, but for now I will say as a recap: I made an arcade with a female adventurer called the Wonder Wanderer avoiding frogs into the night and using powers. More time you survive, more points you can get.
##What it will be Wonder Wanderer 2? ###
The MC for this game will be alone, in a gravity-bending dungeon, without her biplane and new powers for a brand new puzzle platformer and collecting something in every level.
###What did I do today?###
I made most bits of the game design and made a little trial
of movements. I need to make my character move like in a Platformer and in a RPG, so I'll just make a trial level and experiment with animations, jumps, hazards and puzzles until I make the game properly.
![Alt Text](https://media.discordapp.net/attachments/870992694372093973/871499633661206609/cubeman_move.gif)
<figcaption> This is Cubeman, a test character for this journey. </figcaption>
So, that's it for today. Tomorrow I think to go more faster.
###Until then, see you tomorrow!###
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o0yhmv4j080hgfgcip64.gif)
In 2021, Yarn vs. NPM Is there a better one?
Tags: discuss, devops, javascript, npm
Published: 2021-08-01 23:00:46

So I know that this is one of those topics that's more about preference in 2021. I want to hear from both sides and see if my assumptions need to be updated. 

Personally I favor Yarn and have done so for about 4 years working mostly on React projects in teams with 3 - 10 developers. Yarn and it's locked files removed issues of dependencies being a different version and sometimes causing weirdness. Similarly the CI versions have seem to create consistent builds. Finally the lock file is stable and only really changes when a package version is updated, while the last time I used npm the lock file updated a lot more often for no reason. 

I would love to hear and have a discussion on the state of NPM and Yarn what the feelings are out there.
What are Views in Database
Tags: views, database
Published: 2021-08-01 22:44:33

Database View is a virtual/logical table that is made up of a SQL query on the physical tables. A simple view itself does not exist physically at all but a query under a name. 

### Reading data from View
When we read data from view, it's basically a query which gets executed under a name

### Updating data from View
#### Insert query
We can insert data into simple views if Primary key and Not null fields are included in the View. If they are not included, constraint error will be thrown

#### Update query
We can update data in simple views

#### Delete query 
We can also delete data in simple View. Behind the scenes, it executes delete query on the physical table

### Types of Views

1. Simple Views
They are made up of single table.

2. Complex Views
They are made up of more than one table.

### Why we use it?
- To simplify complex queries
- To hide the complexity of underlying tables to the end user or external apps
- To enable backward compatibility. If we make changes in the schema, we can provide views to the existing apps so that they won't break.
- To provide extra security layer using read-only views
- To provide computed columns as database should not save computed columns

### What are Materialized Views?
In order to increase performance in reading data, the data is actually stored on disk. The next time user queries the data from the view, the result wouldn't be calculated on the fly from multiple tables but **it's a query on the view**.

It is used when the view is made up of multiple tables using JOIN. As we know that joining multiple table decreases performance.
Day 1: Planning Ahead
Published: 2021-08-01 22:08:15

This is going to be a simple development blog for a game I'm working on.

I'd like to write about the experience but also I don't want to expend a lot of time here and rather be building the real thing.

The game will be some sort of tribute to the original Prince of Persia, for that, I've made an analysis of the game in another blogpost.

The first thing I've built is a prototype. I've used that to learn the basis of Unity and also test the mechanics I plan for the game.
First thing is that I want the game to be fun from the moment it starts. I've slightly based on HERO

I've started with a [GDD](https://en.wikipedia.org/wiki/Game_design_document) with a format extracted from [Level UP!](https://www.goodreads.com/book/show/8449713-level-up). 
I'll make it public eventually though is nothing complicated, if you want to take a look at it, just let me know.

To summarize, Vectoria: Savior,

* Will have 12 levels
* Is expected to be ready in 3 months

The prototype of the game can be found here: https://tehsis.itch.io/vectoria

There are a couple of decisions I have already made for the game and won't talk about them right now. For example, I'll be using Unity for the game. Mostly because of the community I have access to.

So, where to go now? I think I have enough elements to build the real thing. Most of the prototype is just throw away code which helped me to get familiarized with Unity and C#.

The elements I need to build to support the game are:

* Game mechanics:
   * Jetpack
   * Gun
   * Bombs
   * breakable doors
   * Floor on fire
* Level editor

For each item of the game mechanic I have a description on the GDD, the level editor is something I need to put all elements together. I know there're several plugins on Unity for that so I need to evaluate wether to build one or buy one.
I'll evaluate both options... mostly because the nerd in me tells me to build one.
Stop using ugly if's and start using ternary operators in JavaScript
Tags: javascript, tutorial, codenewbie
Published: 2021-08-01 21:57:37

# What is it?
![1.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1627854331947/L_QpdLzAZ.png)

As it's name suggests, is an operator that takes 3 parameters (only one in JavaScript that takes 3), the first one is the condition, the second one is what will be returned or executed if the condition is true, the last one is what will be returned or executed if the condition is false.

This definition is very vague so let's see some examples

# Examples
### Replacing a simple if..else statement
![2.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1627854347955/jUHBbFRsa.png)

This can be replaced for this

![3.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1627854358041/nx-Ozm0WN.png)

### Returning a value
![4.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1627854364367/8kcpnR5v6.png)

![5.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1627854630194/QFOe8GrX-.png)

### Defining a variable
![6.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1627854642956/f9aaPln2e.png)

![7.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1627854649063/i3vmoqlBP.png)

### Concatenating ternary operators

You can concatenate as many as you want, but don't over use it or it will end up being a nice plate of spaghetti code

![8.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1627854691934/0qJ4q5Da4.png)

# When to use it

- **When the code to execute is short**

If the expression is not very simple, then it's not a good idea to use it

- **When there's no more than 1 condition**

As ****I said, you can concatenate as many as you want, but it will end up being hard to read, so keep it with only one condition (sometimes 2 will be ok)

# Exercises

You can make this exercises online here

[https://playcode.io/new/](https://playcode.io/new/)

### Replace this if...else statement


![9.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1627854703787/fOzp12JBR.png)

### Replace this returning statement
![10.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1627854763001/Ma6TZzC90.png)

### Replace this variable definition
![11.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1627854753885/W9hg3aTKL.png)

# Solutions

### Exercise 1
![12.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1627854741866/sj0iBWMrA.png)

### Exercise 2
![13.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1627854722626/nM6m0tTMA.png)

### Exercise 3

![14.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1627854717453/PCNaqM3ce.png)

I hope this was useful to you and consider following me on [Twitter](https://twitter.com/pallascodes), I'll be posting daily JavaScript content there
HTML Links
Tags: html, beginners, css, codenewbie
Published: 2021-08-01 21:52:12

If you want to add a link to another website in your website, or if you want to add an email link on your website then this is the post for you!

Using HTML to create links we need to use the `<a>`element. Add the website link that you want to direct to inside the `<a>link text</a>`. Link text tells them what they are linking to.  You will use href attribute to add the actual link.

For example... 
`<a href="http://www.kohls.com">KOHLS</a>`

KOHLS tells the user where they are being directed to. They can now click any where in the link text to be forwarded to www.kohls.com.

To insert an email link on your website you also use the `<a>`and href. 

For example...
`<a href="mailto:mary@gmail.com">Email Mary</a>`

Happy Coding!!!
Quick Tip - Remove Unused Using References in Visual Studio
Tags: csharp, visualstudio, dotnet
Published: 2021-08-01 21:05:30

When working on a C# project be it Xamarin, ASP.NET Core etc within Visual Studio, developers sometimes forget to clean up `using statements`. Now Visual Studio does a good job of showing you visually unused using statements as follows 

![Screenshot 2021-08-01 150011](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mjptu7dntwgkpscv3le7.png)

When you are working on bigger projects (in my current case, working on a project with 774 files), sometimes as a developer we forget to clean up our using statements as we go through code refactoring. 

Well, thanks to Visual Studio, we can quickly clean up `using statements` in a file in two ways.

First is putting your cursor on one of the grayed out lines and clicking the light bulb, then clicking "Remove Unnecessary Usings". (NOTE: The shortcut key for this is `CTRL-.`) 

![Screenshot 2021-08-01 150730](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r89ovwkjet67twb5tqbd.png)

When the action is executed the references will be cleaned up. But what happens when you have 700+ files? 

Well if you noticed in the dialog, there is a section at the bottom that says 

![Screenshot 2021-08-01 151508](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v0m2hyymam3f75pa5tsn.png)

Here you can see the options are 

1. Document
1. Project
1. Solution

Now it's pretty obvious, what the options are, but in all my years of using Visual Studio, I have not noticed these options and no one wants to go through 700+ files to clean them up! 

This is what the dialog looks like when you click `Solution`

![Screenshot 2021-08-01 164316](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dcoeil4fnhcupij5q1tx.png)

So I don't know if this is a Visual Studio 2019 feature or if it's always been there. But this makes it a little more 'enjoyable' to go in and clean up lines of code that are no longer required in your source code!
using jq to handle az graph output
Published: 2021-08-01 20:47:37

<sub>Photo by <a href="https://unsplash.com/@raphi_rawr">Raphael Renter</a> on <a href="https://unsplash.com/s/photos/transform">Unsplash</a></sub>

I had to improve the az graph query due to a change in tsv format provided by az graph to a csv produced by jq.

**Reminder**:
```bash
IFS_old=$IFS;
IFS=$'\n';
az graph query -q "where type =~ 'Microsoft.Web/sites' and kind=~'$type' | project name, resourceGroup" | jq '.data[] | [.name, .resourceGroup] | @csv' -r | for i in ` awk -F ',' '{print " --name " $1 " --resource-group " $2 }' ` ; do eval "az webapp config appsettings set $i --settings WEBSITE_RUN_FROM_PACKAGE='$PackageLink' " ;done;
IFS=$IFS_old;
```
Useful Links:
- [jq CheatSheet](https://lzone.de/cheat-sheet/jq)
- [jq Manual](https://stedolan.github.io/jq/manual)
- [this link](https://www.starkandwayne.com/blog/bash-for-loop-over-json-array-using-jq/) explains basics on jq and how to loop using jq
- [this link](https://phpfog.com/convert-json-to-csv-with-jq/) describes how to manage output format in CSV

Hope this helps