teleren/devto huggingface dataset:
Can a VPN be hacked?
Tags: vpn, security, hacking
Published: 2019-05-17 08:16:40

---
title: Can a VPN be hacked?
published: true
description: Can a VPN be hacked?
tags: vpn, security, hacking, 
---

With a Virtual Private Network (VPN) everyone – from a student or a housewife to a Silicon Valley entrepreneur – can take charge of their cybersecurity and make it harder for hackers to steal their sensitive information. But are you truly safe? Can a VPN be hacked?

Once your data leaves the VPN server to go to the website, it’s again out in the open if you visit websites with unsecure HTTP connection. Even though no one spoofing on the traffic will be able to tie that information back to you that doesn’t mean that you can visit suspicious sites without a worry.

You can read up more on the article about [VPN hacking](https://nordvpn.com/blog/can-vpn-be-hacked/).
How to control router access permissions in Golang web application
Tags: go, webdev, router
Published: 2019-05-17 07:38:51

---
title: How to control router access permissions in Golang web application
published: true
description: In this post I'm going to describe how can we limit user access to the specific url in golang web application.
cover_image: https://thepracticaldev.s3.amazonaws.com/i/yawem5p87p4epgz2oilj.jpeg
tags: golang,go,webdev,router
---

In this post I'm going to describe how can we limit user access to the specific url in golang web application. I will use [chi](https://github.com/go-chi/chi) router - a lightweight, idiomatic and composable router for building Go HTTP services.

Let's create our main package.

```go
package main

import (
	"net/http"
	"github.com/go-chi/chi"
)

func main() {
  r := chi.NewRouter()

  r.Get("/", homePageHandler)
  r.Get("/admin", adminPageHandler)
  http.ListenAndServe(":3000", r)
}

func homePageHandler(w http.ResponseWriter, r *http.Request) {
  w.Write([]byte("This is home page")) 
}

func adminPageHandler(w http.ResponseWriter, r *http.Request) {
  w.Write([]byte("This is admin page")) 
}
```

After this, if we go to the `/admin` page, we will see "This is admin page".


Now, let's make this path accessible only for admin.

We have to replace

`r.Get("/admin", adminPageHandler)`
With
`r.Mount("/admin", adminRouter())`

Mount attaches another http.Handler or chi Router as a subrouter along a routing path.

Then, we have to attach middleware inside adminRouter() function.
```go
func adminRouter() http.Handler {
    r := chi.NewRouter()
    // Middleware with access rules for router.
    r.Use(AdminOnly)
    r.Get("/", adminPageHandler)

    return r
}
```

In this middleware we have a simple check is user authorized to access this page or not.

```go
func AdminOnly(next http.Handler) http.Handler {
    return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
        // If user is admin, allows access.
        if IsLoggedInAdmin(r) {
            next.ServeHTTP(w, r)
        } else {
            // Otherwise, 403.
            http.Error(w, http.StatusText(403), 403)
            return
        }

        return
    })
}
```

In sake of demonstration, I'm going just to use a random bool function to decide is used admin or not. You can modify this function according to your user authentication model.

```go
func IsLoggedInAdmin(r *http.Request) bool {
    return rand.Float32() < 0.5
}
```
And that's it. Looks really simple, Isn't it?

Let's go to to the `/admin` page again.

As you see, now, sometimes (depends on our random decider), user has no access to this page anymore.



You can find source code [here](https://github.com/alexsergivan/blog-examples/blob/master/route-auth/main.go)
EP15: Learning to Build Mobile Applications for Android
Published: 2019-07-15 11:40:40

---
title: EP15: Learning to Build Mobile Applications for Android
published: true
tags: 
canonical_url: https://anchor.fm/code-cast-zm/episodes/EP15-Learning-to-Build-Mobile-Applications-for-Android-e421si
---

On this episode, we welcome Android developer and lover of all things Java,[<u><strong>Dennis</strong></u>](https://twitter.com/Iambigd50). Cynthia is back from Facebooks' F8 event with an interesting on update on the announcements made at the conference.

We take a look at Googles new devices, the Pixel 3A & Pixel 3A XL, their new additions to Google Assistant as well as the biggest announcement for most android developers regarding Kotlin.

We discuss the differences between[<u><strong>Kotlin</strong></u>](https://kotlinlang.org/) and[<u><strong>Java</strong></u>](https://www.oracle.com/technetwork/java/javase/downloads/index.html) as primary languages for building applications for mobile devices. With so many comparisons on the inter-web it's easy to get lost in getting started.

We also draw comparisons between Native,[<u><strong>Hybrid App</strong></u>](https://www.sitepoint.com/native-vs-hybrid-app-development/) development and [<u>Progressive Web Apps</u>](https://developers.google.com/web/progressive-web-apps/) which have gotten popular for a few years now. However, it remains to be seen if this changes 

Starting out as an [<u>Android </u>](https://www.android.com/)developer requires understanding key concepts around best practices and we delve into some of these best practices to give you the best jump start.

This is a special episode for the team, it's been a year since CodeCast began so Happy Anniversary to us.

**Links and Info:**

- Dennis Mubamba: [<u>Twitter</u>](https://twitter.com/Iambigd50)
- React Native for Windows: [<u>Github Repo</u>](https://github.com/microsoft/react-native-windows)
- Google IO 19’ [<u>Conference</u>](https://events.google.com/io/) 
- Facebook's F8 19’ [<u>Conference</u>](https://www.f8.com/)
- Microsoft Build 19’ [<u>Conference</u>](https://www.microsoft.com/en-us/build)
- [<u>Phonegap</u>](https://phonegap.com/)
- [<u>Cordova</u>](https://cordova.apache.org/)
- [<u>Kotlin</u>](https://kotlinlang.org/)
- [<u>Xamarin</u>](https://docs.microsoft.com/en-us/xamarin/cross-platform/get-started/)
- [<u>Google App Maker</u>](https://developers.google.com/appmaker/)
- [<u>Progressive Web App</u>](https://developers.google.com/web/progressive-web-apps/)

Leave us a review on[<u><strong>iTunes</strong></u>](https://podcasts.apple.com/us/podcast/codecast-zambia/id1442693166?mt=2) to let us know what you think about the show.

 Send in a voice message:[https://anchor.fm/code-cast-zm/message](https://anchor.fm/code-cast-zm/message)
Don't omit __init__.py
Tags: python
Published: 2019-05-17 05:50:54

---
title: Don't omit __init__.py
published: true
description: "Python 3 doesn't require __init__.py" is common misunderstanding
tags: Python
---

I saw some people think Python 3 allow package without `__init__.py` on Stackoverflow or mailing lists.

This is misunderstanding.  Package directory without `__init__.py` is "namespace package", not a regular package.  See [PEP 420](https://www.python.org/dev/peps/pep-0420/) for reference.

Namespace package is special package for people creating complex "distribution package" ("package" which can be registered on PyPI).  There is [guide for namespace package](https://packaging.python.org/guides/packaging-namespace-packages/) in "Python Packaging User guide".

There are some difference between namespace package and regular package.

For example, `unittest` module in standard library doesn't search into directory without `__init__.py`.  If they do, they may take dozen seconds to search tests in `node_modules` which contains millions of files and subdirectories.

You should not omit `__init__.py` in your project unless you are 100% sure about what "namespace package" is.  Use "regular package" with `__init__.py` instead.
Oculus Goで外部マイクを使う
Tags: oculusgo
Published: 2019-05-17 04:23:00

---
title: Oculus Goで外部マイクを使う
published: true
tags: OculusGo
date: 20190517T04:23Z
canonical_url: https://qiita.com/shiena/items/bbd7cc741cad74c7c95b
---
# はじめに

Oculus Goはマイクが内蔵されているのですがマイク端子がないので外部マイクを使えないように見えます。
そこにUSBオーディオ変換アダプタを使うと外部マイクを使うことができたので構成を紹介します。

# 用意するもの

* USB OTGケーブル
* マイク端子があるUSBオーディオ変換アダプタ
* 3.5mmプラグのヘッドホン
* 3.5mmプラグのマイク

動作確認できたケーブルとアダプタは以下の製品です。

* https://www.amazon.co.jp/dp/B00NF8MF3E/
* https://www.amazon.co.jp/dp/B074WZC6B4/

# つなぎ方

説明するまでもないと思いますが次のようにつなぎます。
USBオーディオが認識されると組み込みスピーカーから音が出なくなりUSBオーディオ変換アダプタかヘッドホンジャックにつないだヘッドホンから音が出ます。

Oculus GoのUSB端子
↓
USB OTGケーブル
↓
USBオーディオ変換アダプタ
↓
マイク

ヘッドホンはUSBオーディオ変換アダプタとOculus Goのヘッドホンジャックのどちらからも音が出ました。

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

# 応用

外部マイクを使えるという事はPCのサウンド出力とマイク端子をつないでボイスチェンジできます。実際にやってみるとケーブルだらけで動きにくかったりUSBオーディオのせいでバッテリー消費が早くなったりするので事前準備が大事です。

外部マイクを使う時は[HTML 5 Microphone Visualizer](https://static.yige.ch/html5-mic/)が音量チェックしやすそうです。
Search box v.2
Tags: codepen, ui, webdev, design
Published: 2019-05-17 05:49:14

---
title: Search box v.2
published: true
tags: codepen, ui, webdev, design
---

<p>This is just an example of microinteractions for search bar.</p>

<p>While I'm learning the concept of microinteractions, I tried to make a search box.</p>

<p>This is the second version of 'Search Box' that I made before. I used 'cubic-bezier' attribute at the transition, to have that "Bouncy" effect during the transition.</p>

{% codepen https://codepen.io/takaneichinose/pen/ErGwPZ %}

<p>Below is my first version of 'search box'</p>

{% codepen https://codepen.io/takaneichinose/pen/gKVXXL %}

<p>Thank you for your time, I hope you like it.</p>
Tipos de componentes en React Js ⚛️
Tags: react, javascript
Published: 2019-05-17 05:41:30

---
title: Tipos de componentes en React Js ⚛️
published: true
description: Describimos los tipos de componentes que podemos utilizar en React Js.
tags: ReactJs, JavaScript
cover_image: https://thepracticaldev.s3.amazonaws.com/i/xnnrd5escg70996ewowk.png
series: React Js Series
---
 
#Hola Coders 👋!

Este Post esta dedicado a **ReactJs**, describiremos los tipos de componentes que podemos utilizar en **React**, tenemos dos tipos de componentes, los componentes de clase y los componentes funcionales, que pueden tener otros nombres ya que cada uno de ellos tiene sus propias características. 

Class components: Tienen un estado o State y pueden ser llamados también **Statefull Components**, estos componentes tienen siempre un método **render()** y otra cosa muy importante en estos componentes existen ciclos de vida, de los cuales hablaremos en otro post.

Functional components: No tienen un estado o State, que pueden ser llamados tambien **Stateless Components** simplemente son funciones puras y no tienen un método **render()** a diferencia del anterior.

####vamos a ver un ejemplo de cada uno 😉

#####Componente de clase o Statefull Component👇

![Component de clase](https://thepracticaldev.s3.amazonaws.com/i/15z9b0gn9t39yxgcvctl.png)

Podemos ver que hereda de Component, tiene un método Constructor y un State y como lo mencione anteriormente tiene un método render.

#####Componente funcional o Stateless Component👇

![Component de clase](https://thepracticaldev.s3.amazonaws.com/i/qzciqwctg0ljozyu9wc4.png)

En este componente podemos ver que no tiene un **State**, tampoco un método render y mucho menos un método constructor solo retorna un template.


Tal vez te encuentres un poco confundido y te preguntes cuando usar cada uno de estos componentes, es muy sencillo primero vamos a nombrarlos diferente.

####Smart Components o Componentes Inteligentes.

Estos componentes son los Componentes de clase, y en estos tenemos toda nuestra lógica específicamente para ese componente por ejemplo en ellos podemos consumir una **API** y posteriormente, los datos que obtuvimos de esa **API** los pasamos vía **props** a nuestro componente funcional para mostrarlo al usuario 🤭.

####Componentes Tontos o Silly Components.

Estos componentes son los Componentes funcionales, y solo se encargan de mostrar datos, que previamente recibieron de un **Smart Component**, cabe resaltar que estos componentes no saben ni se enteran de nada de lo que pasa en la app, solo se encargan de mostrar templates.

En realidad es muy sencillo aprender sobre los tipos de componentes en React Js les dejo un vídeo para que lo entiendan mejor. 

{% youtube Nh2He5m_Eps %}

Espero este Post les haya servido y hayan resuelto sus dudas nos vemos pronto 😉
Fixing Issue When You Can't Connect to Docker Debugger in VS Code
Tags: docker, dotnet, vscode, debugging
Published: 2019-05-17 06:47:15

---
title: Fixing Issue When You Can't Connect to Docker Debugger in VS Code
published: true
tags: docker,dotnet,vscode,debugging
canonical_url: https://www.aaron-powell.com/posts/2019-05-17-fixing-cant-connect-to-docker-debugger/
---

I’ve [previously blogged about debugging .NET Docker containers in VS Code](https://dev.to/azure/debugging-your-net-core-in-docker-applications-with-vs-code-3g5d) but recently I came across a problem with a container that I had a .NET Core application in failing to connect the debugger with the following error:

```
Executing: docker.exe exec -i sunshine-functions sh -s < /home/aaron/.vscode-remote/extensions/ms-vscode.csharp-1.19.1/scripts/remoteProcessPickerScript
Linux
stderr: sh: 1: ps: not found
Error Message: Command failed: docker.exe exec -i sunshine-functions sh -s < /home/aaron/.vscode-remote/extensions/ms-vscode.csharp-1.19.1/scripts/remoteProcessPickerScript
sh: 1: ps: not found

```

THe crux of the problem is that it’s unable to list the processes that I need to pick from in VS Code.

The image I was using as my base image was the [Azure Functions Host](https://hub.docker.com/_/microsoft-azure-functions-base), specifically `mcr.microsoft.com/azure-functions/dotnet` and it turns out that this particular image doesn’t have [`ps`](http://man7.org/linux/man-pages/man1/ps.1.html) anywhere in it!

Thankfully, this is an easy fix, you need to install `procps` using `apt install`, assuming your image is from a distro that supports `apt` of course. 😉

Once `ps` is installed into your image you’ll now be able to list the processes and then debug your image.
Repeatable Test Step Fallacy
Tags: testing
Published: 2019-05-17 04:15:36

If you're a test professional you're often more then just a tester. You're given a pile of functionality and expected to verify it functions, detail out how it functions and do it again with the next piece of functionality along with doings it for the new functionality.

Recently I was asked to produce repeatable test steps as evidence of testing. We are in a position where we could have third party audits and this person has placed themselves as the final gate to say the product is ready to be released. (this is not intended to jab at the benefits of this person's skills or contributions, only to clarify the request is reasonable) this person has no involvement with the product, including defining or knowing what functionality exists.

Rapid Software Testing describes a targeted testing session where the tester will take notes for themselves, the tester can review their sessions with a senior tester to help find gaps and exchange knowledge. These notes are intended as personal, used by their creator, not as repeatable test steps.

If you're in the agile space you're probably thinking, there are no testers, and we have detailed behavior through acceptance criteria. But acceptance criteria aren't the test steps. 

When a bug is identified, working on a minimal reproduction step list is critical to having timely resolution and even insight into severity. This is not where this fallacy lies.

The idea that by defining repeatable test steps on new functionality you will have:

* Full coverage to catch defects
* Time to execute everything for each release 
* Have more than one release a year 
* documentation to hand off for another tester to pick up 
* An understanding of what was tested

I don't think you get this, especially if you want more than one. Leaving bread crumbs about the testing is useful. There is also a time to cover the test effort in more detail. I recommend focus first

* How are found issues handled
* What issues might crop up that are similar or are hiding 
* Understand the issue (root cause, not accusations)  
* determine your risk tolerance
* can you reproduce closer to time of development
* could the issue be found in a different manner
Boring Flutter Project
Tags: flutter, widget
Published: 2019-05-17 03:57:50

---
title: Boring Flutter Project
published: true
description: A collection of classic UI widget for Flutter.
tags: flutter, widget
---

Spent something to create this not-that-useful but fun project.
Here is the repo.

https://github.com/xieweizhi/flutter_classic_kit


## Screenshots

![screen shot 01](https://github.com/xieweizhi/flutter_classic_kit/raw/master/screen_shots/Simulator%20Screen%20Shot%20-%20iPhone%20X%CA%80%2012.2%20-%202019-05-17%20at%2008.27.08.png)

![screen shot 02](https://github.com/xieweizhi/flutter_classic_kit/raw/master/screen_shots/Simulator%20Screen%20Shot%20-%20iPhone%20X%CA%80%2012.2%20-%202019-05-17%20at%2008.26.28.png)
How do you cope with a problem that you can't solve?
Published: 2019-05-17 03:33:34

Hi everyone,

I've been lucky enough to get a full-stack web development position in my hometown (read: not a big city) and am approaching my 1st year marker. It's a great fit for my skillset and I love everything about the people and the work.

Today we deployed a semi-hefty feature release after doing our tests and QA, and everything was going swimmingly. Untill a few hours later when the calls starting coming in ... Fast.

This release consisted of a lot of work that I had been doing, and included some major refactoring of some legacy processes, but QA passed it and I had hands on experience in our staging environment to suggest green lights across the board, but wouldn't you know it, as I'm packing up to leave (about 3 hours post release, for context) a CX rep, measured panic in her eyes, lets me know something in the past half hour has gone terribly wrong. A major point of our flow is broken, and I'm the only dev left in the office.

I unpack and dig in to try to determine the issue. I mean, no forks or knives here, more like hands and feet, My thinking was that logic would dictate that a major issue would correlate to a major change, so I took ownership over the problem since the release earlier was mostly my doing. And I troubleshoot, and hotfix, and troubleshoot, and hotfix some more, but to no avail. Everything about my work seems to be pointing to 'it should work.'

Fast forward to about 4 hours after I had originally tried to pack up, the office is completely empty, and I'm no closer to solving the problem. I rollback the release in a desparate attempt to undo whatever happened, but the issue remains. I gained some valuable insight at that moment that I'm still wrestling with, which is that the issue might not have been my fault it may be somewhere else on the stack that I'm not involved in. Moreover, I feel like the blame game is a toxic sentiment, but I digress.

I had to leave any further investigation because I was exhausted and starving, and (insult to injury) have an operation the following day. But I feel so uneasy and worried about leaving a major loose end, despite knowing it's not something I could easily solve considering I might not actually know the circumstances around the root of the problem. But I also can't shake that feeling of responsibility over it.

To be honest, I feel jeopardized by the whole scenario.

So I want to know, all you dedicated problem solvers out there, what tips can you give someone to walk away from a mission critical problem when the solution seems completely out of your grasp and, to make matters worse, you physically can't be involved in it's solution?
Seven segment display
Tags: javascript
Published: 2019-05-17 02:53:00

# Intro

Learn what it takes to create a classic seven segment display to display the current time in style.

# What do you need?

To run the code in this article you don’t need to install anything on your local computer.

Just open the online JavaScript playground from [codeguppy.com/code.html](https://codeguppy.com/code.html) and copy and paste the following code in the integrated editor.

When ready, press the “Play” button to run the code.

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


# Source code

```
function loop()
{
    clear();

    display();
    displayInfo();
}

function display()
{
    var d = new Date();
    var hour = d.getHours();
    var min = d.getMinutes();
    var sec = d.getSeconds();

    drawNo(hour, 2, 106, 250, 50);
    drawNo(min, 2, 106 * 2 + 125, 250, 50);
    drawNo(sec, 2, 106 * 3 + 125 * 2, 250, 50);
}

function displayInfo()
{
    fill(0);
    noStroke();
    
    textAlign(CENTER, CENTER);
    text("Current time displayed using 7 segment LED displays", width / 2, height - 10);
}

function drawNo(no, digits, x, y, w)
{
    // no  gfedcba Hex
    // ---------------
    // 0   0111111 3F
    // 1   0000110 06
    // 2   1011011 5B
    // 3   1001111 4F
    // 4   1100110 66
    // 5   1101101 6D
    // 6   1111101 7D
    // 7   0000111 07
    // 8   1111111 7F
    // 9   1101111 6F
    
    var numbers = [0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F];

    var txt = no.toString();
    txt = padNumber(txt, digits);
    
    for(var i = 0; i < txt.length; i++)
    {
        var chr = txt[i];
        no = int(chr);
        
        drawBinNo(numbers[no], x + i * (w + w / 2), y, w);    
    }
}

function drawBinNo(no, x, y, w)
{
    var bin = no.toString(2);
    bin = padNumber(bin, 8);

    push();
    strokeWeight(20);
    stroke("Red");
    
    drawHorizontal(x, y, w, bin[7]);         // a
    drawVertical(x + w, y, w, bin[6]);       // b
    drawVertical(x + w, y + w, w, bin[5]);   // c
    drawHorizontal(x, y + 2 * w, w, bin[4]); // d
    drawVertical(x, y + w, w, bin[3]);       // e
    drawVertical(x, y, w, bin[2]);           // f
    drawHorizontal(x, y + w, w, bin[1]);     // g
    pop();
}

function drawVertical(x, y, w, state)
{
    if (state === '1')
        line(x, y, x, y + w);
}

function drawHorizontal(x, y, w, state)
{
    if (state === '1')
        line(x, y, x + w, y);
}

// Pad a string with zeros on the left until reaches the specified length
function padNumber(txt, len)
{
    while(txt.length < len)
        txt = "0" + txt;
        
    return txt;
}


```

# Feedback

If you liked the article, please follow [@codeguppy](https://twitter.com/codeguppy) on Twitter and / or visit [codeguppy.com](https://codeguppy.com) for more tutorials and projects.

Also, if you want to extend this article with detailed instructions explaing how to build the program step by step, please leave feedback in the comments.