teleren/devto huggingface dataset:
De range() functie in Python (Dutch)
Tags: python, beginners
Published: 2020-02-21 15:06:53

<a href="https://python.org">Python</a> heeft een functie die getallen genereert, de *range* functie. Deze functie maakt een lijst van getallen.

De range() functie wordt vaak gebruikt in een <a href="https://pythonbasics.org/for-loops/">for loop</a>, om code een bepaald aantal keren te herhalen. Het kan ook gebruikt wordt voor het maken van een lijst met getallen want elk getal handmatig opschrijven is gewoon te veel werk.


## Range() voorbeelden

Als de range functie slechts één parameter heeft, telt deze van nul tot het maximum.

    range(maximum)

In Python 3 moet je het converteren naar een lijst (data type `list`). Zo wordt het een numerieke `list`.  In dit voorbeeld slaan we de `list` op in variabele l, die we dan weergeven.

    >>> l = list(range(5))
    >>> print(l)
    [0, 1, 2, 3, 4]
    >>> 


De functie maakt het mogelijk om de begin waarde en stap grootte te definiëren. Om te beginnen bij 5 met een stapgrootte van 2:

    >>> l = list(range(5,50,2))
    >>> print(l)
    [5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]
    >>> 

<img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fthumbs.gfycat.com%2FAchingWellinformedIndianrhinoceros-max-1mb.gif&f=1&nofb=1"> 

## Range loop voorbeeld

For loops zijn een manier om de code te herhalen (dit noemen we ook wel iteratie). Dat betekent dat je niet steeds dezelfde instructies hoeft te herschrijven, maar de code "terug kan springen" ofwel de code regels kan herhalen.

Voor gebruik in een for-loop hoeft u niet te converteren naar een `list`,

    >>> for i in range(0,6):
    ... print(i)
    ... 
    0
    1
    2
    3
    4
    5
    >>> 

In de for-lus kunt u de stapgrootte en de startwaarde gebruiken. In dit geval beginnend bij 1 met een stapgrootte van 3.

    >>> for i in range(1,30,3):
    ... print(i)
    ... 
    1
    4
    7
    10
    13
    16
    19
    22
    25
    28
    >>>

**Gerelateerde links:**
* <a href="https://docs.python.org/3.5/library/stdtypes.html#typesseq-range">Range functie in Python-documentatie</a>
* <a href="https://pythonbasics.org">Python beginner lessen</a>
* <a href="https://gum.co/dcsp">Python cursus</a>
Start to spend time on refactoring
Tags: codequality, refactoring
Published: 2020-02-21 14:59:14

Let's start with a catchphrase: Everything changes! Why your base code don't?

I've participated of many projects with million legacy code lines, so I surely can say that: any kind of project must have a huge refactoring culture, no matter if the managers think that is a waste of time. They can't be more wrong.

## The "tech world" changes everyday
We have no news here: the developers biggest challenge is to keep updated about what is running on tech world.

It's not hard to a project become outdated because of many reasons and the most common is to ignore the growth of all technologies used in the entire project. 

I bet that you already have worked in a PHP5 based project that can't be evolved to version 7 because "it will be a wast of time and money".

Absolutely it is losing a lot of performance, security, code health, development velocity and more. You must ever spend time refactoring some things to keep updated and enjoy the best of technologies can provide.

## The dev team is ever evolving
The experience acquired while software developing is the main factor to become a better developer, so, no matter if the code was wrote a week or few years ago, it can be evolved.

![dev](https://i.ibb.co/fNWMvP8/kyle-blog-pic.png)

## The project is ever growing up
Sometimes your project was developed to be X and them becomes Y, and that's OK! The problem: without refactoring, your project will be a truly Frankstein soon. It's like to build a ship then set wings to fly. It has a big chance to not work.

Obviously if big changes like that is previous noticed, and the project was planned to have that big changes, everything will be fine. Instead, a refactoring will be necessary.

Keep you code healthy! Refactor it.
De time.sleep() functie (Dutch)
Tags: python, beginners, dutch, nederlands
Published: 2020-02-21 14:54:44

<a href="https://python.org">Python</a> heeft een module speciaal om met tijd gerelateerde functionaliteit om te gaan. Je kunt hiermee de code laten pauzeren/wachten. Om dit te doen, moet u eerst de `time` module importeren

    #!/usr/bin/python3
    import time

In deze module zit de functie `sleep()`. Dwz `time.sleep()`

## Pauze in Python

Om de code een paar seconden "te laten slapen" dw wachten, kunt u de method time.sleep() gebruiken.

    time.sleep (sec.)

Bijvoorbeeld om de code vijf seconden te laten pauzeren

    time.sleep(5)

Je kunt dit ook gebruiken voor pauzes korter dan een seconde

    tijd.slaap(.500)

De parameter kan dus zowel een geheel getal (x aantal seconden) of een float zijn.


## Sleep vs. threads

Voor de duidelijkheid: het hele programma wordt gepauzeerd. Dat betekent dat gedurende `time.sleep()` draait het programma absoluut niets doet, zelfs niet reageren op de invoer van het toetsenbord. 

Soms is dat handig, bijvoorbeeld bij een stop watch. Bij desktop applicaties is dat toch wat minder, stel je voor dat je de web browser niet kan gebruiken tijdens het downloaden van een bestand.

Als het programma verschillende dingen tegelijk moet doen, kun je <a href="https://pythonprogramminglanguage.com/threading/">threading</a> gebruiken. 

Elke taak loopt in een aparte `thread`, dus het programma zou kunnen pauzeren terwijl het nog steeds invoer van het toetsenbord of het ontvangen van gegevens voor het netwerk krijgt. 

<img src="https://external-content.duckduckgo.com/iu/?u=http%3A%2F%2Fpitchenginelive.blob.core.windows.net%2Frefinery%2F28f29690-4305-4640-95e9-c04dab195652%2FGallery%2F4df83d29-aac3-4158-aed7-103e1aa26745.png&f=1&nofb=1" alt="threading">

## Hoe nauwkeurig is time.sleep() ?

De `sleep()` method maakt gebruik van de sleep() functie van het besturingssysteem. Met andere woorden, bestaande functionaliteit in je besturingssysteem. Besturingssystemen zijn meestal niet real-time (windows,linux en mac bv niet). 

Omdat besturingssystemen niet accuraat zijn zoals een atoomklok, hebben ze enige vertraging. 

Maar maak je geen zorgen, deze vertraging is meestal 1-10 milliseconden en maakt voor 99% van de apps niet uit. Er zijn situaties mogelijk waar dit belangrijk is, maar niet voor de gemiddelde huis-tuin en keuken app.

**Gerelateerde links:**

* <a href="http://docs.python.org/3.0/library/time.html">Python-tijdmodule</a>
* <a href="https://pythonbasics.org/time-and-date/">Tijd en datum in Python</a>
* <a href="https://pythonbasics.org/">Python tutorial</a>
Are you reading the "What's New" in .NET docs?
Tags: dotnet, csharp
Published: 2020-02-21 17:25:07

---
title: Are you reading the "What's New" in .NET docs?
published: true
date: 2020-02-21 14:47:32 UTC
tags: dotnet, csharp
canonical_url: https://tattoocoder.com/are-you-reading-the-whats-new/
---

 ![Are you reading the](https://tattoocoder.com/content/images/2020/02/document_desk.png)

Did you know that every month, the docs team at Microsoft has a post for [what's new in the .NET documentation](https://docs.microsoft.com/dotnet/whats-new/?WT.mc_id=blog-docs-shboyer)?

For each month there are new articles, updates to existing docs, and kudos for the [community contributors](https://docs.microsoft.com/en-us/dotnet/whats-new/dotnet-2020-01#community-contributors).

> It's super easy to get involved in contributing to the docs for the related technologies you are invested or interested in.  See the [Microsoft docs contributors guide](https://docs.microsoft.com/contribute?WT.mc_id=blog-docs-shboyer) or simply click the "Edit" link at the top of any doc to get started, they are all open source!

Here are some of the highlights for[last month](https://docs.microsoft.com/dotnet/whats-new/dotnet-2020-01?WT.mc_id=blog-docs-shboyer) .NET Docs

The [**Architecting Cloud-Native Apps for Azure architecture guide e-book**](https://docs.microsoft.com/dotnet/architecture/cloud-native/?WT.mc_id=blog-docs-shboyer) added some new sections -

- [Caching in a cloud native app](https://docs.microsoft.com/dotnet/architecture/cloud-native/azure-caching?WT.mc_id=blog-docs-shboyer)
- [Database per microservice](https://docs.microsoft.com/dotnet/architecture/cloud-native/database-per-microservice?WT.mc_id=blog-docs-shboyer)
- [Elasticsearch in in a cloud native app](https://docs.microsoft.com/dotnet/architecture/cloud-native/elastic-search-in-azure?WT.mc_id=blog-docs-shboyer)

**[C# language](https://docs.microsoft.com/dotnet/csharp/?WT.mc_id=blog-docs-shboyer)** revised the [Value types](https://docs.microsoft.com/dotnet/csharp/language-reference/builtin-types/value-types?WT.mc_id=blog-docs-shboyer) and [added new <inheritdoc> xml documentation](https://docs.microsoft.com/dotnet/csharp/programming-guide/xmldoc/inheritdoc?WT.mc_id=blog-docs-shboyer)

**.NET** added a great new article in the **[.NET Guide](https://docs.microsoft.com/dotnet/standard/?WT.mc_id=blog-docs-shboyer)** on [How to migrate from Newtonsoft.Json to System.Text.Json](https://docs.microsoft.com/dotnet/standard/serialization/system-text-json-migrate-from-newtonsoft-how-to?WT.mc_id=blog-docs-shboyer)

Other areas of the docs are also adding similar related what's new pages too. Check out **[ASP.NET Core docs updates](https://docs.microsoft.com/aspnet/core/whats-new/?view=aspnetcore-3.1&WT.mc_id=blog-docs-shboyer)** and **[Xamarin updates](https://docs.microsoft.com/xamarin/whats-new/?WT.mc_id=blog-docs-shboyer)** too!

The docs continue to grow and evolve. Check in often on these pages to keep up to date with the latest content.

 ![](http://feeds.feedburner.com/~r/Tattoocoder/~4/y5qmK8RV5Vw)
Hub the GitHub wrapper you never knew
Tags: git, productivity, webdev
Published: 2020-02-21 11:38:34

Hi everyone,

Today I am writing about `hub`, the GitHub wrapper that can help you save time when you don't want to leave the console(terminal) and still want to add git as version control to your project.

I find it very useful when I want to create a new project on Github to just type in the root of my project:

```shell
hub init 
hub create
```

These commands, if you have GitHub set up right, will create your repo on Github and also push the project. So we can already start branching or tagging.

Also if you ever want to find out more about what `hub` can do. Just type `hub` in the terminal like this:

```shell
hub
```

This is just a fraction of what hub can do and I will also have to explore it more.


Hub installation and download instructions can be found here 

https://hub.github.com/

I highly recommend you to try it, **Dear Reader**. 

Will you take it for a test?


Credits:

https://hub.github.com/

Thank you, Andrew Clayton for spotting a typo in the opening paragraph regarding Github instead of git.

Thank you @rhymes

https://github.com/cli/cli
What is the best Javascript Stack to choose in 2020 ?
Tags: discuss
Published: 2020-02-21 14:27:51

---
title: What is the best Javascript Stack to choose in 2020 ?
published: true
description: 
tags: discuss
---

If you have to select one Javascript Stack that has: 

- High Performance 
- Easy Learning curve 
- best community support 

Which stack will you choose and why?

![](https://media.giphy.com/media/14mgxYFJHXGmoo/giphy.gif)
Django Best Practices: Docker
Tags: django, python, tutorial, beginners
Published: 2020-02-21 14:17:29

[Docker](https://www.docker.com/) is a very popular tool for managing Django projects. Many professional developers use it but I find it is still confusing to many newcomers. In this post I'll attempt to demystify what Docker is and why it is such a powerful addition to working with Django.


## What is Docker?
The easiest way to think of Docker is as a large virtual environment that contains everything needed for our Django project: dependencies, databases, caching services, and any other tools needed.

This is **not** the same thing as a virtual environment. A virtual environment helps isolate individual software packages--like which version of Django you're using and other Python packages--but it cannot extend to outside services like a PostgreSQL database. Docker can. It is an entire contained development environment that can be used both locally and in production.

## Production Databases

Django ships with SQLite as the default database and it is a great choice for quick prototyping. But...you don't want to deploy to SQLite in production, instead you're more likely to use something like PostgreSQL or MySQL. While you *can* use SQLite locally and then deploy to a production database this is not advised. There are many bugs that can creep up when your local dev environment does not match your production environment.

The answer is to run your own instance of, say, PostgreSQL locally. However this can be a challenging experience. You must correctly install and then run a PostgreSQL instance on its own. Then you need to connect your Django app. It's doable, but error-prone.

And if you have additional services running in production like a Redis cache that also is tough to configure locally but much simpler with Docker. You can accurately mimic your production environment locally, which is the holy grail for web developers.

## Teams

Now consider what happens if you're on a team of developers. How do you ensure that every developer is working on the same local setup? Especially when both the local database and its config varies wildly from developer to developer?

This is where Docker really shines. With Docker you an ensure that each team member is working on exactly the same local dev environment which is a huge benefit. Trust yourself lucky if you haven't learned this from personal experience.

## Docker, Docker, Docker

So why use Docker? Because it simplifies configuring your own local dev environment. Because installing Postgres, Redis, and other dependencies locally is a nightmare. And because Docker ensures you work on **exactly** the same specs as other members of your team.

Docker is less about deployment and more about faithfully recreating your production environment locally. That's where it shines.

If you'd like to learn how to use Docker and Django to build production-ready applications, my book [Django for Professionals](https://djangoforprofessionals.com) covers it in detail.
Impostor syndrome and pressure
Tags: juniordeveloper, discuss
Published: 2020-02-21 13:56:47

- How do you deal with impostor syndrome when you are just starting your tech career? 
- Specially when your workplace already had a person from the same bootcamp you come from but with more coding experience and practice prior to starting the same position?  
- Since this person picked up things considerably fast at work. Hints of slow progress are pointed towards me. I feel their expectations have not been met. 
- What can one do about this? Apart from raising the issue?
- I keep learning and applying my knowledge. Maybe I just need more practice and time?
Django Best Practices - Imports
Tags: django, python, tutorial, beginners
Published: 2020-02-21 13:33:55

Imports are an inevitable part of Python and Django development. [Pep8](https://pep8.org/#imports), which is the official style guide for Python, recommends imports be placed at the top of the file, on separate lines, and grouped in the following order:

1. Standard library imports
2. Related third party imports
3. Local application/library specific imports

Whenever possible, be as explicit as possible with imports.

Here's an example `views.py` file from the Blog app built in my [Django for Beginners](https://djangoforbeginners.com/) book.

```python
# blog/views.py
from django.views.generic import ListView, DetailView
from django.views.generic.edit import CreateView, UpdateView, DeleteView
from django.urls import reverse_lazy

from .models import Post # explicit relative import

class BlogListView(ListView):
    model = Post
    template_name = 'home.html'
```

The top 3 lines are **absolute imports** which are used when importing packages from *outside* a given app. This is how all Django core code is imported.

The database model is imported using an **explicit relative import**--we didn't hardcode the app name in here which makes it much more reusable. If we had instead done `from blog.models import Post` then if the name of the `blog` app changed in the future or we wanted to separate out this code, the import would fail.

Another good rule of thumb is to never use `*` which accesses **all** imports. For example, this is a bad idea:

```python
# blog/views.py
from django.views.generic import * # BAD IDEA!
```

Why import things you don't need? Plus what if `views.generic` changes at some point in the future in unforeseen ways which opens up security concerns.

## Takeaway

You'll likely see different import styles in open source and professional code settings. Try to follow PEP8 as closely as possible. Use absolute imports when necessary and prefer explicit relative imports for your local Django code.
Augmented Reality business card with headshot using Xamarin, .NET and C#
Tags: xamarin, ar, augmentedreality
Published: 2020-02-21 13:33:42

Augmented Reality business card with headshot and social media attempt 1 using #Xamarin #Arkit and C#/.NET. Animations included this time.

More examples can be seen on [https://xamarinarkit.com/videos](XamarinArkit.com/videos) where I am documenting my Xamarin ArKit learning in the form of lessons for others benefit.

{% youtube 3b9hID1rKtc %}

{% twitter 1230743803545321472 %}

-- Lee
The J in JAMstack Does Not Stand for React (or Angular, Vue, Svelte, etc.)
Tags: webdev, jamstack
Published: 2020-02-21 13:31:12

---
title: The J in JAMstack Does Not Stand for React (or Angular, Vue, Svelte, etc.)
published: true
description: Correcting what seems to be a common misconceptions about what makes an app JAMstack
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/p9dx9kwg9oqiefyz57ox.jpg
canonical_url: https://remotesynthesis.com/blog/j-in-jamstack
tags: webdev,jamstack
---

Once upon a time, I was asked to present the best static site generators for JavaScript developers. I painstakingly went through each of the available options at the time and then got to the end where I revealed which one I recommended. The answer: none of them. Compared to the other options at the time (Jekyll, Hugo, Middleman), they were slow, less full-featured and lacking in much of an existing ecosystem (or documentation).

Thankfully, that is not the case anymore. There are a ton of great options for JavaScript developers including [Gatsby](https://www.gatsbyjs.org/), [Next.js](https://nextjs.org/) and [React Static](https://github.com/react-static/react-static) if you prefer React, [Nuxt](https://nuxtjs.org/), [Gridsome](https://gridsome.org/) and [VuePress](https://vuepress.vuejs.org/) if you prefer Vue, and more recently, [Scully](https://github.com/scullyio/scully) for those who prefer Angular.

The existence of mature JavaScript-based tools has been part of the growth of the overall usage of static site generators, which are a key ingredient in the JAMstack. However, this seems to be fueling a common misconception that the frameworks themselves are a key part of the JAMstack - that the J in JAMstack is for your JavaScript framework. This is _not_ the case.

It's important to keep in mind that in 2016 when the term JAMstack first came about, Gatsby was little more than a year into its existence and far from the powerhouse it is today. Next.js came around in 2017; Gridsome in 2018. The point is, JavaScript frameworks were not even a relevant factor in the the term JAMstack. The role of JavaScript as [originally defined](https://web.archive.org/web/20160527203229/http://jamstack.org/) was as follows:

> JavaScript is in charge of any dynamic programming during the request/response cycle and runs entirely on the client.

My goal here is not to dissuade you from using a JavaScript framework. If you are a JavaScript developer, there are great tools for you if you'd like to use a JavaScript-based static site generator. However, I think it is a mistake if we confuse the term whereby JAMstack becomes synonymous with JavaScript frameworks. I believe one of JAMstack's strengths is the variety of options that are available (though, the variety of choices can also make JAMstack a bit intimidating). The fact that there are enough tools, even among just the widely used ones, for developers with varying programming backgrounds, whether that is JavaScript, Ruby, Go, Python, or others. If you're a developer, it's likely that regardless of what you program in, there is a static site generator that fits into your JAMstack.
Django Best Practices - Template Structure
Tags: django, python, tutorial, beginners
Published: 2020-02-21 13:29:11

There are two main ways to organize your template structure in Django: the default app-level way and a custom project-level approach.

## Option 1: App Level
By default the Django template loader will look within each app for a `templates` folder. But to avoid namespace issues you *also* need to repeat the app name in a folder below that before adding your template file.

For example, if we had an `example_project` with a `pages` app and a `home.html` template file, the proper structure would be like this: within the `pages` app we create a `templates` directory, then a `pages` directory, and finally our `home.html` file.

```
├── example_project
│   ├── __init__.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
|   └── pages
|      ├── __init__.py
│      ├── admin.py
│      ├── apps.py
│      ├── models.py
│      ├── tests.py
│      └── views.py
|      ├── templates
|          ├── pages
|              ├── home.html
└── manage.py
```

This is demonstrated in the [official Django polls tutorial](https://docs.djangoproject.com/en/dev/intro/) and works just fine.

## Option 2: Project Level
As a Django projects grow in size it's often more convenient to have all the templates in one place rather than hunting for them within multiple apps. With a single line change to our `settings.py` file, we can do this.

Update the `'DIRS'` config under `TEMPLATES` as follows, which specifies that *in addition* to looking for an app-level templates directory, the Django template loader should *also* look for a project-level templates directory.

```python
# settings.py
TEMPLATES = [
    {
        ...
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        ...
    },
]
```

Then create a `templates` directory at the same level as the project. Here's an example of what it would look like with the `home.html` file.

```
├── example_project
│   ├── __init__.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
|   └── pages
|      ├── __init__.py
│      ├── admin.py
│      ├── apps.py
│      ├── models.py
│      ├── tests.py
│      └── views.py
├── templates
    ├── home.html
└── manage.py
```

## Next Steps

Remember the Django template loader will look for an app-level `templates` directory and then--if we update the `DIRS` setting--it will _also_ look for a project-level `templates` directory. There is no "right" way to organize templates within your Django project but many developers, myself included, prefer the project-level approach.
ปัญหา Xcode กับ Git
Tags: xcode, git, github
Published: 2020-02-21 13:19:21

Xcode จะมีปัญหาในการดึง source จาก GitHub ถ้าเซ็ตค่าในไฟล์ ~/.gitconfig แบบนี้

```
[url "git@github.com:"]
insteadOf = https://github.com/
```

ดังนั้นถ้าจะใช้ Xcode ให้เอาออกซะ

credit - https://github.com/grpc/grpc-swift/issues/687#issuecomment-572017587