teleren/devto huggingface dataset:
CSS: R&R part 2
Tags: css, beginners, codenewbie, webdev
Published: 2020-06-06 20:39:32

<h1>Welcome back!</h1>
Refreshing and revitalizing my CSS skills again this week! I'm here to share some more tips and tidbits I've learned with you all.

<h2>Attribute selector</h2>

I knew about the type selectors in CSS for ID, using a #, and class, using a . but I didn't know that you could select elements by their attributes. The attribute selector "matches and styles" elements with that attribute value. For example, if we wanted to select all the elements with the attribute value of 'checkbox' it would look like this: 

```CSS
[type = 'checkbox'] {
    margin: 10px;
}
```

<h2>Types of length: Absolute and Relative</h2>

<h3>Absolute</h3>
Absolute measurements are based on physical measurements, such as inches (in) or milimenters (mm). However, just as absolute measurements in the physical world are not as absolute as they may seem, so it is for computers based on the resolution of the screen. Thankfully, you don't have to be Einstein to understand or use absolute measurements. Just know that it's an approximation based on psychical units of measurement.

<h3>Relative</h3>
Relative units, like em or rem, are relative to another length. Em is relative to font size, but there are others that are relative to the view port. If you are using em, it will be sized relative to the parent elements font size.

<h2>Class declaration: Order matters!</h2>  

In my first R&R post I wrote about how you could assign two different classes to the same element but simply adding a space between the names when you declare the class on that element in the HTML. In CSS, more specific rules will take precedence over less specific ones if there is more than style applied to it. 

So what happens when you have two classes on one element telling the code to styles it in two different ways? It will override the first one that you have in the CSS for the last one you had listed in the CSS. Whichever name you declared first in the HTML doesn't matter though. 

Thanks again for stopping by to read! Hope this helps! Till next time!
Automice - Mouse Auto-Mover
Tags: python, remote, mouse, automice
Published: 2020-06-06 20:36:41

Hello everyone!

I created a small app that is intended for anyone still working from home. I am often annoyed by the constant locked screen every time I am  going for a coffee or short break and due to company policy, I am unable to change the lock screen timeout.

The app is fairly small and works out of the box. It is made to be portable, so it doesn't require any elevated privileges. The settings are saved in the same folder as the launcher, so you will always have the same input parameters, even if you put it on a USB stick and move it around.
Also, it will always be free for use.

I know, it looks pretty basic, but it does its intended job.
![image](https://user-images.githubusercontent.com/33485041/80921902-0d805300-8d82-11ea-8b35-ce1b6da80df0.png)

You can customize how far and how often the mouse will move and also the inactivity period for the mouse. Don't worry, it won't interfere with your work, if any mouse movement is detected the app will just reset its inactivity timer.

You can download it from [here](https://github.com/IulianOctavianPreda/AutoMice-MouseMover/releases), it is available for Windows and Linux at the moment. I currently don't a Mac, so I am unable to compile it for macOS.

For any suggestions or problems, you can always open an issue [here](https://github.com/IulianOctavianPreda/AutoMice-MouseMover/issues)
CKAD Exam : Practice Exercise
Tags: kubernetes, developer, devops, cloud
Published: 2020-06-06 20:12:03

Lot of people asked, how i prepared for CKAD. I'd like to share with you my experience.

A set of exercises that helped me prepare for the Certified Kubernetes Application Developer exam, offered by the Cloud Native Computing Foundation, organized by curriculum domain. They may as well serve as learning and practicing with Kubernetes.

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

During the exam, you are allowed to keep only one other browser tab open to refer official documentation. Make a mental note of the breadcrumb at the start of the excercise section, to quickly locate the relevant document in kubernetes.io. It is recommended that you read official documents before attempting exercises below it.

CKAD is a performance-based exam and it’s all about completing 19 questions within 2 hours. No matter how much you know kubernetes, but time is important in this exam the more you practice the more comfortable you feel during the exam. Practice. Practice. Practice.
I can’t stress this enough because the more you practice, the faster you will be in the exam. It’s all about how fast you could complete each question with the right answer. It wouldn’t be possible without practice.

#Course sections.
Core Concepts - 13%
Multi-container pods - 10%
Pod design - 20%
Configuration - 18%
Observability - 18%
Services and networking - 13%
State persistence - 8%

Section based exercise to be continued in the series of posts.
What is Code-First?
Tags: entityframework, codefirst
Published: 2020-06-06 20:07:23

Entity Framework introduced the Code-First approach with Entity Framework 4.1. Code-First is mainly useful in [Domain Driven Design](https://msdn.microsoft.com/en-us/magazine/dd419654.aspx). In the Code-First approach, you focus on the domain of your application and start creating classes for your domain entity rather than design your database first and then create the classes which match your database design. The following figure illustrates the code-first approach.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/o026lrtbuqpfk6kj2yvs.png)
As you can see in the above figure, EF API will create the database based on your domain classes and configuration. This means you need to start coding first in C# or VB.NET and then EF will create the database from your code.

## Code-First Workflow
The following figure illustrates the code-first development workflow.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/m7pvo20oir9sbik3hrc8.png)
The development workflow in the code-first approach would be: Create or modify domain classes -> configure these domain classes using Fluent-API or data annotation attributes -> Create or update the database schema using automated migration or code-based migration.
//todo
Tags: discuss, codenewbie, learning
Published: 2020-06-06 19:58:41

As a self-teaching developer, I find the list of todo (to learn, to create, to improve) is growing faster than I can check things off the list! I first starting using a simple [chrome extension ](http://momentumdash.com/) to keep track of everything. As the list grew and grew, it's time to move to something more robust.

I've started a Trello board to keep things organized. So far I have three main lists:
- Front End
- Full Stack
- Portfolio

I expect to add things to a fourth "Job Hunt" list in the coming months, as I make progress on those three. Some of the items on the list are small ("finish clone of front-end example") and some are huge and vague ("practice algorithms"). I ask of you, dev community, what are your tips and practices for staying organized and focused in this sea of "todo"?
The Swift Programming Language Companion: Closures
Tags: ios, swift, beginners
Published: 2020-06-06 19:28:28

This article is part of a series on learning Swift by writing code to The Swift Programming Language book from Apple. This is the first article in Section 2 (here is [Section 1](https://app-o-mat.com/post/swift-programming-language-companion-section-1))

Read each article after you have read the corresponding chapter in the book. This article is a companion to [Closures](https://docs.swift.org/swift-book/LanguageGuide/Closures.html).

### Set up a reading environment

If you are jumping around these articles, make sure you read the [Introduction](https://dev.to/loufranco/the-swift-programming-language-companion-introduction-4k0a) to see my recommendation for setting up a reading environment.

To add a new page, in Xcode:

1. Choose File > New > Playground Page
1. Rename the page to "07-Closures"

### Exercises for Closures

At this point, you should have read [Closures](https://docs.swift.org/swift-book/LanguageGuide/Closures.html) in The Swift Programming Language. You should have a Playground page for this chapter with code in it that you generated while reading the book.

#### Exercises

The chapter covers how to create and call closures and the concept of _capturing_.

For these exercises, we are going to imagine a simple media playing app.

In your Playground write code to do the following:

1. Declare a Boolean variable called `isPlaying` and set it to `false`.
1. Declare a constant called `play` that is a closure type that takes no arguments and returns `Void`. Initialize it with a closure that prints the word "Play" and sets `isPlaying` to `true` when called.
1. Call `play`. Print `isPlaying` (it should be true)
1. Make a constant called `stop` which is like `play` but prints "Stop" and sets `isPlaying` to `false`
1. Call `stop` and print `isPlaying`
1. Under `isPlaying`, Declare an optional `String` variable called `currentSong`
1. Add a `String` argument to play called `song` and set `currentSong` to it inside the closure.
1. Update your call to play pass a `song` argument
1. Print `currentSong` after calling `play`
1. Declare a `playList` array of `Strings` and initialize it with 5 songs.
1. Sort the list by the length of the song name


#### Next

The next article will provide exercises for the [Enumerations](https://docs.swift.org/swift-book/LanguageGuide/Enumerations.html) chapter.
ASKING FOR HELP
Tags: javascript, help, html
Published: 2020-06-06 19:18:19

Hey Guys 
I'm creating a website and in there, I wanna take an email from user using prompt
Then I wanna validate the email and then I want to get the email they have given
So that I can add it in my subscribers' list...

So can I do that using a prompt ? And how to do if yes..  and If it's not possible.. please tell me some other methods
How to create a web server using Cowboy without Plug or Phoenix - Part 01
Tags: cowboy, elixir, phoenix, plug
Published: 2020-06-06 19:04:59

---
title: How to create a web server using Cowboy without Plug or Phoenix - Part 01
published: true
canonical_url: https://minhajuddin.com/2020/06/05/how-to-create-a-web-server-using-cowboy-without-plug/
description: 
tags: Cowboy, Elixir, Phoenix, Plug
series: Cowboy with Elixir
//cover_image: https://direct_url_to_image.jpg
---

Cowboy is an amazing web server that is used by Plug/Phoenix out of the box, I don't think Phoenix supports any other web servers at the moment. However, the [plug adapter](https://github.com/elixir-plug/plug/blob/master/lib/plug/conn/adapter.ex) is fairly abstracted, and plug implements this adapter for cowboy through the [plug_cowboy](https://github.com/elixir-plug/plug_cowboy/) hex package. In theory, you should be able to write a new adapter if you just implement the [Plug adapter <abbr title="That's not a typo :) it comes from the british heritage of Erlang">behaviour</abbr>](https://github.com/elixir-plug/plug/blob/master/lib/plug/conn/adapter.ex). The plug cowboy adapter has a lot of interesting code and you'll learn a lot from reading it. Anyway, this blog post isn't about Plug or Phoenix. I wanted to show off how you can create a simple Cowboy server without using Plug or Phoenix (I had to learn how to do this while creating my side project [webpipe](https://webpipe.hyperngn.com/))


We want an application which spins up a cowboy server and renders a hello world message. Here is the required code for that:

```elixir
defmodule Hello do
  # The handler module which handles all requests, its `init` function is called
  # by Cowboy for all matching requests.
  defmodule Handler do
    def init(req, _opts) do
      resp =
        :cowboy_req.reply(
          _status = 200,
          _headers = %{"content-type" => "text/html; charset=utf-8"},
          _body = "<!doctype html><h1>Hello, Cowboy!</h1>",
          _request = req
        )

      {:ok, resp, []}
    end
  end

  def start do
    # compile the routes
    routes =
      :cowboy_router.compile([
        {:_,
         [
           # { wildcard, handler module (needs to have an init function), options }
           {:_, Handler, []}
         ]}
      ])

    require Logger
    Logger.info("Staring server at http://localhost:4001/")

    # start an http server
    :cowboy.start_clear(
      :hello_http,
      [port: 4001],
      %{env: %{dispatch: routes}}
    )
  end
end
```

And, here is a quick test to assert that it works!

```elixir
defmodule HelloTest do
  use ExUnit.Case

  test "returns hello world" do
    assert {:ok, {{'HTTP/1.1', 200, 'OK'}, _headers, '<!doctype html><h1>Hello, Cowboy!</h1>'}} =
             :httpc.request('http://localhost:4001/')
  end
end
```

[Full code on GitHub](https://github.com/hyperngn/cowboy-examples/tree/master/hello)
Online chat with Python
Tags: python, tornado, websocket, chat
Published: 2020-06-06 19:03:47

---
title: Online chat with Python
published: true
description: Simple web chat with Tornado web-server and WebSocket.
tags: python, tornado, websocket, chat
cover_image: https://abgeo.dev/uploads/images/projects/5edbe5d677d1c.png
---

Here is my simple Python project with a Tornados web server and WebSocket: https://abgeo.dev/project/20
Always test default parameters (Graphql, express)
Tags: javascript, graphql, node, todayilearned
Published: 2020-06-06 18:56:37

# Introduction 

So I have been recently working on an app that uses the following:

**Backend:** 
 - Graphql Yoga
 - Prisma2

**Frontend:**
 - apollo-graphql
 - apollo-boost
 - react

# The problematic

The main issue I was encountering was all my data is based on the user that is logged in. This meant having the bearing token to check in the active connections which userID is the id of the person making the request.

Currently the platform has a list of active connections in the context generated by Graphql Server

```
{webtoken:  {userID, timestamp}
```

The issue that arose was that the bearer token passed by Apollo Boost is in the request headers per standard.

But when working with GraphQL Query we only have the variables passed and thus no idea hwo is making the request.

After searching high and low for how to get access to either:
 - Get access to `request.headers` from GraphQL Query
 - Add middleware to GraphQL Server to pass the `request.headers` as variable to the query

# The solution 

After tens and tens of testing and `console.log` I noticed this line:

```js
const server = new GraphQLServer({ schema, context: createContext, })
```

In my create `createContext` I initialize a class which handles the prisma2 client, active connections and more: 

```js
export function createContext(): Context {
    return { prisma, connections: connectionContext }
}
```

I then decided to add the following:

```js
export function createContext(req: any): Context {
    console.log(req)
    return { prisma, connections: connectionContext }
}
```

Turns out the default value passed to the context by GraphQL Server is the request payload.
This means we can do the following:

```js
export function createContext(req: any): Context {
    // Check and set bearer token
    const bearerToken = req.request.headers.authorization || null
    return { prisma, bearer: bearerToken, connections: connectionContext, drive: driveContext }
}
```

This means in my GraphQL query I can get access to the `context.bearer`.

```js
t.list.field('User', {
    type: 'User',
    resolve: (_parent, _args, ctx) => {
        return ctx.prisma.user.findMany({
            where: {userID = ctx.connections.getUserByToken(ctx.bearer)}
        })
    },
})
```
Getting Started with MQTT
Tags: mqtt, iot, mosquitto, pubsub
Published: 2020-06-06 18:47:40

---
title: Getting Started with MQTT
published: true
description: The MQTT protocol is a lightweight protocol that enables small IoT devices to communicate using publish and subscribe model.
tags: [mqtt, iot, mosquitto, pubsub]
cover_image: https://jeetprksh.github.com/post/getting-started-with-mqtt/louis-reed-zDxlNcdUzxk-unsplash.jpg
---

MQTT is a light-weight publish and subscribe protocol which allows low energy devices to exchange messages among each other. It is a simple messaging protocol design for resource constrained devices having low bandwidth. And hence it has found wide adoption on devices for Internet of Things (IoT) as it enables the IoT devices to receive control commands to do various things like turning the lights on or off.

There are many brokers available that implement MQTT protocol. I will be using Mosquitto Broker for the purpose of this and future posts.

## Setting up Mosquitto MQTT Broker

Head to the official [Mosquitto Downloads](https://mosquitto.org/download/) page for installing MQTT broker on your Windows or Linux machine. Or if you are more comfortable with docker you can also download and run the [official docker image](https://hub.docker.com/_/eclipse-mosquitto) from Docker Hub as well.

`docker run -it -p 1883:1883 -p 9001:9001 eclipse-mosquitto:latest`

This command will download the eclipse-mosquitto image and start the container which will listen on port 1883 for incoming connections.

## Connecting to Mosquitto MQTT Broker

Now that we have set up the Mosquitto MQTT Broker we are ready to publish messages to it. When we install the Mosquitto broker from its official downloads page it installs the CLI based MQTT client as well which allows us to publish messages and subscribe to the Mosquitto MQTT Broker.

With the following command we can subscribe to the broker:

`> mosquitto_sub -t mqtt/test`

And to publish the message to broker we can use this command:

`> mosquitto_pub -t mqtt/test -m "Hello MQTT"`

In both of the above commands we have used `-t` flag to specify which of the topics to subscribe and publish to. By default both commands will try to find the broker at localhost, if we want the clients to connect to a broker located somewhere else we can use `-h` flag for that. Also the message to be published can be specified by `-m` flag.

And as soon as we publish a message on terminal running publish client we see the same message appear on the terminal running subscriber client.

![Subscribing to Broker](https://jeetprksh.github.io/post/getting-started-with-mqtt/mosquitto-subscribe.png "Subscribing to a topic on Mosquitto Broker")

![Publishing to Broker](https://jeetprksh.github.io/post/getting-started-with-mqtt/mosquitto-publish.png "Publishing to a topic on Mosquitto Broker")

There is a lot more to MQTT that I have not covered in this post like Topic Levels, Message Encryption, Message Retention and much more. But these would surely be the topics for future posts. So stay tuned!

>This article is already published on my personal [blog](https://jeetprksh.github.io/post/getting-started-with-mqtt/).
Build it and they will come
Tags: opinion, career
Published: 2020-07-09 07:37:28

---
title: Build it and they will come
description: "No matter if it’s a product, platform, framework or some other piece of tech, if you think that if you just build it people will come, I’m sorry to break it for you: you’re wrong."
published: true
date: 2020-06-06 18:16:10 UTC
tags: opinion, career
canonical_url: https://blog.mastykarz.nl/build-it-they-will-come/
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/rq38ywvrrzqym2rj2qpe.jpg
---

No matter if it’s a product, platform, framework or some other piece of tech, if you think that if you just build it people will come, I’m sorry to break it for you: you’re wrong.

To you, it makes perfect sense. It’s better/faster/cooler/simpler/has more features/can handle the scale. It’s a no-brainer that everyone should use it. It’s stupid not to use it.

And yet, somehow others don’t share your enthusiasm. Looking at your solution, others are nowhere near as thrilled as you are. They clearly don’t get it. Or do they?

Building something is never the solution. It’s just one step towards it. Whatever you have to offer, it brings change and people hate change. Unless you make them a part of it. Unless you help them understand why it’s needed and what role they plan it.

People support what they help make. So next time you want to make something, before you start coding away, ask yourself: who needs to be on board so that your effort isn’t a waste of time.

<small>Photo by <a href="https://unsplash.com/@brucemars">bruce mars</a> on Unsplash</small>
Motivation to code and write a blog
Tags: beginners, motivation, html, css
Published: 2020-06-06 17:55:29

I’ve always been a creative soul. I spent my whole education at a school of fine arts. After lessons I liked to sew, crochet, and make clothes, and accessories out of nothing - it’s called upcycling. I used to write a blog where I shared my upcycling ideas. After receiving my degree I’ve realized that neither the art world nor the fashion industry would suit my needs. 
My friend once told me she wanted to learn how to code. I thought it sounded pretty cool, so I asked what coding was. Since I like to learn new things, I was interested in giving it a try. I checked it out and it turned out to be absolutely amazing because it was the same thing I had been doing in my youth: creating something out of nothing.
Thus, to follow my new-found passions in a new field, I’m running my new blog http://neverendingcode.com/

The blog is both for you and for me.

For you because you get access to a wide field of front-end development knowledge and experience. My aim is to build a friendly environment for beginning programmers and to provide the clearest coding aid. 
I want to support especially people for whom english is not the first language, because I’m one of these people and I know what obstacles can appear on their way. That’s also the cause why I definitely want to write the blog in two languages - english and polish - I want to support my natives. 

The blog is for me because I feel a kind of calling to teach. Currently, I work at school as a teaching assistant and I love the process of sharing knowledge! Some people say I’m pretty cool in explaining things.
The blog is for me also because I need some of the learning diary - proof of my effort and improvement that I could see in a half of year. 
It is also to be my showcase. A permanent answer to my friends’ questions: What did you make recently? or What are you coding now? It is also a nice thing to show my potential employers.

So many advantages for me and for other people. Achieving this goal makes me feel a good person as I do something for myself and others.

And you? What is your strong motivation to learn code?
What are you like?
What do you like?
What is your calling?
What do you want to create?
And for whom? And WHY?
Do you love video games so much you want to create them? Are you in love with data science? Is the web your second home? Answer as many questions as you need to define your programming goal and motivation. It will keep you strong, confident and will help you in the time of doubt.