teleren/devto huggingface dataset:
Explain different CMS options Like I'm Five
Tags: explainlikeimfivecms
Published: 2019-08-23 13:36:16

---
title: Explain different CMS options Like I'm Five
published: true
tags: explainlikeimfive cms
---

I've been looking into a CMS for websites I'm creating for various small non-profit organizations and whoa, I didn't realize how complex the CMS world was in itself! In the past I've only worked with Wordpress and Umbraco (testing an established CMS through my job) and I'm relatively new to web dev so my understanding of CMSs is somewhat limited at this time. I've been coming across terms such as 'headless CMS', 'baking style', 'static site generators', among others.

Can someone explain to me all the different variations of CMSs that I should be aware of when selecting one type to work with - like I'm five?
Daily Challenge #48 - Facebook Likes
Tags: challenge
Published: 2019-08-23 13:33:11

---
title: Daily Challenge #48 - Facebook Likes
published: true
series: Daily Challenge
description: creating the like system from Facebook
tags: challenge
---
In today's [challenge](https://www.codewars.com/kata/5266876b8f4bf2da9b000362), you are asked to create a like system from Facebook; a text which displays the names of people who liked an item.

> For example:

> `likes []` must be `"no one likes this"`
`likes ["Peter"]` must be `"Peter likes this"`
`likes ["Jacob", "Alex"]` must be `"Jacob and Alex like this"`
`likes ["Max", "John", "Mark"]` must be `"Max, John and Mark like this"`
`likes ["Alex", "Jacob", "Mark", "Max"]` must be `"Alex, Jacob and 2 others like this"` 

> Note: For 4 or more names, the number in and 2 others simply increases.

***
_Want to propose a challenge idea for a future post?  Email **yo+challenge@dev.to** with your suggestions!_

_This challenge comes from BattleRattle on CodeWars. Thank you to [CodeWars](<https://codewars.com/>), who has licensed redistribution of this challenge under the [2-Clause BSD License](<https://opensource.org/licenses/BSD-2-Clause>)!_
Why losing your motivation is okay.
Tags: codenewbie, beginners, mentalhealth
Published: 2019-08-23 13:27:02

To be honest, I fully intended to write a different post today. 

I wanted to write about my journey becoming a web developer. I was planning on doing it over a couple of posts over a couple of weeks and then going into my journey since becoming a fully fledged developer. 

I'm not writing that post today ...

I'm writing a different post.

This is that post ...

Simple sentences.

The thing is, I've been working hard almost every day for the past 18 months. I've got up. I've studied. I've gone to work, coded, studied some more and then gone home and studied some more after that.

That's in addition to:

- learning Turkish
- going to the gym
- making sure my wife knows I'm still alive
- socialising
- eating
- sleeping
- doing things for the sake of my own sanity

Problem I'm having over the last two weeks is ... I don't want to do it right now.

And I know that's wrong because every single YouTube/ Instagram/ Facebook/ My Space (editor's note ... I'm old) influencer is telling me that I should be getting up 45 minutes after I fall asleep, completing my workouts whilst I shower and living off of crackers so I can invest the money I would've spent surviving in a self managed stock exchange portfolio.

Right now, I don't want to do that. 

I want to chill out on my sofa and do none of those things.

But that's okay ...

I know from my own experience that after a little while of next to no motivation to do anything, I'll wake up to an epiphany. Suddenly I'll want to do nothing but work my absolute ass off.

It's those moments of heightened motivation that I find myself making leaps and bounds. I'll look back after a couple of weeks and things will have clicked into place. I'll have improved massively.

Point here is, don't become demotivated by your lack of motivation. Your mind is telling you to chill out and take it easy. Just make sure that you do take stock, ask yourself if your goals are still the same and if the answer is yes, allow yourself to recover from the tedium of life. 

TLDR: chill the f*** out man.
🛠 Setup WildFly SSL
Tags: devops, java, security
Published: 2019-08-23 12:57:03

DevOps should configure SSL support on WildFly application servers for security reasons. The following steps describe how to configure HTTPS on local server for the web application:

**Step 1:**

*Generate a keystore and self-signed certificate*

Ensure that Java is installed and setup on `JAVA_HOME` properly as JRE keytool will be used for this purpose.

Switch to a command-line and execute the following command as shown below:

`$ keytool -genkey -alias mycert -keyalg RSA -keystore mycert.keystore -validity 365`

The aforementioned command has some default sets, and also prompts the developer to enter additional information as shown below:

```bash
What is your first and last name?
  [Unknown]:  Orestis Pantazos
What is the name of your organizational unit?
  [Unknown]:  Open DevOps
What is the name of your organization?
  [Unknown]:  opendevops.dev
What is the name of your City or Locality?
  [Unknown]:  Athens
What is the name of your State or Province?
  [Unknown]:  Greece
What is the two-letter country code for this unit?
  [Unknown]:  GR
Is CN=Orestis Pantazos, OU=Open DevOps, O=opendevops.dev, L=Athens, ST=Greece, C=GR correct?
  [no]:  yes
```

**Step 2:**

The command generates mycert.keystore file in the folder that you are currently working. Copy this to your WildFly config directory (`%JBOSS_HOME%/standalone/config`)

**Step 3:**

*Configure the additional WildFly Security Realm*

The next step is to configure the new keystore as a server identity for SSL in the WildFly security-realms section of the `standalone.xml`. You can insert the source code after `<management>` tag and also inside `<security-realms>` tag in the XML file.

```xml
<management>
    <security-realms>
        <security-realm name="UndertowRealm">
            <server-identities>
                <ssl>
                    <keystore path="mycert.keystore" relative-to="jboss.server.config.dir" keystore-password="secret" alias="mycert" key-password="secret"/>
                </ssl>
            </server-identities>
        </security-realm>
```

**Step 4:**

*Configure Undertow Subsystem for SSL*

If the default-server is running, add the https-listener to the undertow subsystem:

```xml
<subsystem xmlns="urn:jboss:domain:undertow:1.2">
    <server name="default-server">
        <https-listener name="https" socket-binding="https" security-realm="UndertowRealm"/>
```

Replace only the word `UndertowRealm` with the previous one for https listener in the given namespace into `security-realm="..."`.

**Step 5:**

SSL port of the current instance is already for connection in `https://localhost:8443/`. Otherwise, the SSL port can be changed to 443 as default port number in the end/bottom of the file.

Source: 
https://opendevops.dev/setup-wildfly-ssl/
Setting bing image of the day as desktop wallpaper using Python script
Tags: python
Published: 2019-08-23 11:33:22

Originally published at [**pythoncircle.com**](https://www.pythoncircle.com/post/691/python-script-17-setting-bing-image-of-the-day-as-desktop-wallpaper/?utm_campaign=devto)


Using this python script, we will try to download the bing image of the day and set it as desktop wallpaper.

There is a URL which bing itself uses to fetch the image details using AJAX. We will send GET request to this URL to fetch image details.


```python
# get image url
response = requests.get("https://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1&mkt=en-US")
image_data = json.loads(response.text)
```

Response returned will be in below format.

```
{
	"images": [{
		"startdate": "20190823",
		"fullstartdate": "201908230700",
		"enddate": "20190824",
		"url": "/th?id=OHR.FarmlandLandscape_EN-US6661316442_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp",
		"urlbase": "/th?id=OHR.FarmlandLandscape_EN-US6661316442",
		"copyright": "Farmland in Washington state's Palouse region (© Art Wolfe/Getty Images)",
		"copyrightlink": "https://www.bing.com/search?q=palouse+region&form=hpcapt&filters=HpDate%3a%2220190823_0700%22",
		"title": "Harvest time in the Palouse",
		"quiz": "/search?q=Bing+homepage+quiz&filters=WQOskey:%22HPQuiz_20190823_FarmlandLandscape%22&FORM=HPQUIZ",
		"wp": true,
		"hsh": "44238c657b35ce3c11fbf3f59881474e",
		"drk": 1,
		"top": 1,
		"bot": 1,
		"hs": []
	}],
	"tooltips": {
		"loading": "Loading...",
		"previous": "Previous image",
		"next": "Next image",
		"walle": "This image is not available to download as wallpaper.",
		"walls": "Download this image. Use of this image is restricted to wallpaper only."
	}
}
```


Get the image URL from the response JSON and download it.

```python
# download and save image
img_data = requests.get(full_image_url).content
with open(image_name, 'wb') as handler:
    handler.write(img_data)
```

The image will be saved in the present working directory. Set this image as desktop background using below command.

```bash
`which gsettings` set org.gnome.desktop.background picture-uri file:$PWD/imagename
```

This command will work for Ubuntu. For other operating systems, please update accordingly.



The script is available on [Github](https://github.com/anuragrana/Python-Scripts).



You can automate the process by scheduling this script to run on system startup.


Originally published at [**pythoncircle.com**](https://www.pythoncircle.com/post/691/python-script-17-setting-bing-image-of-the-day-as-desktop-wallpaper/?utm_campaign=devto)
Rubyists life made easier with composition operators.
Tags: ruby
Published: 2019-08-23 11:31:04

If you write Ruby code and wandered into FP world you might just started writing those little tiny methods inside your classes/modules. And that was awesome to write code like this:

```ruby
class Import
  # Some code goes here...
  
  def find_record(row)
    [ Msa.find_or_initialize_by(region_name: row[:region_name], city: row[:city], state: row[:state], metro: row[:metro] ), row ]
  end

  # record is one of:
  # Object - when record was found
  # false - when record was not found
  def update_record(record, attributes)
    record.attributes = attributes
    record
  end

  # record is one of:
  # false
  # ZipRegion
  def validate_record(record)
    case record
    when false
      [:error, nil]
    else
      validate_record!(record)
    end
  end

  # record is ZipRegion object
  def validate_record!(record)
    if record.valid?
      [:ok, record]
    else
      error(record.id, record.errors.messages)
      [:error, record]
    end
  end

  def persist_record!(validation, record)
    case validation
    when :ok
      record.save
    when :error
      false
    end
  end
end
```

*Yeah, I know there is YARD, and argument types are somewhat weird but at the time of coding, I was fascinated with Gregor Kiczales's HTDP courses (that was a ton of fun, sincerely recommend for every adventurous soul).*

And next comes dreadful composition:
```ruby
def process(row, index)
    return if header_row?(row)

    success(row[:region_name], persist_record!(*validate_record(update_record(*find_record(parse_row(row))))))
  end
```

The pipeline is quite short but already hard to read. Luckily, in Ruby 2.6 we now have 2 composition operators: Proc#>> and its reverse sibling Proc#<<.

And, with a bit of refactoring composition method becomes:
```ruby
def process(row, index)
    return if header_row?(row)

    composition = method(:parse_row)        >>
                  method(:find_record)      >>
                  method(:update_record)    >>
                  method(:validate_record)  >>
                  method(:persist_record!)  >>
                  method(:success).curry[row[:region_name]]
                             
    composition.call(row)
```

Much nicier, don't you think? Ruby just became one step closer to FP-friendly languages family, let's hope there'll be more!
Mini-Program, FTW?
Tags: webdev, programming, tutorial, beginners
Published: 2019-06-23 03:16:30

If you haven't experienced WeChat you might not hear of mini-program. It's a sub-application in WeChat ecosystem.

In 90% of the time I work on backend development, mini program development is new to me, just got my hands on it this week.

Here is McDonald's order mini program.

![Order McDonald's](https://thepracticaldev.s3.amazonaws.com/i/xqvrrc0gwjnaifkfw8sg.png)

A mini-program can be developed on Mac or Windows as the toolkits are available for only these two.

It usually contains 

- WXML, defines how the UI looks like.
- WXSS, WeChat style sheet.
- JS/TS, defines business logic.
- Configs, define how it should run.

Similar to Web UI project except it uses some WeChat defined tags and API. Comparing to native apps, it's more lightweight. Check out the reference [here](https://mp.weixin.qq.com/cgi-bin/wx)

Unfortunately, the documents have poor globalization support. Most of the documents are originally written in Chinese. Well, they are improving it, English version can be found [here](https://open.wechat.com/cgi-bin/newreadtemplate?t=overseas_open/docs/mini-programs/development/framework/view/wxss#view_wxss).

Interested? Try it out🙃
Golang Dynamic Logging for Microservices
Tags: go, zap
Published: 2019-08-23 10:51:03

Dynamic logging is something I believe should be implemented in any micro-service environment.  I suppose I should start with I mean by dynamic logging..  Simply put the following point should be covered.

- Maintainer should be able to change the log level of the application mid-execution.

## Sample Application

Using the `go.uber.org/zap` library [LevelEnablerFunc](https://godoc.org/go.uber.org/zap#LevelEnablerFunc) you should be able to implement the interface using any protocol you want? (Haven't tested this).. That being said, for my sample application I will be using an HTTP interface and so I will use the zap built-in [ServeHttp](https://godoc.org/go.uber.org/zap#AtomicLevel.ServeHTTP) method.

First we need to define our logger and build and build an http router to accept log level changes.  This is completed by utilizing the above mentioned `ServeHttp` function built into the `zap.AtomicLevel` object. 

#### Setup Logger
```golang
config := zap.NewProductionEncoderConfig()
...
encoder := zapcore.NewJSONEncoder(config)
atom := zap.NewAtomicLevel()
	logr := zap.New(zapcore.NewCore(encoder, zapcore.Lock(os.Stdout), atom))
```

#### Dynamic log level interface
```golang
mux := http.NewServeMux()
mux.Handle("/log_level", atom)
go http.ListenAndServe(":1065", mux)
```

I am running a simple loop that repeats various logging messages to allow us to see the expected output.  After building and running the application we can interact with it via curl.

#### Change logging levels
```bash
curl -X PUT -d '{"level":"debug"}' localhost:1065/log_level
curl -X PUT -d '{"level":"info"}' localhost:1065/log_level
curl -X PUT -d '{"level":"info"}' localhost:1065/  # EXPECTED 404
curl -X GET localhost:1065/log_level
```

> NOTE: GIF seems to be broken again... but clicking the link should show you... ill fix it later :joy:

![DEMO](https://i.imgur.com/mSc5ET9.gif)


## Sample Application Code

```golang
package main

import (
	"net/http"
	"os"
	"time"

	"go.uber.org/zap"
	"go.uber.org/zap/zapcore"
)

func main() {
	undo := initLogger()
	defer undo()

	for {
		zap.S().Info("test_logs")
		zap.S().Debug("test_logs_debug")
		time.Sleep(1000 * time.Millisecond)
	}
}

func initLogger() func() {
	config := zap.NewProductionEncoderConfig()
	config.EncodeTime = func(t time.Time, enc zapcore.PrimitiveArrayEncoder) {
		nanos := t.UnixNano()
		millis := nanos / int64(time.Millisecond)
		enc.AppendInt64(millis)
	}
	encoder := zapcore.NewJSONEncoder(config)
	atom := zap.NewAtomicLevel()
	logr := zap.New(zapcore.NewCore(encoder, zapcore.Lock(os.Stdout), atom))

	mux := http.NewServeMux()
	mux.Handle("/log_level", atom)
	go http.ListenAndServe(":1065", mux)

	return zap.ReplaceGlobals(logr)
}
```
What are the skills a junior DevOps should have 
Tags: discuss, devops, cloud
Published: 2019-08-23 09:27:46

---
title: What are the skills a junior DevOps should have 
published: true
description: If you were looking to hire a junior DevOps, what would you expect him to know
tags: discuss, DevOps, cloud
cover_image: https://thepracticaldev.s3.amazonaws.com/i/18zisrrcoyiv2j352v3e.jpg
---

Hi folks! :) 
I've been working as a DevOps for nearly two years. I was offered to teach a small group of students a DevOps course. The outcome for them should be that they are hireable at a junior level. 
What skills and technologies you think are a must for them to know and understand? 

Cheers :)
Set commit signing per git repository
Tags: gpg, git, sign, commit
Published: 2019-08-23 09:21:17

---
title: Set commit signing per git repository
published: true
description: These are the commands I end up using to setup commit signing for each git project
tags: gpg, git, sign, commit
---

When dealing with multiple git identities it's sometimes useful to perform a custom setup for commit signing, for each repository:

```shell
λ gpg --list-keys my@email.com
pub   dsa3072 2016-06-23 [SC]
      XXYYZZXXYYZZXXYYZZXXYYZZXXYYZZXXYYZZXXYY
uid           [ unknown] olistik <my@email.com>
sub   elg3072 2016-06-23 [E]
```

It is also possible to extract the the value with a bit of scripting (Ruby in this case):

```shell
λ gpg --list-keys --fingerprint --with-colons my@email.com | ruby -e "puts STDIN.read.lines.grep(/^fpr/)[0].match(/^.*:([0-9A-Z]+):.*/)[1]"
XXYYZZXXYYZZXXYYZZXXYYZZXXYYZZXXYYZZXXYY
```

And then update the git settings within the repository's directory:

```shell
λ git config user.signingkey XXYYZZ
λ git config commit.gpgsign true
λ git config user.email "my@email.com"
λ git config user.name "olistik"
```

Here's a convenience script that can be invoked to setup commit signing:

```bash
#!/bin/bash

set -e

GPG_KEY=$(gpg --list-keys --fingerprint --with-colons my@email.com | ruby -e "puts STDIN.read.lines.grep(/^fpr/)[0].match(/^.*:([0-9A-Z]+):.*/)[1]")
git config user.signingkey $GPG_KEY
git config commit.gpgsign true
git config user.email "my@email.com"
git config user.name "olistik"
```

Here are the versions of my environment:

```shell
λ ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]
λ gpg --version
gpg (GnuPG) 2.2.17
λ git --version
git version 2.20.1 (Apple Git-117)
```

## Issues when committing

If you encounter the following error after a commit command:

```
error: gpg failed to sign the data
fatal: failed to write commit object
```

You could try to update the `GPG_TTY` environment variable and re-run the commit command:

```shell
λ export GPG_TTY=$(tty)
```

It it succeeds, then you can persist this change by putting this line into your `.zshrc` (or `.bashrc` according to the shell you are using).
How to overcome bad periods at work. Let's share from our experiences
Tags: discuss, career, beginners, culture
Published: 2019-08-23 09:04:06

---
title: How to overcome bad periods at work. Let's share from our experiences
published: true
description: How to overcome bad periods at work. Let's share from our experiences
tags: #discuss #career #beginners #culture
---

Hi, how did you overcome a career bottleneck or a bad period at a job (present or past)? We can all learn from other people's experiences and great 💡 can come up to help others. 

Sometimes we don't know who we can ask about this or even how. This could be because of communication issues, being afraid that you look too vulnerable or just by simply trying to fix everything on your own.

<b>My response to this would be:</b> I had some moments until now in my career when I felt like I was not where I wanted - work wise, career wise - and what I did is to work on a side project for me only in which I had fun with new technologies or just with a new idea. I started investing time and money in my own education, not relying on companies to help out (some do by the way). 

Sometimes the politics at work were too much for me, either because I saw them too intense or too personal. What I always try to do is find "my people" at work, try to form professional relationships, and try to help as much as possible, even outside my job specs (I can ask around, I can read articles as well etc).
Reinventing SSIS scripting with JavaScript - COZYROC
Tags: ssis, javascript, etl, sqlserver
Published: 2019-08-23 08:48:06

SSIS is a fantastic platform for automating your ETL scenarios. It provides many useful adapters and transformations out of the box. Additionally, when you need to handle anything out of the ordinary, you can create a script in C# or VB.NET. You can harness the full power of .NET Framework there and meet any special requirement.

Still, everyone who has used SSIS scripting knows there are several pain points with it:

* Upgrading scripts to the next SQL Server version is not an easy affair, as the scripts are early-bound to the current SSIS framework modules.
* The script code is compiled to intermediate language (CIL) and embedded as part of each package. This makes it very difficult to programatically set or change the script code in an SSIS package.

##### [JavaScript Task](http://cozyroc.com/ssis/javascript-task) and [JavaScript Component](http://cozyroc.com/ssis/javascript-component) enable the automation of any custom logic in the Control Flow and the Data Flow of an SSIS package, via JavaScript scripting. Their purpose is similar to the standard Microsoft Script Task and Microsoft Script Component, but they aim to further simplify the development and maintenance of SSIS scripts.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/7qh0gmmtkkuqak3a4wjw.jpg)

##### You can download JavaScript Task and JavaScript Component from COZYROC website http://cozyroc.com/ssis/javascript.


[COZYROC SSIS+ Components Suite is ](http://cozyroc.com/download)
* Free for test and development within Visual Studio
* Support for SQL Server 2005, 2008, 2012, 2014, 2016, 2017, 2019
* 200+ reusable components

Full article: http://cozyroc.com/blog/reinventing-ssis-scripting-javascript
NodeJS: How To Talk/Answer To The Terminal
Tags: javascript, node, eli5
Published: 2019-08-23 08:47:27

---
title: NodeJS: How To Talk/Answer To The Terminal
published: true
description: how to talk or answer to the terminal
tags: javascript, node, eli5
series: Intro to NodeJS
---

## Intro

So we [installed NodeJS](https://dev.to/miku86/what-is-nodejs-how-to-install-it-1900) on our machine.

Now we want to write a simple script, run it from the terminal & talk/answer to the terminal

---

## Write a simple script

- Open your terminal
- Create a file named `index.js`:

```sh
touch index.js
```

- Add this JavaScript code into it:

```js
process.stdout.write("What's your name?\n");

process.stdin.on('readable', () => {
  const userInput = process.stdin.read();
  process.stdout.write(`Your Input was: ${userInput}`);
});
```

Note: I removed all "unnecessary" stuff from the documentation to decrease the complexity of this simple example.

---

## Every line decoded

```js
// writes something to the stdout (your terminal), including a newline at the end
process.stdout.write("What's your name?\n");
```

`Console.log()` uses `stdout` [under the hood](https://nodejs.org/api/console.html#console_console_log_data_args).


```js
// if a specific event (here: a readable stream) happens, then run this  callback
process.stdin.on('readable', () => {...});
```

[Documentation for readable stream](https://nodejs.org/api/stream.html#stream_readable_streams)


```js
// read data from the stream & save it into a variable
  const userInput = process.stdin.read();
```

```js
// writes something to the stdout
  process.stdout.write(`Your Input was: ${userInput}`);
```


## Run it from the terminal

- Run it: 

```sh
node index.js
```

- Result: 

```sh
What`s your name?
miku86
Your Input was: miku86
```

---

## Questions

- Do you use the native `process.stdin` or some libraries like [`inquirer`](https://www.npmjs.com/package/inquirer) or [`prompts`](https://www.npmjs.com/package/prompts)? Why?