teleren/devto huggingface dataset:
Kubernetes or Docker Swarm? 
Tags: kubernetes, dockerswarm, devops
Published: 2018-07-24 05:42:51

---
title: Kubernetes or Docker Swarm? 
published: true
description: 
tags: kubernetes, docker swarm, devops
---

Docker adoption is still growing exponentially and more and more companies have started using it in Production. 
It is important to use an orchestration platform to scale and manage your containers. Imagine a situation where you have been using Docker for a little while, and have deployed on a few different servers. Your application starts getting massive traffic, and you need to scale up fast, how will you go from 3 servers to 40 servers that you may require? And how will you decide which container should go where? How would you monitor all these containers and make sure they are restarted if they exit? 

This is where Kubernetes comes in.

You might just ask, Can just as easily achieve the same result with Docker Swarm, with far less complexity too. 

It’s not that easy to compare Kubernetes and Docker Swarm. Why?

Docker Swarm is preferred in environments where simplicity and fast development is preferred. Whereas Kubernetes is fit for the environments where medium to large clusters are running complex applications.

Unquestionably, Kubernetes gets a lot of attention given that it has a huge community out there(The Kubernetes project on GitHub has over 1500 contributors and they actively release tons of tooling, extensions, etc.) and it easily rationalizes applications, particularly web-centric applications. But it may not always be the best choice for a given context and hence Kubernetes vs Swarm is not always the question to be asked, rather the kind of questions that need to be asked when considering container orchestration need to think the types of applications that need to run.
Along with all this, you also need to consider the facts and ease with

Installation and set-up

Logging and monitoring

Scalability

Availability

Networking

For example, when it comes to installation and setup, Kubernetes can be quite complex with steep learning curve whereas Docker Swarm is easy to install with a fast setup. 

What do you prefer, Kubernetes or Docker Swarm?
Why to use refs instead of IDs In React JS
Tags: react, javascript, webdev, dev
Published: 2018-07-24 04:48:15

---
title: Why to use refs instead of IDs In React JS
published: true
description: Why to use refs instead of IDs In React JS 
tags: #react #javascript #webdev #dev
---

Post Link : https://www.skptricks.com/2018/06/why-to-use-refs-instead-of-ids.html

Lets start with ID attribute in react js and here we have used ID attribute to access one of the element in react component. Actually in this IdComponent Component we are performing below operations :
When user focus on text field, then it will change the border color to Blue and background color to light black.
When user focus out of the text field, then it will reset the border color and border color to initial stage.

<a href="https://www.skptricks.com/2018/06/why-to-use-refs-instead-of-ids.html">Why to use refs instead of IDs In React JS </a>

<img src="https://3.bp.blogspot.com/-HKgUdqbVmE4/WyUTkluy0tI/AAAAAAAABn0/ZDTMz41XKnIXGJgGT92oHROXCzUxNpI_gCLcBGAs/s400/ref.jpg"  />

The Reusability Problem
The problem you'll encounter , when you are using same component more than once. Here's a demo of re-usability issue with ID attribute, when you try to create that same component multiple times. Tap through the input fields to see what happens. Here we have created multiple objects with the same ID.

Solution is Ref
This component using Ref attribute to overcome above issue.
Games that teach you to program (without you realizing it)
Tags: discuss, programming
Published: 2018-07-24 02:21:13

---
title: Games that teach you to program (without you realizing it) 
published: true
description: What are some games that teach you programming that you may not realize are teaching you?
tags: discuss, programming
cover_image: https://thepracticaldev.s3.amazonaws.com/i/so5ravucpiw6c89da3yj.png
---

I've been replaying a game recently on Steam called [Spacechem](http://www.zachtronics.com/spacechem/). I had never realized it before but this game does an excellent job of simulating programming.  For example:

* Creating small, modular components that can be used in conjunction to create more complex systems
* Multiple processes run in parallel and need to be managed concurrently
* Bugs in your dependent modules that were tested individually can break when incorporated into larger systems if not thoroughly tested

I could go on but you get the idea.  The premise of the game has nothing to do with programming but, fundamentally, it is requires the same skills and techniques to be successful.  It's amazing because when I started playing this game 6 or 7 years ago I never thought of it as, basically, a training module for building complex applications.

What are some of the games that you found invaluable in learning to program?  I am not specifically talking about the obvious ones like [CodeCombat](https://codecombat.com/), which are great games in their own right, where the primary objective is to teach programming.  I am referring to those that are more subtle and teach you the techniques while not ultimately being a coding exercise disguised as a game.

- BG
Rule-Based HTML Form Validation with Formation
Tags: javascript, forms, opensource, webdev
Published: 2018-07-24 01:17:23

---
title: Rule-Based HTML Form Validation with Formation
published: true
description: An open source form validation library
tags: javascript,forms,open-source,webdev
---

Even for relatively simple projects, consistent client-side form validation can get tedious. To that end a while ago I wrote a library called [Formation](http://ozzyogkush.github.io/formation/) (available on NPM at https://www.npmjs.com/package/js-formation).

I was inspired by Bootstrap and how you can simply add `data-` attributes to your DOM nodes, add the `<script>` tag, and let the library see and react. This lets the developer use the code without having to know JavaScript, while providing a simple API for hooking into registered changes. Formation allows developers to validate forms based on text inputs, checkboxes/groups, radio button groups, and select boxes. Developers can add handlers to listen to field and/or form validation state changes, and add custom rules and apply them to many fields. [See a live example for text-based input](http://ozzyogkush.github.io/formation/examples/text-inputs).

Currently it enforces a submit button, but that's a choice based on an early opinionated viewpoint that I will likely modify.

This was originally designed with jQuery and raw DOM manipulation in mind, and I have since removed jQuery from the equation as ultimately it was unnecessary. Nowadays, stateful view libraries like React and Vue are the norm, and manual DOM manipulation is less of a thing. So, in the near future I'll be working to extract out the validation and rules engines from the DOM traversal/manipulation side, so that this can be extended easily to 3rd party libraries like React and Vue. It also makes it possible to re-use the rules/validators engines server-side form submission handling (in projects running a Node backend of course).

For basic web projects that don't require the overhead of something like React, but need to let users input and submit data, this can save a lot of time and energy. More often than not, when building some piece of code, a well-maintained module/package/library exists which can and should be re-used. I'd like to think Formation would get to the level where it's in common use. Only time will tell!

This is an open source project and I would welcome contributors! Check it out on github: https://github.com/ozzyogkush/formation/
Install just redis-cli on Ubuntu, Debian, Jessie
Tags: redis, tooling, webdev, linux
Published: 2018-07-24 13:21:48

---
title: Install just redis-cli on Ubuntu, Debian, Jessie
published: true
tags: Redis,tooling,webdev,linux
canonical_url: https://codewithhugo.com/install-just-redis-cli-on-ubuntu-debian-jessie/
---

As part of adding integration tests to an app on CircleCI I ran into the following issues:

- `redis-cli`'s API has changed from version 2 to 3 to 4
    - ie. this works in v4 `redis-cli -u ${REDIS_URL}` but doesn’t in v2
- the "only way" to install `redis-cli` is through a `redis-tools` or `redis-server` install and I _only_ need `redis-cli` not the server or any other tools

What follows is how _not_ to install `redis-cli` and then how to install `redis-cli` latest, properly.

> This was sent out on the [Code with Hugo newsletter](https://buttondown.email/hugo) last Monday.
> [Subscribe](https://buttondown.email/hugo) to get the latest posts right in your inbox (before anyone else).

## Bad
```sh 
apt-get install redis-tools
```

This installs an outdated version, `2.8.x` where stable is `4.x.x`.

## Better
```sh
apt-get install redis-server
```

Maybe we don’t need the full `redis-server` install if we only need the CLI.
Sometimes it also installs the old `redis-cli`… not the best.

## Best
```sh
cd /tmp
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make
cp src/redis-cli /usr/local/bin/
chmod 755 /usr/local/bin/redis-cli
```

You’ll need `libjemalloc1 libjemalloc-dev gcc make` most of which should already be installed. We're building from source... which takes about a minute on the CircleCI containers (so I would expect less everywhere else), which is fine.

Credit: [DevOps Zone, install redis-cli without installing server](https://www.devops.zone/ha-performance-caching/installing-redis-cli-without-installing-server/). I shamelessly took the snippet from there, because hey, it works.

## Installing redis-cli latest on CircleCI

Same as above except:

```sh
sudo cp src/redis-cli /usr/local/bin/
sudo chmod 755 /usr/local/bin/redis-cli
```

CircleCI runs the jobs with a non-root user by default, and kudos to them for that, more tools should make you think about what privileges you have.

I'm not exactly sure what distribution CircleCI images run, some sort of Debian? Let me know at [hi@codewithhugo.com](hi@codewithhugo.com), or [@hugo__df](https://twitter.com/hugo__df).

## Installing redis-cli latest on Alpine in Docker

```sh
apk --upgrade redis
```

If you know why this works but `apt-get install redis-server` sometimes installs old `redis-cli` drop me a line at [hi@codewithhugo.com](hi@codewithhugo.com), or Twitter [@hugo__df](https://twitter.com/hugo__df).

> This was sent out on the [Code with Hugo newsletter](https://buttondown.email/hugo) last Monday.
> [Subscribe](https://buttondown.email/hugo) to get the latest posts right in your inbox (before anyone else).

<a href="https://unsplash.com/@nilsjacob?utm_medium=referral&amp;utm_campaign=photographer-credit&amp;utm_content=creditBadge" target="_blank">Nils Stahl</a>
Using Current Date and Time In VS Code Snippets
Tags: markdown, snippets, vscode
Published: 2018-07-24 14:18:45

---
title: Using Current Date and Time In VS Code Snippets
published: true
tags: ['markdown', 'snippets', 'vscode'] 
cover_image: https://www.chaseadams.io/img/vscode-current-date-time-in-snippets.gif
canonical_url: https://www.chaseadams.io/2018/vscode-current-date-time-in-snippets/

---

Previously when generating new blog articles, adding dates to Markdown frontmatter was a manual step that required me to:

- Determine the date
- Convert what I read into the date format I use for frontmatter

As of [VS Code release 1.20](https://code.visualstudio.com/updates/v1_20#_more-snippet-variables), Snippets have access to the current date and time with one of the following variables:

- `CURRENT_YEAR`
- `CURRENT_YEAR_SHORT`
- `CURRENT_MONTH`
- `CURRENT_DATE`
- `CURRENT_HOUR`
- `CURRENT_MINUTE`
- `CURRENT_SECOND`

Now if I want a frontmatter "date" for Markdown for the current year, month and day (`YYYY-MM-DD`), I can add the following to my snippet:

```
date: \"$CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE\"
```

Using the published date of this post, the expanded snippet produces:

```
date: "2018-07-24"
```

 ![](https://www.chaseadams.io/img/vscode-current-date-time-in-snippets.gif "Markdown snippet with current date and time automatically inserted")
Module Monday: Photoswipe gallery, Fixed sidenav, Corner ribbon, & more
Tags: showdev, opensource, webdev, javascript
Published: 2018-07-23 22:25:17

---
title: Module Monday: Photoswipe gallery, Fixed sidenav, Corner ribbon, & more
published: true
description: Module Monday 5
tags: showdev, opensource, webdev, javascript
cover_image: https://res.cloudinary.com/component/image/upload/c_pad,g_center,h_370,w_880/v1532122031/photoswipe_mpmobd.gif
canonical_url: https://guide.anymod.com/module-monday/05.html
---
## Free to fork or copy + use anywhere

Every Monday I post free, open-source mods you can use for adding quick functionality to your website or web app.

Everything below is open source and free to use in any project you choose. Copy the code into your project, or use the "Add to website" feature to get a code snippet that works anywhere.

Click a mod to see it in action along with its source code.

### Photoswipe gallery
Advanced, interactive, easy-to-use photo gallery.
<a class="button" href="https://anymod.com/mod/andkk?h1=48&h2=48&v=20">View mod</a>
<a href="https://anymod.com/mod/andkk?h1=48&h2=48&v=20">
  <img src="https://res.cloudinary.com/component/image/upload/v1532122031/photoswipe_mpmobd.gif"/>
</a>

### Fixed navigation (right side)
Add & edit navigation links on the fly.
<a class="button" href="https://anymod.com/mod/lromo?v=20">View mod</a>
<a href="https://anymod.com/mod/lromo?v=20">
  <img src="https://res.cloudinary.com/component/image/upload/v1532123748/sidenav_ahqm8f.png"/>
</a>

### Corner announcement
Set a corner message, with custom link and colors.
<a class="button" href="https://anymod.com/mod/dboaa?h1=50&h2=100&v=20">View mod</a>
<a href="https://anymod.com/mod/dboaa?h1=50&h2=100&v=20">
  <img src="https://res.cloudinary.com/component/image/upload/v1532122020/corner-ribbon_cozyoa.png"/>
</a>

### Content columns
Add one or more stylish columns and easily manage content.
<a class="button" href="https://anymod.com/mod/modbl?v=20">View mod</a>
<a href="https://anymod.com/mod/modbl?v=20">
  <img src="https://res.cloudinary.com/component/image/upload/v1532122024/content-columns_xgurzd.png"/>
</a>


### Spotify playlist
Embed a custom, responsive Spotify playlist anywhere on your site.
<a class="button" href="https://anymod.com/mod/nmlda?v=20">View mod</a>
<a href="https://anymod.com/mod/nmlda?v=20">
  <img src="https://res.cloudinary.com/component/image/upload/v1532122020/spotify_kfkhnh.png"/>
</a>

Anymod supports developers and open source, and Module Mondays are one way we give back to the developer community to help foster a more open, inclusive web. We hope you enjoy!

## Contributing
If you want to contribute mods or ideas so that other developers can benefit, you can [request mods](https://guide.anymod.com/v1/community/requests.html) or [submit a mod](https://guide.anymod.com/v1/community/contributing.html).

I'll be posting new modules [here](https://dev.to/tyrw) every Monday -- I hope you find them useful!

Happy coding ✌️
Old Vault Posts Now Have Redirects!
Tags: openshift, containers, devops, kubernetes
Published: 2018-07-23 20:02:14

---
title: Old Vault Posts Now Have Redirects!
published: true
description: Links to posts that moved off of https://vault.osninja.net should now redirect appropriately to the new blog.
tags: openshift, containers, devops, kubernetes
cover_image: https://thepracticaldev.s3.amazonaws.com/i/hhabesws6z42srx8jw3c.jpeg
---

I have added redirects for a lot of the old posts on https://vault.osninja.net that have moved to my new blog at https://blog.osninja.io. This might have impacted you if you were looking for my [OpenShift for Mere Mortals](https://blog.osninja.io/tag/openshift-for-mere-mortals) series or my [DockerCon 18](https://blog.osninja.io/tag/dockercon-18) series. 

I apologize for any inconvenience as I work out the kinks of separating out my tech blog from my personal one. [Email me](mailto:jeffrey@osninja.io) if you find any other pages that are broken.
REST API - Yet Another UI
Tags: discuss
Published: 2018-07-09 09:01:13

---
title: REST API - Yet Another UI
published: true
description: 
tags: discuss
---

I'm working on my new product and it's my task to develop the backend.
It's not a complicated tech stack, we are going only with a few pieces for an MVP:

```
MongoDB <-> Node.js <-> React Native (Android & iOS)
```

It's been a while since I've worked on a not small project. I'm trying to decouple the Service Layer from the "Web Service (Layer)" (REST API), and I just realized something: 

# **REST API is just a UI**

This might be a bit silly or bold statement, but if you think about it then it makes sense in my opinion. When I realized that, the tech stack changed:

```
MongoDB <-> Core (Node.js) <-> REST API (Node.js) <-> React Native (Android & iOS)
```

All of these pieces are decoupled. 
I might be stupid, but this is a serious realization for me.

---

I just wanted to share this with you guys and would like to hear what you think.
We never stop learning and hopefully you will write something that will make me realize something very important.
Line spacing in Visual Studio
Tags: visualstudio, cpp, gamedev
Published: 2018-07-23 18:41:33

---
title: Line spacing in Visual Studio
published: true
description: Workaround to missing line spacing feature in Visual Studio
tags: visualStudio, cpp, gamedev
cover_image: https://raw.githubusercontent.com/alexhajdu/visual-studio-fonts/master/Preview.png
---

Visual Studio is not as fancy as it's sibling VSCode. I'm ok with that, no problem. 

**But hey, why on earth we can't even set up line spacing!?**

For me personally, the line spacing is a must have feature - it's a huge step towards code readability.

Anyway, let's keep this short. In the repository bellow, you can download the workaround to this missing feature. Your eyes will be happy :)

A.

{% github alexhajdu/visual-studio-fonts %}
Can you excel at front-end with average UI design skill?
Tags: beginners, help, career, advice
Published: 2018-07-23 18:03:51

---
title: Can you excel at front-end with average UI design skill?
published: true
tags: beginners, help, career, advice
---

Hi all, my first post here!

I am a self-taught aspiring front-end developer who came from a non-technical background. I _love_ and enjoy working with HTML, CSS (and preprocessors), and templating systems (ERB, Mustache, Handlebar). I am still improving my Javascript and related tech stacks (React, bundlers, static site generators). While I don't instantly "get" everything at once, I make reasonable progress and enjoy the learning process. 

But one thing that gives me serious impostor syndrome is **I am not good at creating UI design**.

I'm familiar with basic graphic design principles (proportion, proximity, etc) and can create reasonably decent websites with style guides or existing frameworks/themes to work on. I love implementing existing visual design comps, improving and optimizing for web (responsiveness, accessibility, etc). I enjoy learning about user needs and figuring out ways to meet those needs.

However, I am stuck whenever I try to _create_ UI design on my own (pick colour schemes, make layout from scratch, decide on spacing, sizes, illustration style, iconography, etc). I spend hours on Pinterest & Dribbble, I browse and recreate designs I like; I try to translate moods, concepts, and objectives into inspired visual elements; but my UI designs remain simple and mediocre, and I find it frustrating.

I'm aware that _"front-end"_ technically encompasses a complex spectrum of overlapping fields and might be considered separate from _"UI design"_. But in the real world, good front-end developers I follow mostly seem to have good artistic skills, and front-end job positions I see (often? occassionally? sometimes?) require good UI design skills.

My questions:
- How important are UI design skills for professional front-end developers?
- If you have experience with this: How do you make up for the lack of advanced UI skills? (Do you have to be extra good at the programming/logic side of things? Or excelling at HTML, CSS, JS would suffice?)

I've been worrying about this for a while — did not realize it'd end up this long, sorry! 😅 — and I'd be interested to hear from folks in the same boat.

Anyway... thanks for reading!
Logging approaches in Go
Tags: go, logging
Published: 2018-07-23 16:56:21

---
title: Logging approaches in Go
published: true
description: Working with and thinking about glog
tags: go, logging
cover_image: https://thepracticaldev.s3.amazonaws.com/i/ugh3xwzqsycuznlgj7sk.jpeg
---

During a [kubeadm](https://kubernetes.io/docs/reference/setup-tools/kubeadm/kubeadm/) clean up cycle I found a neat feature of the [glog](https://github.com/golang/glog) library that made me think about various approaches to logging.

This flag is what set off my thought process:

```
  -log_backtrace_at value
    	when logging hits line file:N, emit a stack trace
```

I really needed this feature for the ticket I was working on, but it's not a feature I've seen in other logging libraries. `glog` takes the stance that logging should be global. You import the `glog` library and log whatever lines you need wherever you want. You don't configure `glog` with code, you configure it at runtime with flags. That's why glog requires you to run `flag.Parse()` before using it. `glog` gets the job done quickly as a global logger.

On the opposite end of the spectrum, you have logging as a proper dependency. The logger is a parameter to your function or exists on the struct. Either way, it's configurable via code which makes writing unit tests a lot easier. You don't have to resort to [Go's testable examples](https://blog.golang.org/examples) to make sure your application is logging correctly. This approach is good when you rely on the output to be a certain way or depend on logs for more than just debug output. Check out [logrus](https://github.com/sirupsen/logrus) for a nice library that is easily wrapped to be a proper logging dependency.

As is the answer of almost every tech question, choose the method that works for the project at hand. Likely you'll end up somewhere in the middle and use both types of logging and that's ok. The only important thing is to treat each log type as it should be treated. So go ahead and skip unit testing of global loggers and don't forget to build in extra time for a well tested library by injecting the logging dependency.