teleren/devto huggingface dataset:
How To Neovim Inside VS Code
Tags: vim, vscode, productivity
Published: 2021-04-27 16:14:16

If you've been wanting to try out and learn vim, but don't want to leave the comforts of VS Code behind, this tutorial is for you. In this tutorial, I will show you how to achieve (what I consider to be) the best of both worlds when it comes to using these tools together.

## Installation

First, we'll start off by adding the [Neovim extension for VS Code](https://marketplace.visualstudio.com/items?itemName=asvetliakov.vscode-neovim). Once that extension is installed, we're going to need to point the extension at an instance of neovim. It's very important that we use v0.5.0 instead of anything v0.4 or lower. If you do, you'll experience a hard time with this extension.

Once you download and install the [Neovim v0.5.0](https://github.com/neovim/neovim/releases/tag/nightly), you're going to want to point your Neovim extension at this installation.

![neovim extension settings](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/syt5eoupb8fmeetjjnmo.png)

## Configuration

I like to turn the ctrl keys for insert and normal mode off. This means you can still use ctrl + c all the other vs code keybindings will work as expected. 

![ctrl keys off](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fkqefvku6nvj34c5bu7w.png)

I also like to double-tap j while in insert mode to escape into normal mode. You can add the following snippet to your `keybindings.json` if you'd like:

```json
{
    "command": "vscode-neovim.compositeEscape1",
    "key": "j",
    "when": "neovim.mode == insert && editorTextFocus",
    "args": "j"
}
```

## Conclusion

I hope you enjoy learning VIM from the comfort of your VS Code editor! [Here's a great VIM cheat sheet](https://www.maketecheasier.com/cheatsheet/vim-keyboard-shortcuts/) I have bookmarked with a bunch of great and useful keyboard shortcuts for VIM.
Mount light weighted apps into Ember
Tags: ember, svelte, react, lightweightapps
Published: 2021-04-27 15:58:59

This article is a demonstration on how to mount light weighted apps made with Preact, Svelte, etc. along with a dedicated router into Ember.

Right now, this can be achieved with certain router packages​ like https://single-spa.js.org. However, let's try a different approach.
<br>
For demo, let's choose **Ember and Preact** and define two routes in Ember
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uye1s6tw35ysznxfficz.png)<br>

And again define three routes in Preact
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8kjoaxfecmp3ud7eeuv3.png)<br> 

At this point, these are two stand-alone apps, which would render in different html pages. Let **Ember** be our **base app**,  and to mount Preact App into Ember, we need **a route(page) which certainly acts as an exit point for Ember and entry point for the Preact App**.
​
There are two set of changes here.

​1. Define **exit route** in Ember(Say `/ember-exit-route`)​
​2. Use `/ember-exit-route` as **base url** for the Preact App.
​
Now, we add two more routes in the Ember App, which handles the url `/ember-exit-route` and all child paths beyond that say(`/ember-exit-route/home`, `/ember-exit-route/profile`,...)

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ro194krrg0xmtth9u812.png)

`/*path` denotes a wildcard, which catches all the paths coming after `/ember-exit-route`.

 ​​​
And we define the ​exit url as base path in the Preact App.

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iq5xxqt9o8nar63erdd9.png)<br>

​​​Now, the last part, once we visit `/ember-exit-route`, we need to load the assets of the Preact App and render it inside an element.

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/snlvgnl5bm5bf0w01xzu.png)
 
That's it. 

**Demo link**: https://ember-preact-demo.netlify.app/

Let me know your thoughts on this.
Apache Virtual Host
Published: 2021-04-27 15:56:55

---
title: Apache Virtual Host
published: true
description: 
tags: 
//cover_image: https://direct_url_to_image.jpg
---

# Apache Virtualhost

O servidor apache permite virtualizar diferentes sites numa mesma máquina. O que facilita testar mais de um projeto no mesmo servidor local.

## Associando um Host Name com o IP local da máquina

Primeiro vamos editar o arquivo `/etc/hosts`. Esse é o arquivo do sistema operacional que traduz nomes de host ou nomes de domínio em endereços IP.

Edite o conteúdo desse arquivo como visto abaixo.

```
127.0.0.1 localhost
127.0.0.1 vhost_domain.lan
127.0.0.1 www.vhost_domain.lan
```

Salve o arquivo e experimente acessar a URL `vhost_domain.lan`, você pode fazer isso através do navegador ou pelo terminal: `curl vhost_domain.lan`.

Nesse momento o resultado de `vhost_domain.lan` deve ser idêntico ao resultado de localhost.

## Configurando o Apache

Crie o diretório para o `vhost_domain`

```
sudo mkdir /var/www/vhost_domain
```

Passe para o usuário atual a propriedade deste diretório

```
sudo chown -R $USER:$USER /var/www/vhost_domain
```

Crie uma página de amostra `index.html` utilizando seu editor favorito:

```
sudo $EDITOR /var/www/vhost_domain/public_html/index.html
```

Dentro, adicione a seguinte amostra HTML:

```
<!--/var/www/vhost_domain/public_html/index.html-->
<html>
    <head>
        <title>vhost_domain</title>
    </head>
    <body>
        <h1>Ah moleque!</h1>
    </body>
</html>
```

O Apache guarda na pasta `/etc/apache2/sites-available` arquivos de configuração para sites que estão disponíveis, mas não necessariamente ativados. Crie nessa pasta um arquivo denominado `vhost_domain.conf` com o seguinte conteúdo.

```
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName vhost_domain
    ServerAlias www.vhost_domain.lan
    DocumentRoot /var/www/vhost_domain/public_html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
```

## Ativando o novo virtualhost

Vamos habilitar o arquivo com a ferramenta `a2ensite`:

```
a2ensite vhost_domain.conf
```

Caso precise desabilar use o comando a seguir

```
a2dissite vhost_domain.conf
```

É possível testar à procura de erros de configuração:

```
sudo apache2ctl configtest
```

Você deve receber a seguinte saída:

```
Output
Syntax OK
```

Reinicie o Apache para implementar as suas alterações:

```
sudo systemctl restart apache2
```

O Apache agora já deve estar atendendo ao nome de domínio. Teste isso navegando para `http://vhost_domain.lan`, onde você deve ver algo assim:

## Referência

- https://httpd.apache.org/docs/2.4/vhosts/index.html
WIP: Testing in Meteor
Tags: meteor, testing, react, javascript
Published: 2021-04-27 15:16:06

While reading through the [Meteor Guide article on testing](https://guide.meteor.com/testing.html), I noticed that the section on acceptance testing still recommended Chimp. Chimp is...a bit old at this point, and Chimp 2.0 is not maintained. I see [people on the forums recommending cypress.io for acceptance tests](https://forums.meteor.com/t/2020-best-test-packages/54587/4?u=wizonesolutions).

Since I do I have one end-to-end test I want to write, I figured I'd try to document at least some of my experience setting up testing in my app DayMeter as I go. I might also propose changes to the Meteor Guide article. This post will be my way of thinking about it.

I'll be starting implementation this week (it's 27 Apr 2021 right now), so I will come back and revise this post as I go.

28 Apr:

I'm seeing varying opinions on what to use for unit and integration tests. [jkuester and @hexsprite generally use what's in the Guide](https://forums.meteor.com/t/2020-best-test-packages/54587/2?u=wizonesolutions).

[awatson1978's approach differs in some ways](https://forums.meteor.com/t/which-testing-frameworks-are-popular-today-end-2018/46480/11?u=wizonesolutions). She uses Jest for UI testing and Nightwatch for end-to-end tests. Cypress isn't mentioned, but it might not have been as mature in 2019. I don't know enough to comment.

**I'm going to start with the Meteor Guide recommendations and see if they get the job done.** I'll probably try to use as few packages as possible unless things start getting cumbersome. I don't have many initial tests to write, so I'll see how things go.

29 Apr:

A lot of people seem to just use Cypress. I probably could too, although I have one method where I probably want to make sure it's working a little more closely than just looking at its output. So I'm going to try Mocha and an integration test for that.

22 Sep:

Long break, right? 😅 I've been working on this again, and have settled on using Mocha for integration tests. It works great for my purposes. I'm also using `xolvio:cleaner` to reset the database before each test. I was able to fix a longstanding bug in the app and ensure I didn't cause any critical regressions. I'm glad I wrote tests!

Today, I have to figure out what I want to do for acceptance testing. Once that's done, I'll take a look at Storybook testing again if I have time. There's a different testing landscape there, some of it brittle, some of it more stable. I have to think about if I have any "critical paths" that I'm likely to break as I keep developing things or if simply have stories for each component that I check up on manually is good enough (given that I will also have acceptance for the most important functionality).

I'm leaning towards not doing more testing in Storybook specifically *yet*. That seems like the right amount of testing for now.

I'll then aim for test-driven development (TDD) going forward.
Should M-V-C not actually be M-D-V-C?
Tags: help, beginners, mvc
Published: 2021-04-27 15:35:34

I recently took first steps using the MVC pattern. While coding along, I was reflecting on the idea of *separation of concerns*, which made sense to me and turned out to be really helpful in my coding.

Nonetheless, I was asking myself a few practical questions:

* Would you consider it bad style if the controller accessed information directly in the model instead of using a get/set method?

```
class Model {
  data = data;
}

class Controller {
  doSomeControlling = function() {
    model.data += 9;
  }
}

const model = new Model();
const controller = new Controller();
```
* Assuming my model is obtained from who-knows-where (e.g. a database), should I include a fourth element *dataHandler* between model and controller? I am thinking about ensuring that if the database changes, etc., I still have the possibility to retain my model. Or should I rather implement model-get/set-methods that handle exactly this?

```
class Model {
  data = ...;
}

class DataHandler {
  getDataFromADatabase = function() {
    // lots of database connection stuff
    return data;
  }
}

class Controller {
  setData = function() {
    model.data = dataHandler.getDataFromADatabase();
  }
}
``` 

## Further questions about structure unrelated to the heading

* Does it make any sense to implement e.g. a controller as a class, when you are anyways going to instantiate it right away, and only once? (see last two lines of first code sample above)

* How extreme should you be with methods? I can find a method for lots of small bits that might make the higher-level-function **a lot easier** to read, but adds lots of methods which would more or less only be used once. Or in other words: When is enough enough? :)

Thank you for your thoughts!

*Photo by [Mihai Strompl](https://unsplash.com/@mihaistrompl?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) on [Unsplash](https://unsplash.com/s/photos/separation?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText)*
How to Use Type Annotations in Python
Tags: python, programming, datascience, tutorial
Published: 2021-04-27 15:32:32

{% youtube QrzHImDEq_w %}

Type annotations - also known as type signatures - are used to indicate the datatypes of variables and input/outputs of functions and methods.

In many languages, datatypes are explicitly stated. In these languages, if you don't declare your datatype - the code will not run.

Type annotations have a long and convoluted history with Python, going all the way back to the first release of Python 3 with the initial implementation of function annotations.

Type annotations in Python are not make-or-break like in other languages (like C). They're optional chunks of syntax that we can add to make our code more explicit.

Erroneous type annotations will do nothing more than highlight the incorrect annotation in our code editor - no errors are ever raised due to annotations.

So, if type annotations are not enforced, why use them?

Well, as we touched upon already - declaring types makes our code more explicit, and if done well, easier to read - both for ourselves and others.
If you don’t code at your job, how do you keep your skills sharp?
Tags: watercooler, discuss, productivity, career
Published: 2021-04-27 15:32:21

Like most skills, if you don’t code after a long time you’ll become rusty! 

Maybe you previously worked on coding projects at work but moved on to another position that requires you to code a lot less or not at all. Or maybe coding is something you do on the side and it's not compulsory that you code.

If you’re not currently working in a position that requires you to code how do you make sure your skills are kept sharp?

At my work I've moved on to responsibilities that requires a lot less coding. But in my spare time I still work on some projects on the side. I'm also working on building a developer community called [inspirezone](https://community.inspirezone.tech/) which keeps me actively working on something.
Python Zero to Hero - Ep.41 - Last time we ganna talk about emoji prediction for a while
Tags: python, pypi, video, packaging
Published: 2021-04-27 15:13:27

---
title: Python Zero to Hero - Ep.41 - Last time we ganna talk about emoji prediction for a while
published: true
description: It will be the last time we ganna talk about emoji prediction for a while, could we package the library and release it on PyPI?
tags: python, pypi, video, packaging
---
It will be the last time we ganna talk about emoji prediction for a while, could we package the library and release it on PyPI? If you have any questions or any suggestions about which Python topics to cover, please leave your comment at my [Twitch channel](https://www.twitch.tv/cheukting_ho)
Ways to create a Java Object
Tags: java, object
Published: 2021-04-27 15:11:38

https://grokonez.com/java/ways-to-create-a-java-object

Ways to create a Java Object

Object is an important concept in Java Development. This tutorial shows you the ways to create a Java Object.

<!--more-->
<div id="tuttoc" class="jsa-toc"></div>

<div id="tutcontents">
<h2>I. Ways to create a Java Object</h2>
<h3>1. Using 'new' keyword</h3>
This is the most popular way to create an object.
<pre class="lang:java">
MyJavaClass object = new MyJavaClass();
</pre>
<h3>2. Using Class.forName()</h3>
Instead of calling <code>new MyJavaClass()</code>, we can call <code>newInstance()</code> method in this way:
<pre class="lang:java">
MyJavaClass object = (MyJavaClass) Class.forName("com.javasampleapproach.createobject.MyJavaClass").newInstance();
</pre>
<h3>3. Using newInstance() method of Constructor class</h3>
<strong>java.lang.reflect.Constructor</strong> class has <code>newInstance()</code> method which can be used to create objects.
<pre><code class="language-java">
Constructor<MyJavaClass> constructor = MyJavaClass.class.getConstructor();
MyJavaClass object = constructor.newInstance();
</code></pre>
<h3>4. Using clone() method</h3>
There will be no constructor to be invoked when using <code>clone()</code> method, the <strong>JVM</strong> generates exactly the object which content is the same as content of the object which call the method.
<pre><code class="language-java">
// we should implement Cloneable and define the clone() method before
MyJavaClass object2 = (MyJavaClass) object1.clone();
</code></pre>
<h3>5. Using Object Deserialization</h3>
This way creates an object from its serialized form. We should implement a <strong>Serializable</strong> interface in the class before.

More at:

https://grokonez.com/java/ways-to-create-a-java-object

Ways to create a Java Object
How to work with Java HashMap
Tags: java, hashmap
Published: 2021-04-27 15:05:28

https://grokonez.com/java/java-advanced/work-java-hashmap

How to work with Java HashMap


In the tutorial, <a href="https://grokonez.com/" target="_blank">JavaSampleApproach</a> will introduce you how to work with <strong>Java HashMap</strong>

<!--more-->


<h2>I. Concepts</h2>
Java HashMap is a construction of Map interface, so it provides all methods of Map interface.
Related post: <a href="https://grokonez.com/spring-framework/spring-core/work-java-map-interface" target="_blank">How to work with Java Map Interface</a>

- It permits a <strong>null</strong> key and <strong>null</strong> values
HashMap provides 3 Constructors:
- HashMap(): default initial capacity (16) and the default load factor (0.75).
- HashMap(int initialCapacity, float loadFactor)
- HashMap(Map<? extends K,? extends V> m): constructs a new <strong>HashMap</strong> with the same mappings as the specified Map.
<strong>Note</strong>: In common case, we use empty constructor HashMap() & HashMap(Map<? extends K,? extends V> m) constructors.
Example:
<pre><code class="language-java">
//a void (no arguments) constructor
Map<Integer, String> map = new HashMap<Integer, String>();
 
//a constructor with a single argument of type Map
Map<Integer, String> newMap = new HashMap<Integer, String>(map);
</code></pre>

For insert and retrieve a key-value mapping, we uses: <strong>put()</strong> & <strong>get()</strong> methods.
- put(K key, V value)
- putAll(Map<? extends K,? extends V> m)
- get(Object key)

More at:

https://grokonez.com/java/java-advanced/work-java-hashmap

How to work with Java HashMap
Amazing Image Hover Effect Using HTML & CSS
Tags: html, css, webdev, beginners
Published: 2021-04-27 15:03:04

Hello, 

Today I created an Amazing Image Hover Effect Using HTML & CSS. when you hover on the image it's changing blur & grayscale also have some cubic-bezier animation in this post. I hope you like this also comments about your thoughts.

For more content follow me on Instagram  [@developer_nikhil27](https://www.instagram.com/developer_nikhil27/).

If you want to more support me then buy me a [coffee](https://www.buymeacoffee.com/nikhilbobade27).

Thank you!

{% codepen https://codepen.io/NikhilBobade/pen/RwKOWPM %}
Pytorch MNIST Dataset Error
Tags: deeplearning, python, pytorch
Published: 2021-04-27 14:55:39

There seems to be some problem with the Hosting, and the Pytorch team is solving the following issue.

Use this code to solve the issue. It provides a new mirror to download the dataset.
```
from torchvision import datasets,transforms
new_mirror = 'https://ossci-datasets.s3.amazonaws.com/mnist'
datasets.MNIST.resources = [
   ('/'.join([new_mirror, url.split('/')[-1]]), md5)
   for url, md5 in datasets.MNIST.resources
]
train_dataset = datasets.MNIST(
   "../data", train=True, download=True, transform=transforms.Totensor()
)
```
Courtesy: https://stackoverflow.com/questions/66577151/http-error-when-trying-to-download-mnist-data
Java Regular Expression Overview – Syntax
Tags: java, regularexpression, syntax
Published: 2021-04-27 14:53:30

https://grokonez.com/java/java-regular-expression-overview-syntax

Java Regular Expression Overview – Syntax

<strong>Regular expression</strong> (regex) defines patterns to recognise strings. Those patterns can be anything: a character, a specific string, a group of special characters or a combination of them. We can use <strong>Regular expression</strong> for <em>searching</em>, <em>extracting</em>, and <em>modifying text</em>.
This tutorial shows you an overview of Regular Expression <strong>Syntax</strong>.

<!--more-->
<div id="tuttoc" class="jsa-toc"></div>

<div id="tutcontents">
<h2>I. Syntax</h2>
<h3>1. Characters</h3>
To define content of a regex pattern, we use many kinds of character classes:
<table style="padding-right:0">
  <tr>
    <th style="width: 15%">character</th>
    <th style="width: 65%">match</th>
    <th style="width: 20%">abbreviation of</th>
  </tr>
  <tr>
    <td>.</td>
    <td>any single character except newline<br/>(we can use m option to match the newline)</td>
    <td></td>
  </tr>
  <tr>
    <td>\d</td>
    <td>a digit</td>
    <td>[0-9]</td>
  </tr>
  <tr>
    <td>\D</td>
    <td>a non-digit</td>
    <td>[^0-9]</td>
  </tr>
  <tr>
    <td>\s</td>
    <td>a whitespace character</td>
    <td>[ \t\n\x0B\f\r]</td>
  </tr>
  <tr>
    <td>\S</td>
    <td>a non-whitespace character</td>
    <td>[^\s]</td>
  </tr>
  <tr>
    <td>\w</td>
    <td>a word character</td>
    <td>[a-zA-Z_0-9]</td>
  </tr>
  <tr>
    <td>\W</td>
    <td>a non-word character</td>
    <td>[^\w]</td>
  </tr>
</table>
When using in real Java code, except '.', we should double the 'escape' (\\) :

https://grokonez.com/java/java-regular-expression-overview-syntax

Java Regular Expression Overview – Syntax
ProductHunt page feedback
Tags: showdev, discuss
Published: 2021-04-27 14:49:40

Fellow devs, can I ask for feedback please?

I am hunting our live video podcast for community builders next week and I'd love your feedback on the copy and the art:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zoi1113ttf2o8ef0080e.png)

[I've build a draft using PreviewHunt](https://previewhunt.com/posts/the-communities-show---live-video-podcast)

Please bash the copy and the art so we have a chance to improve it:
* what was confusing about how it looks and feels? 
* what message did resonate with you? 
* anything that annoyed you?

Thanks!
How to Sort an Array in Java with Examples
Tags: java, sort
Published: 2021-04-27 14:46:44

https://grokonez.com/java/how-to-sort-an-array-in-java-tutorial-with-example

How to Sort an Array in Java with Examples

In the tutorial, we will discuss how to Sort an Array with Java in ascending and descending order. <code>java.util.Arrays</code> class provides a lot of Methods to sort an Array with difference types:
<ul>
<li>With Primitives Array, We use the method such as: <code>static void sort(int[] a)</code>.</li>
<li>With String or Objects Array that implement <code>Comparable</code>, We use method: <code>static void sort(Object[] a)</code>.</li>
<li>With Custom Object Array that no implement <code>Comparable</code>, We use method: <code>sort(T[] a, Comparator<? super T> c)</code>.</li>
</ul>
Let's do more details with Java Array Sorting.

<!--more-->

<h2>Sort with Primitives Java Array</h2>
We define a simple Int Java Array:

<pre><code class="language-java">
int[] numbers = new int[] { -9, 5, 4, 8, 11, -2, 2 };
</code></pre>
<h3>Sorting in Ascending Order</h3>
We use the method <code>static void sort(int[] a)</code> to sort the specified array into ascending numerical order.
- The method returns nothing
- The Sorting algorithm is a Dual-Pivot Quicksort
- This algorithm offers O(n log(n)) performance so it is typically faster than traditional (one-pivot) Quicksort implementations.

Practice:

<pre><code class="language-java">package com.grokonez.sortarray;

import java.util.Arrays;

public class JavaArraySortingExample {
	public static void main(String[] args) {
		int[] numbers = new int[] { -9, 5, 4, 8, 11, -2, 2 };
		
		// Sorting
		Arrays.sort(numbers);
		
		// Print Sorted-Array after Sorting
		for(int i=0; i&lt;numbers.length; i++) {
			System.out.println(numbers[i]);	
		}
	}
}</code></pre>

Output:

<pre><code class="language-java">
// Output
-9
-2
2
4
5
8
11
</code></pre>
<h3>Sorting in Descending Order</h3>
Java doesn’t support the use of Comparators on primitive types so sorting a primitive array in descending order is not easy.

More:

https://grokonez.com/java/how-to-sort-an-array-in-java-tutorial-with-example

How to Sort an Array in Java with Examples