teleren/devto huggingface dataset:
ELI5: Database Normalization?
Tags: explainlikeimfive, database, design, beginners
Published: 2019-12-07 13:43:46

Dear fellow devs 👋🏻,

🤓 I just started learning about databases, took the [mode SQL tutorial](https://mode.com/sql-tutorial/) and am taking a [course on Fullstack Web Development](https://www.udacity.com/course/full-stack-web-developer-nanodegree--nd0044).

👩🏻‍🎓 At some point, I will take a deep dive into [database design](https://www.udacity.com/course/database-systems-concepts-design--ud150), but for now, can you help me get a general idea of database normalization? 

🤔What does it mean when a table is in first, second, or third normal form (1NF, 2NF, 3NF)?

Thanks,
Kat 🐱🐾
[A RESTful API BUILT IN NODEJS USING JUST NATIVE MODULES - NO NPM HERE!]
Tags: node, opensource, javascript
Published: 2019-12-07 12:59:51

Hey, people!

Well, I've been using express for routing and mongoose/sequelize to connect my server with my database for a while, and just wanted to try to build my own router and my own database-connector and use them to build a RESTful API using just native modules. :man-shrugging::skin-tone-5:
In this project, I implemented (and much more):

> Instant updates on the sever when some file is edited (as nodemon does).
> Routing using the Middleware pattern (as express does).
> Schema definition to define the data structures used to define the API entities.
> Validate the data before save or update using the pre-defined Schema.

Ok, now you're maybe thinking: "What? We already have some libs that someone else created that helps us to do it all (as express and mongoose and mongoose/sequelize that I mentioned)! Why re-invent the wheel"?

And I'll answer you: And I answer you: I know we don't always have time to implement our own ideas to solve certain problems that we face in our daily lives as engineers who use programming to create solutions, but I really want to encourage you, whenever possible, to try to build your own solutions and codify your ideas for these problems, this will make you a much more independent developer and of course much more confident in using a programming language. Apart from the fact that of course this experience will make you expand your knowledge
and make you feel amazing while implementing each feature (as I'm feeling now)!

PS: Treat this project as a personal challenge that I set myself, so there is no intention of running this API in production. Therefore,
This project is not a perfect solution and certainly not better than the ones that already exist in the market, but I want to share this knowledge I learned and implemented with the community so that everyone can benefit from what I did!

Without further ado, here's the repo!

https://github.com/steniowagner/restful-npmless-api
Numbers that every computer engineer should know, according to Jeff Dean
Tags: computerscience
Published: 2019-12-07 12:59:40

L1 cache reference: 0.5 ns
Branch mispredict: 5 ns
L2 cache reference: 7 ns
Mutex lock/unlock: 100 ns
Main memory reference: 100 ns
Compress 1K bytes with Zippy: 10,000 ns
Send 2K bytes over 1 Gbps network: 20,000 ns
Read 1 MB sequentially from memory: 250,000 ns
Round trip within same datacenter: 500,000 ns
Disk seek: 10,000,000 ns
Read 1 MB sequentially from network: 10,000,000 ns
Read 1 MB sequentially from disk: 30,000,000 ns
Send packet CA->Netherlands->CA: 150,000,000 ns

(1 ns = 1 * 10^-9 s)

These numbers have been updated by others : 
https://colin-scott.github.io/blog/2012/12/24/latency-trends/
Cool Rust and WebAssembly Resource
Tags: rust, webassembly
Published: 2019-12-07 13:06:55

---
title: Cool Rust and WebAssembly Resource
published: true
date: 2019-12-07 12:56:29 UTC
tags: rust, WASM
canonical_url: https://www.iamdeveloper.com/posts/cool-rust-and-webassembly-resource-33j6/
cover_image: https://thepracticaldev.s3.amazonaws.com/i/rawwnuemdznz7320zmkp.jpg
---

I still haven’t really dug into [Rust](https://www.rust-lang.org) and [WebAssembly](https://webassembly.org) (WASM) yet, but this project looks really cool.

{%twitter 1202898165420249089 %}

It looks like a really great way to learn Rust and WASM. 👏

Photo by [takis politis](https://unsplash.com/@citylop?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) on [Unsplash](https://unsplash.com/?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText)
State machine advent: Statically type state machines with TypeScript (7/24)
Tags: typescript, javascript, react
Published: 2019-12-07 12:02:10

In the last couple of days, we've seen how to [define](https://dev.to/codingdive/state-machine-advent-baby-s-first-state-machine-with-xstate-3-24-3b62) and [invoke](https://dev.to/codingdive/state-machine-advent-invoking-a-state-machine-in-react-1nm7) a state machine in React. Above all, for our application to work correctly, we must define our state machines flawlessly. 

As state architecture grows, refactoring state nodes by adding new ones or moving them around will get increasingly difficult within the JSON machine definition.  
By strictly typing state machines, we can ensure that the machine includes all the state nodes and events that we have defined in TypeScript.

The first thing we do is to define our state schema and all possible events.

```typescript
interface LightSwitchStateSchema {
  states: {
    inactive: {};
    active: {};
  };
}

type LightSwitchEvent = { type: 'TOGGLE' };
```

After having defined our state schema and event type, we can pass the types to the `Machine` function when creating our machine in XState. Do not worry about the first type argument `any` for now as we'll cover it in detail in a few days from now.

```typescript
const lightSwitchMachine = Machine<any, LightSwitchStateSchema, LightSwitchEvent> ({
  id: 'lightSwitch',
  initial: 'inactive',
  states: {
    inactive: {
      on: {
        TOGGLE: 'active'
      }
    },
    active: {
      on: {
        TOGGLE: 'inactive'
      }
    },
  }
});
``` 

Whenever we forget to define a state node or move it into an invalid position within our JSON, TypeScript will now rightfully scream at us. 🎉

If we had two distinct events instead of reusing our toggle event, our event type could look like this. 

```typescript
type LightSwitchEvent =
  | { type: 'ACTIVATE' }
  | { type: 'DEACTIVATE' };
```

Using TypeScript with state machines can reduce so many bugs in our apps. As a result, when we introduce more complex machines in the series, I'll make sure to always include how to type them as well. 

Tomorrow we'll take a critical look at state machines and the one problem they can't solve on their own.

### About this series
Throughout the first 24 days of December, I'll publish a small blog post each day teaching you about the ins and outs of state machines and statecharts.

The first couple of days will be spent on the fundamentals before we'll progress to more advanced concepts.
Simple Dark Theme Switch with Vue.JS
Tags: vue, beginners, webdev
Published: 2019-12-07 11:15:11

---
title: Simple Dark Theme Switch with Vue.JS 
published: true
description: How to add a simple dark theme switch to your Vue.JS application.
tags: vuejs, beginner, webdev
---

Hello, 

In this post I'm going to show you how quickly you can add a dark theme switch to your Vue.JS application.

We're going to start with a blank application. And then we're going to create a dark-theme CSS file which we're going to save in `public/css/darktheme.css`.

This is how the application looks without any CSS.

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

Now, we're going to put the following code in `darktheme.css`:

```css
body {
    background-color: #2c3e50;
}

h1,h2,h3,h4,h5,h6,p {
    color: #42b983;
}
```

We can test our theme by appending the following line in the `<head>` of `public/index.html`

```html
    <link rel="stylesheet" href="<%= BASE_URL %>css/darktheme.css">
```

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

Now let's make this interactive!

In `src/App.vue` we'll add a button and the following methods:

```html
    <button @click="darkThemeSwitch">Switch Theme</button>
```

```javascript
  methods: {
    _addDarkTheme() {
      let darkThemeLinkEl = document.createElement("link");
      darkThemeLinkEl.setAttribute("rel", "stylesheet");
      darkThemeLinkEl.setAttribute("href", "/css/darktheme.css");
      darkThemeLinkEl.setAttribute("id", "dark-theme-style");

      let docHead = document.querySelector("head");
      docHead.append(darkThemeLinkEl);
    },
    _removeDarkTheme() {
      let darkThemeLinkEl = document.querySelector("#dark-theme-style");
      let parentNode = darkThemeLinkEl.parentNode;
      parentNode.removeChild(darkThemeLinkEl);
    },
    darkThemeSwitch() {
      let darkThemeLinkEl = document.querySelector("#dark-theme-style");
      if (!darkThemeLinkEl) {
        this._addDarkTheme()
      } else {
        this._removeDarkTheme()
      }
    }
```

Whenever we click on the `Switch Theme` button, the dark theme should switch back and forth.

This is a quick and dirty way to add a dark theme switch to your Vue.JS application. You can can also take this further by implementing a theme service and persistence support.

Thank you for reading!
Why asking why?
Tags: documentation, rephrasing, talks
Published: 2019-12-07 11:59:58

Did you find yourself reading a documentation or listening to talk and it starts with: 

> Why you need X?

After that headline they usually start listing some facts that are totally  based on something else but justifies why you *should* need X based on some vague examples. ~~So why is this a problem?~~

At first this will convince you because these problems sound familiar to you. You are glad to hear that there finally is a solution. Allegedly there is. But to be honest you bought that argument just because you did not really think about those problems at all. Basically you were sold at the word "need". This tricks our brain in thinking: "Oh my god, you are right I really need this".

Let's rephrase this why question. 

> X is solving following problems.

This will force you to think about those arguments and lets you decide more rational if you really need X. 

So my matter of concern is following. If you are a developer writing documentation and used this kind of question unintentionally, rephrase those statements to be fair to the reader.
Looking for scripting language
Tags: discuss, devops, productivity
Published: 2019-12-07 11:58:33

Hi!

_My first post / question in here so all pointers regarding to creating posts are welcome too._

I've been on the lookout for good language to learn for scripting and automating things. Mostly setting up servers, automating some helpdesk tasks (might include dealing with Excel), generating pdf files, moving files and folders across servers etc.

Requirements are: 
- Compiles to single file binary for easy share for non tech savvy people
- Easy cross platform building because not everyone is on Linux (sadly)
- Be productive, ain't nobody got no time to write some automation script for 2 months

Can someone point at some language / framework to use and learn with little bit more explanation than: "Python, it's best for everything"
How to set up HTTPS with Istio and Kubernetes on GKE
Tags: kubernetes, istio, gcp
Published: 2019-12-07 10:01:53

---
title: How to set up HTTPS with Istio and Kubernetes on GKE
published: true
description: You would typically use annotations on Kubernetes ingress to set up HTTPS and static IP with GKE. Istio set up its own ingress load balancer which is of type ‘Service’ but GKE is not compatible with annotations of that type.
canonical_url: https://www.padok.fr/en/blog/https-istio-kubernetes
tags: Kubernetes, Istio, GCP
---
You would typically use annotations on Kubernetes ingress to set up HTTPS and static IP with GKE. Istio set up its own ingress load balancer which is of type ‘Service’ but GKE is not compatible with annotations of that type.
If you are not familiar with Kubernetes you can check out this article : https://www.padok.fr/en/blog/kubernetes-essentials-components-pods-services or if you want to live test this article setup your own Kubernetes cluster on GKE by following this article : https://www.padok.fr/en/blog/kubernetes-google-cloud-terraform-cluster

Cert-Manager with Kubernetes and GCP
You can use cert-manager with Kubernetes to set up HTTPS, the process is fairly straightforward. We’ll go through setting it up.
Setup Istio to work with cert-manager
````
istioctl manifest apply \
  --set values.gateways.istio-ingressgateway.sds.enabled=true \
  --set values.global.k8sIngress.enabled=true \
  --set values.global.k8sIngress.enableHttps=true \
  --set values.global.k8sIngress.gatewayName=ingressgateway
```
Setup certificate, make sure to set all env variables
```
cat <<EOF | kubectl apply -f -
apiVersion: certmanager.k8s.io/v1alpha1
kind: Certificate
metadata:
  name: ingress-cert
  namespace: istio-system
spec:
  secretName: ingress-cert
  issuerRef:
    name: letsencrypt-staging
    kind: ClusterIssuer
  commonName: $INGRESS_DOMAIN
  dnsNames:
  - $INGRESS_DOMAIN
  acme:
    config:
    - http01:
        ingressClass: istio
      domains:
      - $INGRESS_DOMAIN
---
EOF
```
Done!

If you require a production level certificate you can change the issuerRef name to `letsencrypt` instead of `letsencrypt-staging`
For more details on this setup you can go see their official documentation: https://istio.io/docs/tasks/traffic-management/ingress/ingress-certmgr/
And cert-manager documentation: https://docs.cert-manager.io/en/latest/


The rest of the article is avaible here : https://www.padok.fr/en/blog/https-istio-kubernetes
What are the cons of GraphQL?
Tags: discuss, help
Published: 2019-12-07 09:39:52

I bet everyone here has heard about, used and loved GraphQL over REST API. I also know the reasons why GraphQL is better than REST API.

**BUT**

_Everything comes with drawbacks._

Even today, not all new startups and apps use GraphQL in their backend. 

---

What could be the reason?

What is the biggest hurdle you face when you learn/work with GraphQL? 

And what are the solutions to it?

What are the CONS of GraphQL?

---

I am asking just for the sake of knowing why some people might not like GraphQL. 

I ❤️ GraphQL.

**#devDiscuss**
Online Printing Shop
Tags: help, productivity
Published: 2019-12-07 09:38:44

Hi Dev, call me Gho..

I have plan to provide some services for people who needs printer/coppier locally in my village. To do this, I need to customize and develop a system or application first. It should be an online/offline system/app that used by me as the owner, by admin, by partner and by client both in desktop or mobile.

This topic is really new for me. I don't know what I should to do first, and also never have to know about where I should researching or learning and getting useful informations for everything I need in this project. Especially about:

~ How could we override the default settings of hardware? (in this case is printer/copier).
~ I was wondering that I can get the full access and control of my printer/copier devices. So I can customize the program that will be useful as I want.

I really need your help and also appreciated every answers from Dev. Well, I also hope I wasn't have any violations of ethics for this post. At least, big thanks for your time to reading and replying. 

Best regards ~Gho
Day 7 of the Visual Studio Tips Advent Calendar is now live
Tags: visualstudio
Published: 2019-12-07 08:31:18

Day 7 of the Visual Studio Tips Advent Calendar is now live. Enjoy! 

What will it be today I wonder?

https://visualstudiotips.co.uk/calendar/

#VisualStudio #DevDecember #VsTipsAdvent #Advent
Advent of Code 2019 Solution Megathread - Day 7: Amplification Circuit
Tags: adventofcode, challenge, adventofcode2019, spoilers
Published: 2019-12-07 07:15:18

---
title: Advent of Code 2019 Solution Megathread - Day 7: Amplification Circuit
published: True
description: Revenge of the Return of the Intcode!
tags: adventofcode,challenge, adventofcode2019, spoilers
series: Advent of Code 2019 Solutions
cover_image: https://i.imgur.com/yMvkemv.png
---

Did you get your IntCode machine just right on Day 5? Well, too bad, it was wrong.

### [Day 7 - The Problem](https://adventofcode.com/2019/day/7)
Looks like we **need more _power_**. And we're given some more parts to fix up our module to scrape a few more Joules out here and there. Unfortunately, our supply elves forgot to send us the documentation, and we have to find the optimal solution ourselves.

Part 1 is about finding the permutation of amplifiers that gives us the best output. Oh, and your IntCode compiler needs to be able to take multiple inputs now.

Part 2 decides that we need to create a feedback loop. I'm interested to see what people come up with for this one.  Maybe we can fake the async?

This one swerves right back into hard territory for me. At the time of posting this, I've only solved part 1, and I may not be able to return to part 2 until Sunday! Calamity! (Ah well, such is life!)

### Ongoing Meta

#### Dev.to List of Leaderboards

* `120635-5c140b9a` - provided by [Linda Thompson](https://dev.to/lindakatcodes) 

 If you were part of [Ryan Palo](https://dev.to/rpalo)'s leaderboard last year, you're still a member of that! 

If you want me to add your leaderboard code to this page, reply to one of these posts and/or send me a DM containing your  code and any theming or notes you’d like me to add. (You can find your private leaderboard code on your "[Private Leaderboard](https://adventofcode.com/2019/leaderboard/private)" page.)

I'll edit in any leaderboards that people want to post, along with any description for the kinds of people you want to have on it. (My leaderboard is being used as my office's leaderboard.) And if I get something wrong, please call me out or message me and I’ll fix it ASAP.

There's no limit to the number of leaderboards you can join, so there's no problem belonging to a "Beginner" *and* a language specific one if you want.

#### Neat Statistics

I'm planning on adding some statistics, but other than "what languages did we see yesterday" does anyone have any ideas?

**Languages Seen On Day 06**

* JavaScript × 4
* Python × 2
* Clojure × 1
* Elixir × 1
* Java × 1
* Kotlin × 1
* PHP × 1
* Prolog × 1
* Swift × 1

> _Many thanks to special guest stat compiler [Massimo Artizzu](https://dev.to/maxart2501)_
TIL: The path to CKA Week 0.
Tags: cka, kubernetes, preparecka
Published: 2019-12-07 06:46:54

I've been using Kubernetes and working with kubernetes related project for about 2 yesrs.
So, it's time to set a goal to test myself for the understanding of k8s; and CKA is a very iconic certification for the kubernetes admins.

So I setup a goal for myself to pass CKA as soon as possible, since I would like to take other certification exam in the future.

**Let's start with my background.**
I've been using container related technique for about 3~4 years.
And my current work is about build up NFVI based on the kubernetes platform.
In short. I'm familiar with kubernetes deployment/management and able to using several kinds of plugin like multus, sriov-cni, cmk, nfd, etc.

But, it been about 2 years since the last time I built up k8s all by manually with k8s v1.9. So it's better for me to prepare CKA from the start.

During the Black Friday and the Cyber Monday.
I bought the **CKA + k8s Fundamentals** and **Certified Kubernetes Administrator (CKA) with Practice Tests** on udemy.

And I plan to start from k8s Fundamentals course, then the Certified Kubernetes Administrator (CKA) with Practice Tests.
Also, I will go through the k8s hard way.
https://github.com/kelseyhightower/kubernetes-the-hard-way
Finally, exercise the tasks part in k8s.io document.
Last but not least, scheduling for CKA exam.

So, let's go. Wish me luck. 🤘
Laravel Design Patterns
Tags: discuss
Published: 2019-12-07 06:19:27

Hello, 

I am new to design patterns and would like to implement it to own project. I have the following application structure.

```ssh
app
  -- Http
    -- Controllers
       ProductController.php
  -- Models
     Product
  -- Repositories
      -- Contracts
         ProductInterface.php
     ProductRepository.php
```

I need your help to understand with the following. 
I want to make my codes extendable like what I have to do If I want to use the Cache for my queries or want to use the Redis? 

**ProductInterface.php**

```php
interface ProductInterface
{
    ...

    public function find($id);

    ...
}
```

**ProductRepository.php**

```php
class ProductRepository implements ProductInterface
{
   ...
   
   public function find($id)
   {
      return $this->product->find($id);
   }

   ...
}
```

Any example is must appreciated.
Using .gitignore files 
Tags: git, github, beginners
Published: 2019-12-07 04:49:13

<p>Sometimes your project that you are going to upload to GitHub contains some very important data that you don’t want the whole internet to see. Thus to tackle this problem it is very essential to maintain a <b>.gitignore</b> file that excludes the different files that you don’t want to be uploaded.<p>

<h4>Some common examples of files that you don’t want to get uploaded to the git servers are:</h4>
<ul>
<li>dependency caches, such as the contents of /node_modules or /packages.</li>
<li>compiled code, such as .o , . pyc , etc</li>
<li>build output directories, such as /bin, /out, or /target</li>
<li>files generated at runtime, such as .log, .lock, or .tmp</li>
<li>hidden system files, such as .DS_Store or Thumbs.db</li>
<li>personal IDE config files, such as .idea/workspace.xml</li>
</ul>

<h4>Git sees every file in your working copy as one of the three things </h4>

<ul>
<li> Tracked - a file which has been previously committed </li>
<li> Untracked - a file which has not been committed before </li>
<li> Ignored - a file which git was explicitly told to ignore </li>
</ul>
<br>

<p>There is no code to toggle gitignore, it is a file that you have to create before committing and maintain it regularly. You have to put names of the files that you want to ignore. <br>
<b>A gitignore file specifies intentionally untracked files that git should ignore. Files already tracked by git are not affected.</b>
</p>

<hr>

<h5>To learn more about <b>.gitignore</b> files click here <a href="https://git-scm.com/docs/gitignore">here</a></h5>

<h5>click <a href="https://github.com/github/gitignore">here</a> to Check out the pre-made gitignore file templates. Use this list to populate the .gitignore template choosers available in the GitHub.com interface when creating new repositories and files.
 </h5>