teleren/devto huggingface dataset:
How To Stop Automatic Updates On Ubuntu Or Debian
Tags: linux, ubuntu
Published: 2020-01-22 13:55:27

[Ubuntu]([https://ubuntu.com/](https://ubuntu.com/)) installs some updates automatically, and so does [Debian]([https://www.debian.org/](https://www.debian.org/)) 9+ with GNOME. This is due to unattended-upgrades being installed and enabled by default.


When enabled, unattended upgrades automatically downloads and installs some important updates, and that's ok in many cases except:

- if you need to quickly shut down or reboot the system

- when you need to install some package ASAP and you notice you can't, because an upgrade is in process


What's more, I've noticed on multiple systems that this can cause quite frequent errors like: "Could not get lock /var/lib/dpkg/lock - open (11 Resource temporarily unavailable)", which are not easy to fix, especially for new users (by the way, see [Linux Uprising Blog](https://www.linuxuprising.com/2018/07/how-to-fix-could-not-get-lock.html) for a how-to on recovering from such dpkg lock errors). Sometimes this error never goes away without user intervention (probably because some upgrade failed) which is quite bad since because of this error you're not able to install or upgrade packages until you fix it.


For this reason, I personally prefer to disable unattended upgrades, and just perform the upgrades myself when time permits it. **To stop automatic updates on Ubuntu or Debian, you have two options:**

1) **Reconfigure unattended-upgrades to stop installing updates automatically**

![disable unattended upgrades on Ubuntu](https://thepracticaldev.s3.amazonaws.com/i/v3wmodvzjr05boaz4kav.png)

Use this command:

        sudo dpkg-reconfigure unattended-upgrades

This will ask you if you want to automatically download and install stable updates or not. Choose No and you're done, Debian / Ubuntu should stop installing automatic updates.

2) **Remove the unattended-upgrades package**

You also have the option of removing the unattended-upgrades package. This will stop future automatic upgrades, but do note that unattended-upgrades may be pulled in as a dependency (e.g. if it's a "recommended" dependency for some other package - Ubuntu installs these [automatically](https://askubuntu.com/questions/179060/how-to-not-install-recommended-and-suggested-packages)) in the future. So while this will stop automatic upgrades, it may come back in the future.

If you want to go this route, remove unattended-upgrades using:

        sudo apt remove unattended-upgrades
react native 
Published: 2020-01-22 14:12:40


** BUILD FAILED **


The following build commands failed:
        CompileC /Users/ahmednawasrah/Desktop/Khareta_RN_AWS-master\ 2/ios/build/Khareta/Build/Intermediates.noindex/Khareta.build/Debug-iphonesimulator/Khareta.build/Objects-normal/x86_64/AppDelegate.o /Users/ahmednawasrah/Desktop/Khareta_RN_AWS-master\ 2/ios/Khareta/AppDelegate.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)




whyyyyyyyy
Welcome Thread - v57
Tags: welcome
Published: 2020-01-22 19:24:30

---
title: Welcome Thread - v57
published: true
description: Welcome to DEV! A thread of hellos and intros.
tags: welcome
---

![welcome nanny](https://media.giphy.com/media/l46Cpz0A0dB1jMxG0/giphy.gif)

### Welcome to DEV!

1. Leave a comment below to introduce yourself! You can talk about what brought you here, what you're learning, or just a fun fact about yourself.

2. Reply to someone's comment, either with a question or just a hello. 👋 

**Great to have you in the community!**
MySQL Schema Change Without Downtime
Tags: mysql, database
Published: 2020-01-22 20:12:53

When altering large MySQL tables (> 200MB) it can block reads or writes for a long time. In this post, I'll explain how to alter a large table without any downtime.

First, let's look at how MySQL does an `ALTER TABLE`:
1. Lock the table
2. Make a copy of the table
3. Modify the copy (the "new table")
4. Copy all the rows into the new table
5. Swap the old and new tables
6. Unlock the table

How can we avoid the blocking (steps 1 & 6)? Here are some options:
* Do it at 2am on Sunday morning
  * Problem: Not fun for developers, lowers developer productivity.
* Do a planned failover (aka. "rolling schema upgrade")
  * Start with slaves and, once the schema change is applied to the slave, promote one of the slaves to the new master, demote the old master to a slave and execute the schema change on it.
  * Problem: Can break replication for some schema changes, requires high availability infrastructure.
* Make MySQL use row versioning
  * Tell MySQL this table has a new version of the schema. Then, you can still read from old row versions but when writing a new row, it writes in the new row format.
  * Problem: MySQL still doesn't support row versioning.
* Handle the `ALTER` process yourself
  * Manually perform the same steps the server takes (without locking).
  * Problems: discussed below

The last option is my preferred so I'll go ahead and explain that. You perform the `ALTER` steps manually, with the following changes:

1. ~~Lock the table~~
2. Make a copy of the table
3. Modify the copy (the "new table")
4. Copy all the rows into the new table
   1. Add triggers to keep track of changes
5. Swap the old and new tables
6. ~~Unlock the table~~

As we're not locking the table, your application can continue to read/write to the original table. It will take some time to copy rows to the new table, so we add triggers to the old table that update or insert corresponding rows in the new table.

Some notes on the above process:
* Remember to make backups before trying this
* Do multiple, smaller chunks of `INSERT..SELECT` when copying data to the new table
  * Helps to avoid deadlocks
  * Try make the chunks small enough so each one takes about 0.5s
  * Start at the low-end of the primary key
* The triggers should only copy columns that are common between the 2 tables.
* To swap the old and new tables, we can atomically rename the old table to something else and the new table to the old table.
  * Don't forget to alter the foreign keys to point to the new table

Problems with above process:
* It's a lot slower than just letting MySQL handle the `ALTER`
* The table you're altering can't have triggers already defined

I hope this post has helped if you find yourself altering some large tables. If you have any questions or corrections, you can message me [@mikeseym](https://twitter.com/mikeseym) on twitter.
Starting C# Backend using Razor pages
Tags: dotnetcore, csharp, razor
Published: 2020-01-22 20:25:53

---
title: Starting C# Backend using Razor pages
published: true
description: An option for creating backends is to use C# ASP.NET Core, this article shows how to get started
tags: dotnetcore, Csharp, razor
---
I am creating a backend for my SPA using C#, ASP.NET Core and using the dotnet CLI to generate the project as follows:
```
dotnet new webapp -o MyPortal
```
Doing this will create a new project with the following structure:
![Project structure in Visual Studio Code](https://thepracticaldev.s3.amazonaws.com/i/fb4huazbuiwyspqo5fyf.png)

And then running `dotnet run` will run a website on your local PC that can be accessed at `https://localhost:5001`.

![View of new site](https://thepracticaldev.s3.amazonaws.com/i/liris0f75ap5r1m7wy3l.png)
💡 How to dynamically create and access properties on JavaScript objects
Tags: javascript, beginners, webdev, tutorial
Published: 2020-01-22 22:15:42

Today we'll learn how to **dynamically create and access properties** on JS objects.

There are two ways to set and access properties on objects: 
* the do notation
* the bracket notation

Let's see these in action:

```js
// create an empty object
const pastry = {}

// set a name property on the object using the dot notation
pastry.name = "waffle"

// set a deliciousness property on the object using the bracket notation
pastry["deliciousness"] = 11

// you can also use both notations to access properties again
console.log(pastry.deliciousness) // 11
console.log(pastry["name"]) // waffle
```

But how would we dynamically set and read these properties? Let's say we would have the name of the property in a variable? 

An example could be a `get` or a `set` method in which you can pass an object and a property. The `set` would of course also take a value.

Let's see these functions:

```js
function get(obj, prop) {
  // return prop on obj
}

function set(obj, prop, value) {
  // set value for prop on obj
}

// create an empty object
const pastry = {};

// use set
set(pastry, "name", "waffle")

// use get
console.log(get(pastry, "name")
```

So how would it work? We can use the bracket notation to dynamically set and get properties. 

```js
function get(obj, prop) {
  // return prop on obj
  return obj[prop]
}

function set(obj, prop, value) {
  // set value for prop on obj
  obj[prop] = value
}

// create an empty object
const pastry = {};

// use set
set(pastry, "name", "waffle")

// use get
console.log(get(pastry, "name")) // waffle
```

---

Want to get better at Web Development?
[🚀🚀🚀subscribe to the Tutorial Tuesday ✉️newsletter](https://codesnacks.net/subscribe/)
Laravel model factories with relation sharing foreign keys
Tags: laravel, testing
Published: 2020-01-23 01:19:39

Larevel users lets say you have three models User, Store and Product, and both Store and Product have a user_id foreign key to the users table, your Product factory may look like this:

```php
<?php
//ProductFactory.php

/** @var \Illuminate\Database\Eloquent\Factory $factory */

use App\Product;
use Faker\Generator as Faker;

$factory->define(Product::class, function (Faker $faker) {
    return [
        'name' => $faker->productName,
        'description' => $faker->text(),
        'price' => $faker->randomNumber(4),
        'sku' => $faker->uuid,
        'user_id' => function() {
            return factory(\App\User::class)->create()->id;
        },
        'store_id' => function() {
            return factory(\App\Store::class)->create()->id;
        }
    ];
});

```

And your StoreFactory like this:

```php
<?php
//StoreFactory.php

/** @var \Illuminate\Database\Eloquent\Factory $factory */

use App\Store;
use Faker\Generator as Faker;

$factory->define(Store::class, function (Faker $faker) {
    return [
        'name' => $faker->city,
        'location' => 'SRID=4326;POINT(-74.069891 4.605246)',
        'address' => $faker->address,
        'user_id' => function(){
            return create(\App\User::class)->id;
        },
        'code' => 'S' . $faker->randomNumber(5)
    ];
});

```

The problem is that then when generating products, the store they belong to doesn't belongs to the same user, and that makes no sense, these three models are just an example the same logic is valid for your specific database model, the solution is to access  the current instance generated fields in the callback of the foreign key is:

```php
<?php

/** @var \Illuminate\Database\Eloquent\Factory $factory */

use App\Product;
use Faker\Generator as Faker;

$factory->define(Product::class, function (Faker $faker) {
    return [
        'name' => $faker->productName,
        'description' => $faker->text(),
        'price' => $faker->randomNumber(4),
        'sku' => $faker->uuid,
        'user_id' => function() {
            return create(\App\User::class)->id;
        },
        'store_id' => function(array $product) {
            return factory(\App\Store::class)->create(['user_id' => $product['user_id']])->id;
        }
    ];
});

```

The callback argument `array $product` has the current instance fields, this way you can pass the dynamic generated User to the "sibling" Store model.

Hope it is useful!.
Watch: JavaScript apps going Inter-Planetary
Tags: javascript, distributedweb, ipfs
Published: 2020-01-23 01:41:06

Last December, I gave a talk at Node+JS Interactive in Montreal, with the title **_JavaScript apps going Inter-Planetary_**.

I was very excited to have the opportunity to speak for the first time at a large tech event, and I got to explain and demo something I'm very passionate about: building static web apps for the Distributed Web, and making them "production ready".

After briefly explaining **what is the Inter-Planetary File System** (IPFS) and how to interact with it, I showed how to **run a static JavaScript app** ([JAMstack](https://withblue.ink/2019/11/16/your-next-app-may-not-have-a-backend.html)) deployed through IPFS.

To make that app accessible to anyone in an easy manner, I then introduced using public **IPFS gateways** with Cloudflare, and **simpler URLs** thanks to the IPNS, or Inter-Planetary Name Service.

Lastly, I demoed how you can enable a full DevOps pipeline with **Continuous Integration and Continuous Delivery**, to automatically publish apps on the IPFS network.

📺 The full talk has been recorded and is now on YouTube:

{% youtube OY-YnkVHJcc %}

🖥 You can also find all the [slides in PDF here](https://static.sched.com/hosted_files/njsi2019/0f/JavaScript%20Apps%20Going%20Inter-Planetary.pdf).

🧑‍💻 The code used for the demo, as well as all the instructions to replicate it yourself, are published on GitHub at **[ItalyPaleAle/calendar-next-demo](https://github.com/ItalyPaleAle/calendar-next-demo)**.

📖 Lastly, if you're interested in reading more, check out my other articles about IPFS:

- [Distributed Web: host your website with IPFS clusters, Cloudflare, and DevOps](https://withblue.ink/2018/11/14/distributed-web-host-your-website-with-ipfs-clusters-cloudflare-and-devops.html)
- [Hugo and IPFS: how this blog works (and scales to serve 5,000% spikes instantly!)](https://withblue.ink/2019/03/20/hugo-and-ipfs-how-this-blog-works-and-scales.html)

Hope you enjoy the content, and let me know if you have any feedback!
Grover's Algorithm for NISQ Machines
Published: 2020-01-23 06:30:03

https://youtu.be/L8hws23LZrk

Grover's algorithm for NISQ machines (Part 1 / Sub-oracle)

Update: Watch the series grow here: https://www.youtube.com/playlist?list=PLsedzcQz4wyWYTgeTsR_JjJ_UMYyaEKKT

Original paper: https://arxiv.org/abs/2001.06575
Subdivided Phase Oracle for NISQ Search Algorithms
Takahiko Satoh, Yasuhiro Ohkura, Rodney Van Meter
Video Snippets: [2 => Test Processes] 🎥
Tags: testing, codenewbie, todayilearned
Published: 2020-01-23 10:01:30

Fundamental test process activities include planning and control, analysis and design, implementation and execution, evaluating exit criteria and reporting, and test closure activities. 


📝 <bold>Test Planning</bold>

Test planning is the first activity in the test process. The test plan is a key document, providing a record of the test planning process. 

📝 <bold>Test Control</bold>

Test control is performed throughout the project. This process involves the tracking of testing activities and comparisons with the plan. 

📝 <bold>Test Analysis and Design</bold>

Test analysis and design activities include the design and prioritization of high-level test cases, identification of test data and software needed for test case execution, and creation of traceability document between test basis and test cases to determine test coverage. These activities help to set up a test environment. 

📝 <bold>Implementation and Execution</bold>


Test implementation activities should start before test execution. Test implementation activities help to finalize, implement and prioritize test cases, create test suits from test cases and write automated test scripts if needed. 

Test execution activities include comparison of actual results with expected results, recording the outcomes of test execution, and re-testing as well as regression testing. 


📝 <bold>Evaluating Exit Criteria and Reporting</bold>

In evaluating exit criteria and reporting, information on test execution may be compared with test plan, assessments of criteria may be made, and a test summary report prepared. The exit criteria determine if a test can be considered as completed. 

📝 <bold>Test Closure Activities</bold>

Test closure activities involve the closure of defect reports, finalization and archiving of testware, and handover of testware to the maintenance organization. 

<kbd>Source: <a href="https://www.youtube.com/watch?v=UWqhewGlHVs"> Smart Software Testing</a></kbd>
love coding, not the language...
Tags: coding
Published: 2020-02-07 20:57:47

So before you get me wrong let me just say, while you are working with language obviously love the language to learn it but when you are done learning and there is nothing more to learn or you have potential to learn something new, do it! don’t hesitate to learn something even if it’s not useful at that moment.

I started my career in Perl about 14 years ago in 2016. I was very new to any kind of programming and I was fascinated by the coding. I learned Perl, Shell Scripting & Linux on the job and then read the books. There is a concept of reference in Perl which I only understood after reading book but I was using it for well over 3 months.

The only problem with Perl was when I picked up it was already on a decline as a new version (Perl 6) was in making for almost 8 years then and others were moving to new languages. But I loved the language so much that I just kept on using it and refusing to learn new languages, oh, I wish what if I had picked Python back in 2008? What's done is done now.

I worked on Perl till 2011 almost the first 5 years of my career till I saw that there are no jobs in the market for Perl and it forced me to learn something new, it was C#. I love this language but I never got a chance to do a deep dive into the language as it was only specific to Windows (i did use it on Linux using Mono project - which is officially supported now). I decided I will not make the same mistake of loving a programming language and pick something which is interesting and that where Python came. I picked it because it was in demand back then and I was desperately looking for a job. Luckily after 6 months of self-study, I found 1 in 2013. I am still with Python which evolving and getting more popular day by day but I am still keeping an eye on new stuff to learn.

In 13+ years, I learned that as a developer don’t stick to one language try to pick something new and keep yourself relevant.

Keep learning, keep exploring!
Postgresql com Backup Incremental — parte 4— Restore da base de dados
Tags: postgres, backup, database
Published: 2020-01-23 12:15:42

Para esta etapa, devemos ter o Postgresql instalado na máquina onde o restore será feito.

Devemos copiar o arquivo **base.tar.gz** criado a partir do comando pg_basebackup no servidor principal e os arquivos incrementais que estão sendo salvos na pasta **/var/lib/postgresql/pg_log_archive**.

O aconselhável é sempre fazer a transferência destes arquivos para outro lugar, se ocorrer um problema físico na máquina principal, não será possível acessar estes arquivos e o backup não terá utilidade. Podemos utilizar scp, rsync, ou qualquer outro programa para a transferência.

Devemos parar o serviço do Postgresql da máquina onde será feito o restore.

```bash
/etc/init.d/postgresql stop
```

Dentro da pasta **/var/lib/pgsql** temos a pasta **data**, esta pasta é onde encontramos os dados referentes ao Postgresql, como vamos fazer o restore do banco de outra máquina, devemos renomear a pasta data para tmp (ou qualquer outro nome)

```bash
mv /var/lib/pgsql/data /var/lib/pgsql/tmp
```

Agora vamos descompactar o arquivo de backup feito no servidor principal. Se as versões do Linux forem as mesmas, a pasta será criada diretamente dentro de /var/lib/pgsql, se atentar onde a pasta data será criada.

```bash
tar xvfP /var/lib/pgsql/base.tar.gz
```

Ao listar as pastas, você verá que foi criada novamente a pasta data, onde está é a cópia do servidor principal.

Depois desta etapa devemos remover os logs antigos da pasta pg_xlog do arquivo descompactado, para evitar problemas com dados antigos

```bash
rm -rf /var/lib/pgsql/data/pg_xlog/*.*
```

No servidor master "Principal" temos os logs que ainda não foram salvos no arquivo incremental, estes logs estão dentro da pasta pg_xlog. Se não for possível recuperar estes logs, o restore de dados será feito somente a partir do último arquivo incremental.

Se for possível acessar o servidor principal então devemos copiar os arquivos da pasta pg_xlog, para a pasta pg_xlog do servidor onde será feito o restore.

Agora devemos criar um arquivo chamado recovery.conf dentro da pasta /var/lib/pgsql/data/, neste arquivo colocaremos a linha abaixo:

```bash
restore_command = 'cp /var/lib/pgsql/pg_log_archive/%f %p'
```

Onde o caminho **/var/lib/pgsql/pg_log_archive/** são os logs incrementais que buscamos do servidor principal.

Devemos também dar permissão ao postgres executar o arquivo

```bash
chown postgres.postgres recovery.conf
```

Após estes passos devemos iniciar o Postgresql novamente, para a importação dos logs

```bash
/etc/init.d/postgresql start
```

Com isso a rotina de backup e restore incremental esta concluída.
Mental Health Pixel - Develop confidence
Published: 2020-02-01 13:10:03

I remember the beginning of my career, as a self-taught, I was struggling to feel confident about my skills, I had what the community refers to as «Imposter Syndrome». Here are 4 ways I managed to change my mindset and turn this «Imposter Syndrome» to my advantage:

## 1 - Practice

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

We all have busy lifestyles, but practicing your skills frequently will help you build confidence, schedule some time every day, even a few minutes to practice your skills.

On that note, a lot of folks struggle to find projects or tasks to work on. What I usually do when I don’t have ideas: rebuild a product/app you like yourself, look at your favorite repositories/packages and see if there are issues to tackle or documentation to contribute to. Practice can also be «Offline», go on dev.to to read interesting articles, follow fellow developers, designers, «techies» on Twitter to see what they are up to, or even pick up a book.

## 2 - Mentor others

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

At the beginning of my career, I didn’t think I could help anybody, as I didn’t know enough. Turns out, there are always people behind you on their journey and could use the extra help to make progress. It is also a great way to consolidate your knowledge and realize that you know more than you think.

## 3 - Don’t overthink

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

I am guilty as charged when it comes to overthinking. I spent years in my early career overthinking every solution, every conversation at work, with my friends and family. I was driving me crazy. It’s only a few years back that I made the decision for myself to stop overthinking and assuming things. Assumptions were the real killer for me, I would always try to assume what people think or why people do some things. It wasn’t easy to stop, but telling myself every day that I don’t know and can’t control what other people think, but I know what I think and what I can control, so I should focus on that, helped me tremendously.

## 4 - You are not alone

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

Sometimes, we are so focused on our life that we forget that other people are living too and they most likely struggle with the same things as us. Helping someone with their project/task/learning, telling them they can do it, they got this will not only help them build confidence, but it will also help you.

—


You can also find these pixels on my Instagram: https://instagram.com/valentinprgnd. I will publish Pixels every Monday, Wednesday, and Friday about career development in tech, code, mental health and health for developers. Follow me for more tips @valentinprngd and check out my podcast https://rebased.whatdafox.com.