teleren/devto huggingface dataset:
How to install virtualenv on Ubuntu 18.04
Tags: python, virtualenv, django, dev
Published: 2019-09-11 12:38:37

---
title: How to install virtualenv on Ubuntu 18.04
published: true
tags: python, virtualenv, django, dev
canonical_url: https://tech.serhatteker.com/post/2018-12/virtualenv/
---

We may face issues when our Linux distribution only offers certain versions of Python and its packages, when we actually need newer or older versions. 

We can install new versions of Python on the server, however this will be more complex because we will have some dependency issues when trying to compile everything we need. 

Virtual environments make this very easy to manage and set up, we can have different versions of Python and packages in each environment, and it will be isolated from the main system. 

Installing Virtual Environment on Ubuntu 18.04 -or later from 16.04, is fairly easy task and it shouldn’t take more then 10 minutes to finish.



##  install pip

install pip3 if you don't have already

```sh
$   sudo apt-get install python3-pip
```

##  instal virtualenv

```sh
$   sudo pip3 install virtualenv
```

##  build new virtualenv

```sh
$   cd $YOUR_PROJECT_DIRECTORY
$   virtualenv .venv
```

.venv or any `$NAME` for your virtualenv

## to activate your virtualev

```sh
$   source .venv/bin/activate
```

and you see your `.venv` activated

```
(.venv) ~/project$
```

## to deactivate your virtualev

```
$   deactivate
```

## install new packages
After activating your virtualenv 

```sh
$  pip install <some-package>
```



### P.S:

You can also use `Python2.7` interpreter for your `virtualenv` but I would not recommend that since Python 2.7 **will not be maintained after January 1, 2020**. But if you like to:

```sh
$   virtualenv -p /usr/bin/python2.7 .venv
```
A month of Flutter: FABulous authentication
Tags: flutter, tutorial, authentication
Published: 2018-12-15 22:52:06

_Originally published on [bendyworks.com](https://bendyworks.com/blog/a-month-of-flutter-fabulous-authentication)._

Wouldn't it be FABulous if users could sign in to the app? I agree. I'm planning on using [Firebase Authentication](https://firebase.google.com/docs/auth/) via the [`firebase_auth` package](https://pub.dartlang.org/packages/firebase_auth) but today is all about that [FAB](https://docs.flutter.io/flutter/material/FloatingActionButton-class.html).

This implementation is pretty simple. I'm going to create a new `StatelessWidget` that uses an [extended](https://docs.flutter.io/flutter/material/FloatingActionButton/FloatingActionButton.extended.html) FAB with a [G logo](https://developers.google.com/identity/branding-guidelines) and text. `onPressed` will kick off the authentication flow in the future, but for now it just prints that the FAB was tapped.

~~~dart
class SignInFab extends StatelessWidget {
  const SignInFab();
   @override
  Widget build(BuildContext context) {
    return FloatingActionButton.extended(
      onPressed: () => print('Tapped on sign in'),
      icon: Image.asset('assets/google_g_logo.png', height: 24.0),
      label: const Text('Sign in with Google'),
    );
  }
}
~~~

The tests for `SignInFab` simply check that the expected elements are still there.

In addition to adding [`floatingActionButton`](https://docs.flutter.io/flutter/material/Scaffold/floatingActionButton.html) to the `Scaffold` in `_MyHomePageState`, I'm also adding [`accentColor`](https://docs.flutter.io/flutter/material/ThemeData/accentColor.html) to the theme. The `accentColor` is usually complementary to the `primaryColor` but I want them both to be white for now. `accentColor` will be used as the default background of FABs.

~~~dart
ThemeData(
  brightness: Brightness.light,
  primaryColor: Colors.white,
  accentColor: Colors.white,
)
~~~

And there it is, a nice Sign in with Google extended FAB.

![Screenshot of page with sign in with Google button](https://thepracticaldev.s3.amazonaws.com/i/rmbo44lq68gv414rvp75.png)

## Code changes

- [#40 Add Sign in with Google FAB](https://github.com/abraham/birb/pull/40)
Six Reasons You Should Be Using Gem markdown_helper
Tags: markdown, ruby, github, documentation
Published: 2018-12-15 22:18:39

---
title: Six Reasons You Should Be Using Gem markdown_helper
published: true
description: 
tags: #markdown #ruby #github #documentation
---
[Transparency:  I build this stuff.]

With gem [markdown_helper](https://rubygems.org/gems/markdown_helper), you can:

- Use [file inclusion](https://github.com/BurdetteLamar/markdown_helper/blob/page_nav/markdown/use_cases/include_files/reuse_text/use_case.md#reuse-text) to keep your documentation DRY (Don't Repeat Yourself).

- [Include dynamically generated text](https://github.com/BurdetteLamar/markdown_helper/blob/page_nav/markdown/use_cases/include_files/include_generated_text/use_case.md#include-generated-text).  In particular, you can keep your examples "green" by continuously re-running and re-including them.

- [Nest file inclusions](https://github.com/BurdetteLamar/markdown_helper/blob/page_nav/markdown/use_cases/include_files/nest_inclusions/use_case.md#nest-inclusions).

- Include text as:

  * [Markdown](https://github.com/BurdetteLamar/markdown_helper/blob/page_nav/markdown/use_cases/include_files/include_markdown/use_case.md#include-markdown).
  * [Code block](https://github.com/BurdetteLamar/markdown_helper/blob/page_nav/markdown/use_cases/include_files/include_code_block/use_case.md#include-code-block).
  * [Highlighted code block](https://github.com/BurdetteLamar/markdown_helper/blob/page_nav/markdown/use_cases/include_files/include_highlighted_code/use_case.md#include-highlighted-code).
  * [Pre-formatted text](https://github.com/BurdetteLamar/markdown_helper/blob/page_nav/markdown/use_cases/include_files/include_text_as_pre/use_case.md#include-text-as-pre).
  * [Markdown comment](https://github.com/BurdetteLamar/markdown_helper/blob/page_nav/markdown/use_cases/include_files/include_text_as_comment/use_case.md#include-text-as-comment).

- Include an automatically-generated [page TOC](https://github.com/BurdetteLamar/markdown_helper/blob/page_nav/markdown/use_cases/include_files/include_page_toc/use_case.md#include-page-toc) (table of contents).

- Use either interface:

  * [CLI](https://github.com/BurdetteLamar/markdown_helper#cli) (no Ruby coding needed).
  * [API](https://github.com/BurdetteLamar/markdown_helper#api) in your Ruby code.
OOP is great! And here is why!
Tags: oop, programming, coding, discuss
Published: 2018-12-15 21:49:07

---
title: OOP is great! And here is why!
published: true
description: 
tags: #oop #programming #coding #discuss
---

My first impression of OOP, many years ago, coming from C programming: Cool, let's put everything into a class and declare some attributes. These are like global variables but without the bad smell. No more need to pass too many arguments around.

It took me a few years to find out that this is not the real benefit of OOP.

Unfortunately, when looking at OOP code today, many developers still seem to adhere to this mindset.

Unfortunately this is how OOP is still being taught at schools.
Getter naming conventions
Tags: discuss, java
Published: 2018-12-15 20:51:53

In Java and similar languages that don't have a built-in property concept, it is common to make fields private and accessible to the object's outside only through getter methods.
The Java Beans naming convention suggests to use the name `getX()` for the getter method of a field `x` (most of the time) , like so:


``` java
public class User{
	private Name name;
	
	public Name getName(){
		return name;
	}
	...
}
``` 
I didn't question it when I started programming. Then I heard of several people, like Martin Fowler, who didn't care about that convention. They write `name()` for the example getter instead.

Looks a lot better, so I started adopting it. Then I ran into problems with libraries that expect the Beans convention.
Another benefit of classes adhering to the Beans convention: in an IDE, you can easily find out all the properties of a library's class if you just type in the first three letters: `get`.

So, if you use getter methods, which naming convention do you use?
let, const & Block scoping
Tags: es6, javascript
Published: 2018-12-15 18:03:01

---
title: let, const & Block scoping
published: true
description: 
tags: #es6 #JavaScript
---

<img src="https://thepracticaldev.s3.amazonaws.com/i/y9zb6hktm7ndk6oi920x.png">
<h1>What is block scoping?!</h1>
Quite simply, this means a new scope is created between a pair of `{}`. Unlike the `var keyword`, the variables declared with `let` and `const` can only exist within the innermost block that surrounds them.

In the following example, what do you think will be printed to the console when the code is executed.
```javascript
    let name = 'Runo';
    {
     let name = 'Tega';
    }
   console.log(name)
```
  The value `Runo` is printed to the console because the second variable `name` is not visible outside the block, it simply doesn't exist outside the block.


<h2>let & const: Similarities</h2>

In this section, we'll look at the similarities between the `let` and `const` keywords in different use cases:

###Block Scoping
We know that the `var keyword` is bound to `function scope`, whereas `let` and `const` are
`block scoped` which means that if you have a set of curly braces `{}` you have a `block scope`.

###One declaration per scope
This means that `let` and  `const` can be used to declare a particular variable only once within its scope, lets see an example to level our understanding:

```javascript
    let name = "Runo";
    let name = "Tega";
    console.log(name); //error
``` 
Same goes for `const` 
```javascript
   const name = "Runo";
   const name = "Tega";
   console.log(name); //error
``` 

<strong>Note:</strong> the `var keyword` acts differently, it allows a variable to be declared twice and then it takes the value of the most recent declaration, see the code snippet below:

```javascript
   var name = "Runo";
   var name = "Tega";
   console.log(name) // Tega
``` 
<h2>Let & const: Differences</h2>

In this section we'll look at the differences between `let` and `const` and when to use them.
###Variable initialization
`const` variables <strong>must</strong> be initialized with a value, but  `let` variables don't always require an intialization variable.

```javascript

  const a; //Syntax error

  let a;
```


###Variable reassignment

 `let` variables can be reassigned to another value, whereas `const` variables cannot. See the following:

```javascript
   let name = "Runo";
       name = "Tega";
       console.log(name) // Tega
``` 
 `const` variables <strong>cannot</strong> be reassigned, see below:

```javascript
      const pi = 3.142;
            pi = 3.14; //uncaught typeError 
```

`const` should be used to hold variables whose values remain constant throughout the program. It can be used to create variables that hold references to the DOM. 

#Summary
The `const and let` keywords support block scoping (lexical binding) and the `const` key word is used to declare variables with constant values, whereas the `let` keyword is used to declare variables whose values can change in the course of programming. The `let` keyword is a good replacement for legacy ES5 `var` keyword.
My dev conference project Byteconf is giving away over $2000 in web dev subscriptions, courses and more
Tags: javascript, webdev, react, beginners
Published: 2018-12-15 19:09:57

---
title: My dev conference project Byteconf is giving away over $2000 in web dev subscriptions, courses and more
published: true
description: Our community has grown a TON in the first year of Byteconf, and to celebrate, we've partnered up with a ton of great folks in the frontend web development community to give away all kinds of exciting products and subscriptions to help you jumpstart your web dev career – over $2000 in prizes!
tags: javascript, webdev, react, beginners
---

Hey dev.to, [Kristian](https://twitter.com/signalnerve) from Byteconf here! Over the last eight months, I've been building [Byteconf](https://byteconf.com) - I've posted here before announcing our [free React conference](https://dev.to/signalnerve/a-developer-conference-that-anyone-in-the-world-can-attend-dd3) and [free React Native conference](https://dev.to/signalnerve/check-out-byteconf-react-native---a-free-one-day-react-native-conference-streamed-on-twitch-1nbe).

![A Very Merry Byteconf](https://thepracticaldev.s3.amazonaws.com/i/rj6yhc2qzikfcl4cvg40.png)

# Our community has grown a TON in the first year of Byteconf, and to celebrate, we've partnered up with a ton of great folks in the frontend web development community to give away all kinds of exciting products and subscriptions to help you jumpstart your web dev career – over $2000 in prizes!

**I'm thrilled to be announcing Byteconf's first giveaway: ["A Very Merry Byteconf"](https://byteconf.com/merry).**

We're giving away a ton of incredible stuff, thanks to some of our friends and favorite companies in the web dev community.

- Three **one year subscriptions to [GitHub](https://github.com)** ($250 value)
- Three **one year subscriptions to [Egghead.io](https://egghead.io/)** ($750 value)
- Three copies of Kent C. Dodds' online course **[Testing JavaScript](https://testingjavascript.com/)** ($810 value)
- Three copies of Manning Publication's video course **[React in Motion](https://www.manning.com/livevideo/react-in-motion)** ($180 value)
- Three copies of O'Reilly Media's **[Learning React](http://shop.oreilly.com/product/0636920049579.do)** and **[Learning GraphQL](http://shop.oreilly.com/product/0636920137269.do)** ($135 value)

**Three lucky winners** will get one of each above prize, and a shout out on our social media pages!

The way the giveaway is set up is pretty rad - there's the opportunity to submit up to fourteen entries, so check out all the potential options.

A huge shout out to our friends GitHub, egghead.io, Kent C. Dodds, Manning, and Moon Highway for helping us out with this giveaway! We're super excited to help people get started in web dev in the new year. 

**The deadline for signing up is December 31st, 2018.**

[Don't miss it - join now!](https://byteconf.com/merry)
The var keyword
Tags: javascript, webdev
Published: 2018-12-15 18:04:13

---
title: The var keyword
published: true
description: 
tags: #javascript #webdev
---

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

Before ES6, all variables in JavaScript were declared with the var keyword. This keyword causes our variables to have a function scope.

Lets understand this better with the following code snippet:
 ```javascript
  function SayName(){
   var name = "Tega";
   }

console.log(name)//Undefined
 ```
The console prints out `undefined` because the variable `name` inside the `SayName` function is <strong>not</strong> visible outside the `SayName`function.

The behaviour is quite different in another block that is not a function block. For example, see what happens in an if block.

```javascript
  if(true){
   var name = "Tega";
   }

console.log(name)//Tega
 ```
The console prints `Tega`.

Considering the results from the two examples, it is evident that variables declared with the `var` keyword have a local scope <strong>only</strong> when they are found within a function block.

<strong>It's a bad behaviour</strong>
This is a bad behaviour that has caused a lot of frustration amongst JavaScript programmers. Prior to ES6, JavaScript had function scope, but <em>block scoping</em> is more common in most programming languages. With ES6, `let` and `const` keywords were introduced to allow us to declare variables that are block scoped which is a safe behaviour.


Thank you for reading!
Happy Coding!❤
Default Function Parameters (ES6)
Tags: webdev, es6, javascript
Published: 2018-12-15 18:02:05

---
title: Default Function Parameters (ES6)
published: true
description: 
tags: #webdev #es6 #javascript
---


In the ES5 days, to set default values you might write your code in this manner:


```javascript
function getSum(a, b){
 a = (a !== undefined) ? a:1;
 b = (b !== undefined) ? b:41;
 return a + b;
}
 getSum() //42
 getSum(1,2) //3
```
or

```javascript
function getSum(a, b){
 a = a || 1;
 b = b || 41;
 return a + b;
}
 getSum() //42
 getSum(1,2) //3
```
These are good solutions, but hey it's 2019, Modern JavaScript is here to rescue us from this long walk. Now, you can set default values to the parameters in the function declaration statement itself like so:

```javascript
function getSum(a = 1, b = 41){
 return a + b;
}
 getSum() //42
 getSum(1,2) //3
```
If you don't specify an argument, the default value of the parameters gets used. 

Compared to the older methods of setting default values, this new feature provided by ES6 is easier and much cleaner.

Happy Coding!❤
JavaScript's friendliest for loop: for...of loop 
Tags: webdev, javascript, es6
Published: 2018-12-15 17:53:23

---
title: JavaScript's friendliest for loop: for...of loop 
published: true
description: 
tags: #webdev #javascript #es6
---

<img src="https://thepracticaldev.s3.amazonaws.com/i/lspnw6e19x5hg2n8qt7v.jpg">
For many years in JavaScript, we have been <strong>iterating</strong> over <strong>iterables</strong> using the `for`, `for-in` and `forEach`(in the case of arrays).

I can't imagine how hard programming will be without these structures, they have indeed saved lives but ES6 is here again, with yet another powerful, cleaner and in my opinion, the most friendliest for loop: the `for...of` loop.

The `for...of` loop allows iteration over iterable objects such as arrays, strings, maps, etc with lesser and cleaner syntax.

Let's consider a regular `for-loop` for iterating over an array:

```javascript
  let names = ["runo", "peter", "saduwa"];

for(let i=0; i<names.length; i++){
 console.log(names[i]);
}
// runo
// peter
// saduwa

```

There's absolutely nothing wrong with this style, But with the `for...of` syntax we can achieve the same thing without having to initialize a counter variable `i` to keep track of the loop. See how we can use the `for...of` syntax to make our code much cleaner and readable:

```javascript
  let names = ["runo", "peter", "saduwa"];

for(let name of names){
 console.log(name);
}
// runo
// peter
// saduwa

```

See how clean the code looks, the `name` variable represents each element in the `names` array. 

<strong>Note:</strong> the value you loop over using the `for...of` loop must be an iterable. An iterable is simply an object that is able to produce an iterator. Examples of iterables in JavaScript are the arrays, strings, maps and sets, etc. Also node lists from the Dom tree.

Simple iteration over a string:

```javascript
  let name = "Runo";

for(let letter of name){
console.log(letter)
}

// R
// u
// n
// o
```

##Summary
The `for...of` loop is the latest for-loop in the JavaScript world that will help developers iterate over iterables such as arrays, strings, maps and sets with lesser and cleaner code. It also improves code readability with its focused syntax. 


Happy Coding!!
The new MacBook Pros are overpriced
Tags: discuss, laptop
Published: 2018-12-15 14:00:10

I've been a Mac user for over a decade but I'm lacking enthusiasm towards the recent wave of computers that Apple released (the disappointment started at least two or three years ago). 

Gone is the advantage they had with the first Intel based Macbook Pros in terms of quality and durability (Windows wasn't great also at the time and I was tired of Linux on the desktop).

My 2012 Macbook Pro 13" is still working well, a testament of such quality but... "times are a changing".

My feeling is that Apple has neglected their computers to focus on the smartphones. Nothing wrong with that, they are a private company, they can focus on whatever product they want.

My computer is starting to show its age, so I'm thinking about changing it in 2019.

Thanks to some discussions on dev.to, [some articles](https://medium.com/charged-tech/why-i-left-mac-for-windows-apple-has-given-up-b48c0eaac64) and the Windows Subsystem for Linux I'm keeping an open mind on the idea of switching back to a PC and Windows 10. 

I have to admit that I'm a little scared about going back to Windows. I hated Windows for a long time as a user and everytime I'm in front of a Windows computer my initial reaction now is more or less "how do I operate this thing? What happens if I click this? Do they still have viruses?". I firmly believe macOS is much simpler to use but if millions of people are fine with Windows, I'm sure I'll survive too I guess.

Yesterday I also watched this review from one of my favorite youtubers, Sara Dietschy, and I was quite impressed:

{% youtube 9uIy8n-nsB4 %}

(She's been slowly switching away from Apple laptops and workstations as she mostly does video editing)

Today I tried to compare the Dell XPS laptops (13" and 15") with equivalent configurations of MacBook Pros and well... MacBook Pros prices are a little too much in my opinion.

This is a comparison table I made with [Notion](https://www.notion.so/):

![](https://thepracticaldev.s3.amazonaws.com/i/r7x0q7soxb4ccgix6q91.png)

Dell XPSs are 1549€ and 1769€, MacBook Pros are 2270€ and 2417€. 700€ of difference 😱 And Dell laptops are expandable too, so you can put 32 GB of RAM and increase storage in the future.

The biggest hardware quirk of the Dell XPS is the placement of the webcam (at the bottom!?), but MacBook Pros have that ghastly touch bar and the weird butterfly keyboard people like to complain about. Dell XPS 15" model, for almost 700€ less, has a 4K touchscreen, a SD card and... different types of ports (requiring less adapters and dongles).

Do you think 2018 MacBook Pros models are overpriced? Am I missing something?
Cross-Platform GUI for DynamoDb (Electron + Vue.js)
Tags: aws, dynamodb, vue, javascript
Published: 2018-12-15 16:31:29

---
title: Cross-Platform GUI for DynamoDb (Electron + Vue.js)
published: true
description: Graphical User Interface for AWS DynamoDb
tags: aws, dynamodb, vue.js, javascript
---

Github Repository https://github.com/Arattian/DynamoDb-GUI-Client
Cross-platform GUI client for DynamoDb

https://thepracticaldev.s3.amazonaws.com/i/xlf92f3hz69uyfq9kojm.png

Features
- Remote Access of AWS DynamoDB Service*
- Local DynamoDB
- Supports multiple databases
- View
 - Table view
  - Records view
  - Table schema view
- Operation
 - Record
  - Add Record
  - Edit Record
  - Delete Record
 - Table
  - Add Table
  - Edit Table
  - Delete Table
 - Filter by attribute value
 - Filter by attribute name
For remote access, need to provide access and secret keys.All keys stored in localstorage.
Sometimes, the elegant implementation is just a function
Tags: discuss
Published: 2018-12-15 16:18:31

---
title: Sometimes, the elegant implementation is just a function
published: true
tags: discuss
---

> ““Sometimes, the elegant implementation is just a function. Not a method. Not a class. Not a framework. Just a function.” - John Carmack

This week we discuss this sage advice from John Carmack. We both agree on it, at least in principle, but we still discuss its relevance. Feel free to argue with us, we'll be happy to prove you wrong. :P

{% podcast https://dev.to/edaqa-and-stephane-podcast/15-in-praise-of-the-function %}

This perhaps relates to our [last episode about lasagna code](https://dev.to/mortoray/what-is-your-tale-of-lasagne-code-code-with-too-many-layers-3lp2). A lot of code is simply overly complex -- there's too much overhead and architecture to accomplish something simple.

I find it unfortunate that some languages, *ahem* Java and C#, don't even offer global functions.

What do you think? Is a plain function sometimes the right thing to do?