teleren/devto huggingface dataset:
When your mysql image refuses to start on Kubernetes
Tags: kubernetes, gke, mysql, k8s
Published: 2019-02-07 00:20:12

---
title: When your mysql image refuses to start on Kubernetes
published: true
description: 
tags: #Kubernetes #GKE #mysql #k8s
---

One of the most common deployments of services in k8s has always been a simple mysql-service. You google and you find a thousand examples out there.

But recently I started experimenting with [debezium](https://debezium.io), and it requires a mysql with a custom `my.cnf` file in order to enable full binary logs.

First I deployed this service on my `minikube` with no issues at all:

```yaml
apiVersion: v1
kind: Service
metadata:
  name: mysql
spec:
  ports:
  - port: 3306
  clusterIP: None
  selector:
    app: mysql
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mysql-pvc
  labels:
    app: mysql
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 20Gi
---
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
  name: mysql
spec:
  selector:
    matchLabels:
      app: mysql
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: mysql
    spec:
      containers:
      - image: debezium/example-mysql:0.10      
        name: mysql
        env:
          # Use secret in real usage
        - name: MYSQL_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              name: mysql-pass
              key: password
        ports:
        - containerPort: 3306
          name: mysql
        volumeMounts:
        - name: mysql-persistent-storage
          mountPath: /var/lib/mysql
      volumes:
      - name: mysql-persistent-storage
        persistentVolumeClaim:
          claimName: mysql-pvc
```

But to my surprise, it would not start on GKE. Instead I would get this:

```
> [ERROR] --initialize specified but the data directory has files in it. Aborting.
```

What? Isn't Kubernetes meant to be the fabric on which we could easily port our workloads across different providers with no issues?

After a good amount of googling, it turns out that GKE Persistence Volume provider mounts the `/var/lib/mysql` volume with a **lost+found** directory that is not empty. That does not happen on minikube. And mysql does not like that (not when you are not running with default my.cnf at least).

So to fix this, you need to pass `--ignore-db-dir=lost+found` to the command line arguments of the container as in this snippet:

```yaml
spec:
      containers:
      - image: debezium/example-mysql:0.10
        args:
          - "--ignore-db-dir=lost+found"
        name: mysql
```

Since this took me a while to find, I thought it would be worth sharing for others that may bump into this.

Happy coding
How to do microservices?
Tags: help, microservices, laravel, webdev
Published: 2019-02-07 00:06:54

---
title: How to do microservices?
published: true
description: Doubt about how should I do microservices
tags: help, microservices, laravel, webdev
---

I have a lot of conceptual doubts about the microservices architecture and the implementation on an MVC framework, in this case Laravel.

Suppose that I have a Blog platform with the given ER Database.

![database structure](https://thepracticaldev.s3.amazonaws.com/i/yu8iizosm4uipr6apbsv.png)

And I want to change this system to become a microservices architecture. Based on what I been reading I could go with something like this:


![microservices architecture](https://thepracticaldev.s3.amazonaws.com/i/xbbxv0cap3tz5th1ynkn.png)


In this case each Microservice is a Laravel installation (or it can be Node.js, .net-core, etc).

Now my question comes on how to access each service, for example, suppose that Blog App is a Laravel application and a user enters into http://blog.test/1, so the user wants to see the post with the id 1.

How does the controller should behave?

For what I understand maybe the controller looks like this:

```php
<?php
namespace App\Http\Controllers;

use Illuminate\Routing\Controller as BaseController;
use Illuminate\Http\Request;

class BlogController extends BaseController
{
    public function show(Request $request, $id) {
        $client = new \GuzzleHttp\Client();

        // Get the blog information
        $blogResponse = $client->request('GET', "http://post-api.blog.test/api/blog/{$id}");
        $blogString = $blogResponse->getBody();
        $blog = json_decode($blogString);

        // Get the comments information
        $commentsResponse = $client->request('GET', "http://comments-api.blog.test/api/comments/{$id}");
        $commentsString = $commentsResponse->getBody();
        $comments = json_decode($commentsString);

        // Get the the author information
        $userResponse = $client->request('GET', "http://users-api.blog.test/api/user/{$blog['users_id']}");
        $userString = $userResponse->getBody();
        $user = json_decode($userString);

        return view('blog.show', ['blog' => $blog, 
            'comments' => $comments, 
            'author' => $user]);
    }
}
```

My questions are:

* Is this the correct way to implement it?
* I know I can cache some responses in order to access the resources faster but are Http APIs one way to implement it or there's another piece of technology I'm not seeing?

I know that probably you don't need to do microservices for a blog but just this is just an example as how to implement this paradigm.

Thanks!
VSCode No Reload Extension Install in Version 1.31
Tags: onedevminute, vscode
Published: 2019-02-06 22:41:53

---
title: "VSCode No Reload Extension Install in Version 1.31"
description: "VSCode v1.31 just released has an amazing new feature. Now you can install Visual Studio Code Extensions without having to reload your VSCode instance. This has been the most requested feature of VSCode. Reload is also not needed when you uninstall or disable an extension if it is not activated."
published: true
tags: OneDevMinute, VSCode
canonical_url: https://VSCode.pro/tip/21/
---

VSCode v1.31 just released has an amazing new feature. Now you can install Visual Studio Code Extensions without having to reload your VSCode instance. This has been the most requested feature of VSCode. Reload is also not needed when you uninstall or disable an extension if it is not activated.

{%youtube VS98ddZqLfM %}

> 📺 Watch a more detailed version on [YouTube →](https://Youtu.be/VS98ddZqLfM)

---

> #### Video Transcript
> 🎸 (MUSIC PLAYING) Howdy-do, folks — This is Ahmad Awais! 👋 Back with another #OneDevMinute Guess what just happened? About 10.5 minutes ago the Visual Studio Code team — has just released  The January update, version 1.31 of VS Code And it contains an amazing feature. I think it has been the most most requested feature… Now you can install extensions & do NOT have to reload VS Code at all How awesome is that. Let's dive in and see how it actually works You see I have this `.vue` file! It does NOT have a syntax coloring right now. So, I am going to install this very popular extension called "Vetur" — As you can see this Vetur extension is actually being installed — and as soon as it was installed you can see the Syntax Highlighting is now here! 💯 No need to reload VS Code whatsoever! Now this is a new feature. And it is going to be — you know— rough around the edges — but it is just amazing. So, this is new. Go ahead to this link and take a look at all of these new features. Especially the "No Reload on Extension Install"  and "Tree UI Improvements" — and if you're a VS Code Theme author you might want to add colors for `listFiletWidget` which enables you to explore this Tree View in a better way I have just pushed out a new update of 🦄 Shades of Purple theme so go ahead and install it. And if you want to learn about more Power User Workflows for VS Code — Go ahead and take a look at VSCode.pro — It's my VSCode power user course which is helping Over 4,000 developers become master Visual Studio Code users! So check out my VSCode.pro Power User Course! And I'll see you in the next one. Peace! ✌️


- 🐦 Twitter: https://twitter.com/MrAhmadAwais
- ✍️ Blog: https://AhmadAwais.com
- 😮 GitHub: https://github.com/AhmadAwais
- 🔗 LinkedIn: https://linkedin.com/in/MrAhmadAwais
- 🔗 YouTube: https://YouTube/AhmadAwais


> P.S. If you like my work, feel free to share it, like it. I teach at [VSCode.pro](https://VSCode.pro/) & I am quite active on twitter you can find me cracking silly jokes there, maybe [follow me on Twitter](https://twitter.com/MrAhmadAwais) to connect and [subscribe to my YouTube channel →](https://YouTube/AhmadAwais)

> Peace! ✌️
NPM Linking and Unlinking
Tags: npm, javascript, howto
Published: 2019-02-06 22:05:39

---
title: NPM Linking and Unlinking
published: true
description: How to avoid permissions issues with npm link and unlink when you are constantly switching context.
tags: npm, javascript, howto
---
 
At work, we have our own npm packages that we manage and maintain. As part of the dev process its crucial to test out the package in the context of a larger project to ensure it functions as expected and meets all our criteria. A handy trick that I've been using is linking local npm packages using `npm link`.  

However, as a result of having multiple tasks on the go on any given day, I kept getting myself into weird situations with permission issues where I would have the package not available anymore, which TBH was v annoying.  The result of constant branch switching and not cleaning up my local environment before doing so.

Here are the exact steps for both linking and unlinking so you can avoid the #struggle I went through.

Lets say we have an `npm` package that we are working on locally, lets call it `cowabunga`.  Our project structure looks something like this: 

![cowabunga package folder structure](https://thepracticaldev.s3.amazonaws.com/i/828lkf0znj2qu6e2w8uv.png)

And it’s `package.json` file looks something like this: 

{% gist https://gist.github.com/erin-bush/53e42a5e01ecf9e5edd95eddc819f657 %}

You’ll notice that this package has its own `node_modules` folder - this is where I kept getting tripped up.  I would switch branches in the repo where my package lives and the `node_modules` folder would disappear as a result of building other components that don't live in both branches.  When I would go to unlink, npm was throwing permissions errors that went something like this:

```
npm ERR! enoent ENOENT: no such file or directory, access ‘my_project/node_modules/cowabunga/node_modules/some-package’
```

In order to avoid this, you have to follow the linking/unlinking order otherwise npm will try to unlink folders that no longer exist.  Seems pretty basic but it was surprisingly tedious to figure out. 


### Linking:

First, in the _cowabunga_ folder (where package.json is):
```
npm link
```

Then in the project you want to include _cowabunga_ in:

```
npm link cowabunga
```


### Unlinking:

_Before_ switching branches and/or removing any node modules from the package itself (in my project, this includes running `learn clean` which removed the `node_modules` folders)

First, in the project: 
```
npm unlink --no-save cowabunga
```

Second, in the package:
```
npm unlink
```

Note: order is important!

Where I kept running into issues is switching branches and then the symlink couldn’t find the package anymore so you were stuck in this weird state where you couldn’t link anything or unlink anything because the folders don’t exist.  When this happens, check out your original branch and start from the beginning with linking the package and the project.  

 🤙

_Bonus:_
You can also run 
```
npm install -g i .
```
in your package folder to install it globally and avoid some of the linking mess 🎉
QuizNerd - A quiz app for developers
Tags: showdev
Published: 2019-02-02 21:09:48

---
title: QuizNerd - A quiz app for developers
published: true
description: 
tags: showdev
---
![](https://thepracticaldev.s3.amazonaws.com/i/nsgixkftwjr1a0extypl.png)

**Hi dev community! 🙋‍♂️**

I want to share with you an Android app that I created a few months ago in the context of the [Udacity Android Developer Nanodegree](https://muetsch.io/quiznerd-my-experiences-with-the-android-developer-nanodegree.html). 

## What is it?
QuizNerd is a multiplayer quiz game developed for programmers and IT enthusiasts. You can challenge your friends and compete in matches that consist of a large variety of different programming questions.

It comprises over 800 different questions in 9 categories, including Android, C++, C#, HTML, Java, JavaScript, PHP, Python and Swift. 

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

## How to play? 
You need to create an account by either using your e-mail address or your Google account. Once logged in, you can choose one of the above languages as a category and challenge either a random opponent or a friend, if you know her nickname.

## What technologies are inside?
It's a native Android app, written in Java. I did not use any architectural framework, but only plain Android APIs and a few common libraries like Apache Commons, [OkHttp 3](http://square.github.io/okhttp/), [Project Lombok](https://projectlombok.org/) (must-have for any Java project if you asked me) and the usual Android support libraries. As a backend it uses Google's [Firebase](https://firebase.google.com/) and the pixely, nerdy avatars are generated by a great open-source web service called [DiceBear](https://avatars.dicebear.com/).

## How to contribute?
* **Give feedback.** If you like my app, I'd love to have feedback from you! There is a long list of features to be added in the future and I'm always trying to improve QuizNerd. 
* **Add questions.** Currently, every category has between 50 and 150 questions. That's not a lot, so you will find that question are repeated sometimes. If you're a 🤓 and you have cool quiz questions for your language of choice, please feel free to submit them!

I'm also thinking of open-sourcing the app at some point, but I still need to clean it up a bit.
My first post
Tags: react, gatsby, graphql
Published: 2019-02-06 21:26:14

---
title: My first post
published: true
description: My first post
tags: Reactjs, GatsbyJs, Graphql
---

I currently work on several React/Gatsby projects.  At some point I may switch to NextJs, but I have spend a considerable amount of time on learning Gatsby and feel the need to keep building on that.  I like some of Gatsby's plugins like [gatsby-transformer-sharp](https://www.gatsbyjs.org/packages/gatsby-transformer-sharp/?=gatsby%20image%20shar#gatsby-transformer-sharp) for processing images and allow for some cool effects.  I also use Graphql extensively in my projects recently Gatsby has released a new StaticQuery API to allow components to access data.  Lastly, in one of my recent projects I have started to use markdown files for page data.  My goal is to create my own CMS template at some point that I can utilize for future projects.

I would appreciate any feedback on my [work](https://mirelescloud.com/).  Thank you in advance.


I'm generally not much of a writer/blogger - probably to my own detriment, but I hope to improve on that.
My Writings and Presentations on React Hooks
Tags: javascript, react, hooks
Published: 2019-02-06 20:21:59

---
title: My Writings and Presentations on React Hooks
published: true
description: A list of my articles, meetup talks and live presentations on react Hooks
tags: JavaScript, React, Hooks
---

Below is a compilation of all of the conference talks, articles, blogs and meetup presentations I have given on the subject of React Hooks. If you would like me to speak at your conference on the subject or on any other React topics, please contact me at @httpJunkie on Twitter or here on Dev.to

## Conference Talks

Dev Reach (Sofia Bulgaria) Nov 2018
[Getting Hooked on React](https://www.youtube.com/watch?v=MfAxhBMTkuQ&t=15s)
React Loop (Chicago, IL) June 2019
[State Management with React Hooks](https://www.youtube.com/watch?v=HuCWWvgizDg)


## Meetups

- Thursday, December 6, 2018: [React Hooks, Context API](https://www.meetup.com/Reactivate/events/255645712/)

- Thursday, January 10, 2019: [React Hooks deeper dive. useReducer()](https://www.meetup.com/Reactivate/events/256286135/)

## Blogs and Articles on Hooks


[Can I Use React Hooks Yet?](https://dev.to/httpjunkie/can-i-use-react-hooks-yet-35o9)
[How to Use Basic React Hooks for State and Effects](https://www.telerik.com/blogs/how-to-use-basic-react-hooks-for-state-and-effects)
[How to Use Basic React Hooks for Context](https://www.telerik.com/blogs/how-to-use-basic-react-hooks-for-context)
[How to Use Basic React Hooks for Reducers](https://www.telerik.com/blogs/how-to-use-basic-react-hooks-for-reducers)
[Custom Hooks](https://www.telerik.com/blogs/everything-you-need-to-create-a-custom-react-hook)
[KendoReact: Using Charts and React Hooks](https://www.telerik.com/blogs/kendoreact-using-charts-and-react-hooks)
[Links and Demos From My Talks](https://dev.to/httpjunkie/react-hooks-links-n95)
[Writing From a Beginners Perspective](https://dev.to/httpjunkie/writing-from-a-beginner-developers-perspective-30l0)


## Blogs and Articles on React/Other

[A React State of Mind](State of JavaScript Survey 2018)
[Creating a Responsive Layout in React](https://www.telerik.com/blogs/creating-a-responsive-layout-in-react)
[Let's Build a Sales Dashboard with React](https://www.telerik.com/blogs/lets-build-a-sales-dashboard-with-react)
[Hello, Create React App 2.0!](https://www.telerik.com/blogs/hello-create-react-app-2)
[Software Engineer to Developer Advocate](https://dev.to/httpjunkie/software-engineer-to-developer-advocate-4a8h)
[Get Lazy With React](https://www.telerik.com/blogs/get-lazy-with-react)
What's your goto motivational quote?
Tags: motivation, discuss
Published: 2019-02-06 20:11:48

---
title: What's your goto motivational quote?
published: true
description: What's your goto motivational quote?
tags: motivation, discuss 
cover_image: https://thepracticaldev.s3.amazonaws.com/i/f15ztdergm3q05vfxlme.png
---
Yesterday was one of those days... 

{% twitter 1093123943257567232 %}

By the end of the day I was stressed and crabby. Usually when this happens, I like to reach for a quote to help put things back into perspective. Yesterday I remembered this one that my cousin, who works in hospice, shared with me.

> When I'm stressed I try to remember something a patient much too young told me right before he died. He said that he missed being stressed and when I asked why, he stated "Being stressed means that you have a purpose. That you are needed and relied on."

Obviously, that straightened me out real quick. Another one of my favorite quotes, which is a little more light, is the one in the cover image! **What's your favorite goto quote when you need a pick me up?!**
Contributing to OSS
Tags: discuss, opensource, writing
Published: 2019-02-06 20:04:23

---
title: Contributing to OSS
published: true
description: How to motivate yourself to contribute?
tags: discuss, oss, writing
cover_image: https://thepracticaldev.s3.amazonaws.com/i/0j3src4qy60iu84aemv4.jpg
---



Hey guys out there! If you are like me you are using most of your time coding some bits of OSS. Have you ever thought about contributing to some of those nice frameworks, services and all this other cool stuff? Well I did, but I got to tell you I did not really achieve a lot.

I did some smaller pull requests on GitHub or tried to help to solve a issue with the investigation process. But that's it.

### Whats your approach to contribute to OSS

I would like to know the stories of you guys and girls out there how you tackle this subject, or if you even tackle it? Have you any trick to select a good project that's worth your time?

### How to improve my way to make a larger impact to the OSS world

Sooo, in future I want to sacrifice a hour every week to work on OSS, and try to report at dev.to about my progress, to have additional motivation to procrastinate this process anymore. This is about 0.5% of my time that should be doable.

### Annex

First I wanted to thank @marek for his article about writing more, which motivated to put myself out there.

{% link marek/three-arguments-for-why-you-should-write-more-1no6 %}

Second I want to thank dev.to that there editor is in markdown, since I use this language on daily bases to write documentation, it was really easy to adjust.

Image origin: https://pixabay.com/
react-schemaorg: Strongly-typed Schema.org JSON-LD for React
Tags: react, showdev, githunt, typescript
Published: 2019-02-06 19:37:20

---
title: react-schemaorg: Strongly-typed Schema.org JSON-LD for React
published: true
description: Strongly-typed Schema.org JSON-LD for React using TypeScript
tags: react, showdev, githunt, typescript
cover_image: https://thepracticaldev.s3.amazonaws.com/i/9qadxfy0n6f2wse7jlpq.png
---

I made this library (and the related, lower level [schema-dts](https://github.com/google/schema-dts)) after I was working inserting JSON-LD in a site and noticing a lack of TypeScript-y, developer-friendly way to do it. Most of the tooling to validate [Schema.org](https://Schema.org) JSON-LD is to use these online "validators", but that breaks (or lengthens) the development write-build-test loop.

{% github google/react-schemaorg %}

This library allows you to insert JSON-LD that is type-checked and offers completions, etc., just by taking advantage of TypeScript's type system. react-schemaorg is a simple wrapper around schema-dts, that inserts `<script type="application/ld+json">` tags and requires you to specify a top-level `"@context"`.
Using JWTs for GraphQL Authorization with Hasura
Tags: graphql, authorization, hasura
Published: 2019-02-06 19:09:58

---
title: Using JWTs for GraphQL Authorization with Hasura
published: true
description: Learn about the Hasura platform and how their GraphQL APIs can be secured using JSON Web Tokens
tags: #graphql #authorization #hasura
canonical_url: https://auth0.com/blog/using-jwts-for-graphql-authorization-with-hasura/
---

If you're developing an API today for consumption by third-parties, you'd be more than forgiven for choosing the REST interface to develop the API, as it is a tried and tested standard for delivering data to consumers, as well as accepting changes to the data in a structured way. In more recent times, GraphQL has become an attractive alternative for developing APIs thanks to its flexible, semantic, and performant nature.

[Read on 🎡](https://auth0.com/blog/using-jwts-for-graphql-authorization-with-hasura/?utm_source=dev&utm_medium=sc&utm_campaign=jwt_graphqlauth)

![Using JWTs for GraphQL Authorization with Hasura](https://thepracticaldev.s3.amazonaws.com/i/oori48fj4thfldir6x8n.png)