teleren/devto huggingface dataset:
Rules in your open space for work
Tags: discuss
Published: 2018-10-04 08:34:51

---
title: Rules in your open space for work
published: true
tags: discuss
---

![Open Space in the Facebook](https://thepracticaldev.s3.amazonaws.com/i/dyc9x87lyip2cedl7hia.jpg)

Hi, folks!

I think more people work in the company and main the room is open space.

Which you have rules in your open space room?

Because in my company we have open space where seats 30+ people and this room very noisy and very active. 

I think this a bad practice.
Help with Microservices
Tags: flask, python, microservices
Published: 2018-10-04 08:24:16

---
title: Help with Microservices
published: true
description: My small mindflow when designing microservices
tags: Flask, Python, Microservices
---

Hello, this is my first post here.

I am building a small deezer/spotify clone for my own purposes. I have a huge CD collection, ripped to various music formats.While doing that, I'll try to implement a Microservice Architecture. I've seen netflix basically outsourcing most of the tools I want, but I want to do it myself and I'd like to see if there are opinions on it.

My choice of technology is Python Flask and Apache Kafka.
I implemented all of the following stuff as a separate Flask Application
So, as any microservice architecture needs is

#### Service registry
It's an app, which will publish its location to the kafka topic, so all of the services could reach it. It has a REST api for registering, and fetching services.

#### API Gateway
It's an app, that has a REST api, which will take the request from the frontend, check if the service is up and exist, and forward it to the appropriate one. One thing that's certainly missing is probably loadbalancer, but let's leave that for now.

Now the services. I am thinking about, how to decouple them correctly, for example.

#### Users
This definitely is a separate microservice, it has login and register API, and keeps track of the users in it's own database.

Now on to the tricky stuff. Now I suppose this stuff is very opinionated, but I'd like to hear what others think of it.

#### Records 
Records service is basically 3 GET API's from where you can fetch artists/albums/tracks lists. That is fine, but for my platform I need to keep the path of every song. I would put that in an other table and connect those two with foreign key so I could keep my "database per service pattern" around. And actually the RECORDS Microservice should not use the table with paths!
Now the problem I am having is, I'd like to have a service that will update these db's occasionally, and my thought is, where would that service run?


#### Playlist

Playlist service takes care of the already mentioned path database, it would publish messages to Kafka broker, that contains the paths to the songs.

#### Player
Player consumes Kafka messages and plays the song one after another.

#### Analytics
This is the service that concerns me the most. How do I decouple it from the rest, when basically it should analyze everything that is happening in all services. Is actually the solution that all of the services have a log Kafka topic that they will publish their stuff to? And the analytics constantly consumes those messages in their own table?


I'd like to hear more opinions about this. Am I overusing Kafka or using it exactly as it's supposed to?

Thanks a lot!
Ripping Youtube vids on the cmd line
Tags: linux, macos
Published: 2018-10-04 07:17:09

---
title: Ripping Youtube vids on the cmd line
published: true
description: How to download youtube videos
tags: linux, macos
cover_image: https://thepracticaldev.s3.amazonaws.com/i/vpp0k52oolgqqw6zqd95.jpg
---

Going through my old linux and macOS cheatsheets, I found this, `youtube-dl`; it lets you rip youtube vids and download them.

```bash
sudo apt-get update && sudo apt-get install youtube-dl
youtube-dl <youtube vid URL>

```

It's also available on macOS. If you use brew, you can get it with this

```bash
brew update
brew install youtube-dl

youtube-dl <youtube vid URL>
```

I think you can also do this in Windows with Cygwin, but I haven't tried that.

**UPDATE**:

{% user zeerorg %} added in the comments. Windows users can also get this via a Python package. You can get the EXE from [rg3/youtube-dl](https://rg3.github.io/youtube-dl/)
セマンティック バージョニング 
Tags: varsion
Published: 2018-10-04 06:53:26

---
title: セマンティック バージョニング 
published: true
description: 
tags: varsion
---

![semver.org](https://thepracticaldev.s3.amazonaws.com/i/yx38a7nohichwljyntor.png)

# What is this?
バージョニングのルールです。

主に公開されるAPIのバージョンの付与規則と言うことです。


## Links
- [Semantic Versioning 2.0.0](https://semver.org/)
- [日本語訳](https://semver.org/lang/ja/)
- [t32k、怒られる！セマンティック バージョニングしてますか？](https://html5experts.jp/t32k/11746/)

## 同意する場合

> セマンティック バージョニングを実践していることを宣言し、ルールを守って下さい。それからあなたのREADMEからこのWebサイトにリンクしてください。
macOS mojave
Tags: discuss, macos
Published: 2018-10-04 06:25:16

---
title: macOS mojave
published: true
description: Should I upgrade to macOS Mojave now
tags: discussion, macOS
---

I just downloaded macOS Mojave upgrade, but I haven't pulled the trigger yet. Is there anything I should watch out for; things it would break? If you've installed it already, anything weird going on? In case it didn't break anything, did it improve anything (speed, battery usage etc)

Thanks
Introducing the XML Language Server!!!
Tags: github, opensource, tools, vscode
Published: 2018-10-04 05:47:01

---
title: Introducing the XML Language Server!!!
published: true
description: XML Language Server!!!
tags: github, opensource, tools, vscode
---

For the past 6 months or so some of my co-workers at Red Hat have been working on a language server for XML. This has been a [heavily requested language server](https://github.com/Microsoft/vscode/issues/1440) with a few attempts, but all of them only had basics features. As someone who is really fascinated with language servers its awesome to see another new one come out, especially one that I got to watch grow from inception. It just released on the [VSCode marketplace](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-xml) a week or two ago and its really exciting to see the impact it has on writing XML.

The current features are:
* Syntax error reporting
* General code completion
* Auto-close tags
* Symbol highlighting
* Document folding
* Document symbols and outline
* Renaming support
* Document Formatting
* XSD validation
* XSD based hover
* XSD based code completion
* Code actions

![Features gif](https://user-images.githubusercontent.com/148698/45977901-df208a80-c018-11e8-85ec-71c70ba8a5ca.gif)

It is still being actively developed and if you would like to check it out here's a link: https://github.com/angelozerr/lsp4xml
LaravelのModelからSQLを直接実行する方法
Tags: laravel, sql
Published: 2018-10-04 05:09:49

---
title: LaravelのModelからSQLを直接実行する方法
published: true
description: 
tags: laravel,sql
canonical_url: https://crieit.net/posts/Laravel-Model-SQL
---

LaravelでSQLを直接実行する方法というのは、一般的には下記のようにDBのFacadeを使用する方法になる。

```php
DB::statement($query);
```

Laravelだと上記で問題ないのだが、EloquentはLaravelでなくても使用できるので、プロジェクトに個別にEloquentを入れている場合はDBファザードが無いため上記が実行できない。

その場合、モデル自体からDBファザードと同じものを取得する方法があるためそれで同じ様にしてSQLを実行することができる。

まず適当にモデルのインスタンスを作成する。

```php
$user = new User;
```

あとは同様。

```php
$user->getConnection()->statement($query);
```
Did you know that Oracle owns the trademark to Javascript?
Tags: discuss, javascript, history
Published: 2018-10-04 05:00:21

---
title: Did you know that Oracle owns the trademark to Javascript?
published: true
description: Did you know that Oracle owns the trademark to Javascript? 
tags: discuss, javascript, history
cover_image: https://d33wubrfki0l68.cloudfront.net/871521ecc315b651de02bb4b69804ae2dfb34f12/9281b/images/blog/javascript-logo.png
---

I have used Javascript for over 20 years, but I was unaware that [Oracle owned the trademark to Javascript](http://tsdr.uspto.gov/#caseNumber=75026640&caseType=SERIAL_NO&searchType=statusSearch). If anything, I would have guessed that Mozilla owned it.

Oracle inherited the trademark after they bought Sun Microsystems (I didn't even know Sun had trademarked Javascript!). 

I came across a Reddit post where [Apple took down an App](https://www.reddit.com/r/javascript/comments/8d0bg2/oracle_owns_javascript_so_apple_is_taking_down_my/) because the AppStore displayed the word JAVASCRIPT without authorization from Oracle.

I wonder if they will continue to enforce it in the future given that it is such a ubiquitous term. Many have suggested that we should refer to it as ES going forward and call it a day. I'm not sure how I feel about that.

Did you know about this? What are your thoughts?

---

{% link https://dev.to/theoutlander/how-to-improve-your-debugging-skills-3j5p %}
Background task requirement? 
Tags: question, asynchronous, background
Published: 2018-10-04 04:06:58

---
title: Background task requirement? 
published: true
description: Background task
tags: question, asynchronous, background
---
I have a requirement where I need to execute the shell script background. For example, The user will click on the button in the browser, this action will invoke a shell script, as soon as this shell script gets executed, there should be asynchronous message notified to the user in javascript. How can I do that?
Why software shouldn't be free
Tags: software, philosophy
Published: 2018-10-04 03:58:02

---
title: Why software shouldn't be free
published: true
description: My take on why free software is creating a bad habit among consumers and destroying the maker culture
tags: software,philosophy
---

![cover](https://s3.us-east-2.amazonaws.com/devletters/covers/money.jpeg)

> First posted on [Dev Letters](https://devletters.com/letters/software-shouldnt-be-free/)

People have really a hard-time paying for software, online courses, digital subscriptions, and other similar online stuff. This really saddens me.

We have reached this point in our civilization where software (or any code-backed product) are commonplace like any physical goods. So why the discrimination?

I will tell you why.

People know that software, songs, courses etc can be easily mass distributed. That is, if you do make a software or song, you can almost distribute it for the same cost to 10s or millions of people. There is very little overhead.

And that is partly right. Maybe that’s why people don’t want to pay for software because they think a song/software developer has an unfair advantage. They are essentially just making copies of the code (which is free unlike physical photocopies) and earning sweet 100% profit from it.

Or maybe there is another reason. We have become so used to consuming free services from the “Silicon Valley” backed behemoths that we feel paying for a software is stupid on our part.

Think about it. All the popular online things you use, Facebook, Gmail, OneNote, Youtube, Google Search, etc, everything is free. And this has installed the habit of free software in all of us.

But all of this comes at costs that are hidden to us. For starters, these companies feed on your data to serve you advertisements. They profile you so that they can help advertisers sell you better.

I understand this might be fine for the most of us. Right, who are we in a pool of 8 billion people.

Let Google profile me, let them know every minor detail about me, from my secret crush to my credit card numbers, it doesn’t matter because they probably won’t do anything bad to me.

And that is right. But by allowing them to do so, you are forcing a habit upon you of using free software. And that’s bad for indie software creators, those that don’t have the technology to “profile” you and just want to provide pure value for chunk change in return.

Now, this is like supporting global well-settled industries and discouraging local produce. Or in another way, allowing the already successful ones to succeed and stopping the wannabes from even getting started (all because they are charging you for 2x-1000x value that they can add).

Now I can’t be your moral guide here, you should do what you feel is right.

But next time you decide not to purchase the software just because it charges 2 cups of coffee, think again.

Maybe the value that product adds to you is nothing in comparison to the cents it charges.
How to Stay Productive at Work During Slow Periods
Tags: beginners, productivity
Published: 2018-10-04 03:43:33

---
title: How to Stay Productive at Work During Slow Periods
published: true
description: Covers some ideas on workplace productivity.
tags: #beginners,#productivity
---

Here I will be covering some ideas on how to be productive at work when you have no assigned tasks, or when you are waiting to be able to work on something.

I currently work for a marketing intelligence company, where we take tons of data, analyze it, and use it to find the best audience to market to. The nature of our company means that we get very busy for the holiday marketing push and then slow down after the holidays are over. Due to this our main development pushes are early in the year with a slowdown towards the end of the year. This leaves plenty of time to work on something like learning or refactoring some old code.

I will split this into three categories of work to be done: new code, refactoring, learning.

For new code I am primary talking about new libraries to help clean up development or make the development process easier down the road. Anyone who has worked in dev for awhile can testify that sometimes we are moving to quickly to write a reusable library for something, or perhaps we *think* we will only use a piece of code in this one spot. Look at and pick some repetitive code that would be useful to have in a centralized utility and have at it. Another option for new code is to look at new technology and see if it is useful for your situation. For me typescript was a perfect contender for our complex javascript.

The second option is refactoring existing code. Maybe you wrote the code years ago or someone else did, but either way every time you have to interact with it you groan (to yourself or out loud). This is a perfect contender of something that can be refactored. Use some prudence when choosing what to refactor based of your time and the impact it will have. 

Lastly you can use your free time to learn something new. Maybe it's a new language, some new techniques, or the latest features in your language(s) of choice. As a developer we always need to be expanding our knowledge and capabilities and taking some time to learn will be a benefit to you and your company.

So the next time you feel like you do not have anything to work on and are tempted to go to facebook, reddit, or similar (dev.to is ok ;P) consider one of the options above.
Need help understanding: Filtering an array of objects in Javascript
Tags: help, javascript, arrays, objects
Published: 2018-10-04 02:54:17

---
title: Need help understanding: Filtering an array of objects in Javascript
published: true
description: 
tags: help, javascript, arrays, objects
---

I am still trying to wrap my head around filtering an array of objects in Javascript; spent a couple of hours figuring this out.

I have this array of objects being returned to me from my backend. Inside each object, there is a key that has an array of objects as its value. AND inside this array, there's another array of objects, with another array... Yeah it gets pretty confusing.


So something like this:

```
{
menuEntities: Array(1)
0:
categoryEntities: Array(2)

0:
categoryId: 1
categoryName: "Main"
menuItemEntities: Array(1)
0: {customisableItemEntities: Array(0), description: "Full of delicious beef", enabled: true, foodItemEntities: Array(0), imagePath: "", menuItemName: "Burger"}
length: 1
__proto__: Array(0)
__proto__: Object


1: {categoryId: 2, categoryName: "Drinks", menuItemEntities: Array(1)}
length: 2
__proto__: Array(0)
isSelected: true
menuId: 1
menuName: "Menu 1"
__proto__: Object
length: 1
__proto__: Array(0)
}
```

What I wanted to do was build a filter function to return true if my input text includes a particular menuItemName. For example, type in burger into my input field and all the restaurants that contain burger would show up in my search results.

I came across this post on [Stack Overflow](https://stackoverflow.com/questions/45575043/filtering-array-of-objects-by-searching-nested-object-properties) that suggests to use [some](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some) 

After a bit of tinkering, I got this:

```
      this.sortedRestaurants = this.sortedRestaurants.filter(function(
        restaurant
      ) {
        if (_.isEmpty(restaurant.menuEntities) == false) {
          return restaurant.menuEntities[0].categoryEntities.some(category =>
            category.menuItemEntities.some(menuItemEntity =>
              menuItemEntity.menuItemName
                .toLowerCase()
                .includes(val.toLowerCase())
            )
          );
        }
      });
```

And that works for the current use case! 

But I don't understand why when I tried forEach initially, this didn't work: 

```
this.sortedRestaurants = this.sortedRestaurants.filter(function(
        restaurant
      ) {
        if (_.isEmpty(restaurant.menuEntities) == false) {
          return restaurant.menuEntities[0].categoryEntities.forEach(e => {
            e.menuItemEntities.forEach(menuItemEntity => {
              menuItemEntity.menuItemName
                .toLowerCase()
                .includes(val.toLowerCase());
            });
          });


        }
      });
```

To me, wouldn't includes still return a true or false value for the case of the forEach function..?

How would you guys write this function better too?
VirtualBox: How To Fix Failure In Starting VM (On Manjaro Linux)
Tags: virtualbox, vm, manjaro, archlinux
Published: 2018-10-04 02:47:47

---
title: VirtualBox: How To Fix Failure In Starting VM (On Manjaro Linux)
published: true
description: This post shows how to fix failure in starting vm (on Manjaro Linux).
tags: virtualbox, vm, manjaro, archlinux

---

## Intro

[Manjaro Linux](https://manjaro.org/) is one of Linux distros based on Arch Linux.
This is my favorite one because of its flexible user interface and powerful package management.

I have failed in running a virtual machine using [VirtualBox](https://www.virtualbox.org/), however, not few times.
This has been found to be simply because of my way to install VirtualBox.
Thus I decided to write and record how to fix it in order to escape from failing again.

\* *note*: The official document is [here](https://wiki.manjaro.org/index.php?title=Virtualbox#Install_VirtualBox).

## Problem

An error occurs when trying to run a virtual machine:

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

Error messages #1:

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

Error messages #2:

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

It says:

* "Kernel driver not installed (rc=-1908)"
* "VERR_VM_DRIVER_NOT_INSTALLED"
* "The VirtualBox Linux kernel driver (vboxdrv) is either not loaded or there is a permission problem with /dev/vboxdrv."

But, to my confusion, there is no '`/sbin/vboxconfig`' in my Manjaro machine.
I know now this is a problem that some modules in `/lib/modules/extramodules-[kernel version]-MANJARO/` such as `vboxdrv` and `vboxpci` are missing.

## Solution

#### Preparation

1. Get kernel version

For example, use `uname -r` command:

```
$ uname -r
4.14.71-1-MANJARO
```

#### Procedure

1. Run Pamac installer.

1. Search "virtualbox".

1. Select "Oracle VM VirtualBox (virtualbox)" and install it.

    ![](https://thepracticaldev.s3.amazonaws.com/i/x0vkfru7krmf36fzodjo.jpg)

1. When the below modal opens, select **NOT** "virtualbox-host-modules" **BUT** "linux[kernel version]-virtualbox-host-modules":

    **NOT**:

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

    **BUT**:
    (The version is up to the host machine.)

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

1. Run `vboxreload` command if there is still an error.

```shell-session
$ sudo vboxreload 
Loading modules: vboxnetadp vboxnetflt vboxpci vboxdrv 
```

## Outro

Thank you very much for your reading.
I'm happy if this post helps someone who has the same problem in some way : )
How to fix Redshift in Manjaro Linux i3
Tags: manjaro, troubleshooting, redshift, i3
Published: 2018-10-04 14:09:37

---
title: How to fix Redshift in Manjaro Linux i3
published: true
tags: [manjaro, troubleshooting, redshift, i3]
canonical_url: https://lobotuerto.com/blog/how-to-fix-redshift-in-manjaro-linux-i3/
cover_image: https://thepracticaldev.s3.amazonaws.com/i/iib2dx7xwb34n44b174l.jpg
---

[Redshift](https://github.com/jonls/redshift) is a very cool program that can help in keeping your eyesight healthy — it’ll tint your screen red a little bit when the night approaches.

This puts less strain in your eyes.

# The problem

Everything was working good, I had the `redshift` package installed and had setup it to start automatically on my `~/.i3/config`.

It was just after an update that I started to see this when trying to run it:

```
Trying location provider `geoclue2'...
Using provider `geoclue2'.
Using method `randr'.
Waiting for initial location to become available...
Unable to start GeoClue client:
 GDBus.Error:org.freedesktop.DBus.Error.NoReply:
 Message recipient disconnected from message bus without replying.
Unable to get location from provider.
```

And seeing this dialog when trying to start `redshift-gtk`:

![redshift-gtk error](https://lobotuerto.com/blog/how-to-fix-redshift-in-manjaro-linux-i3/redshift-gtk-error.png)

It never worked after that, even with the newest versions for `geoclue2` and `redshift`:

```
pacman -Q geoclue2 redshift
geoclue2 2.4.12-1
redshift 1.12-2
```

# The solution

After doing some sleuthing, I found a solution.

Edit your `/etc/geoclue/geoclue.conf` file, and add this at the end:

```
# ...
[redshift]
allowed=true
system=false
users=
```

To start **Redshift** automatically, add these lines to your `~/.i3/config`:

```
exec --no-startup-id /usr/lib/geoclue-2.0/demos/agent
exec --no-startup-id redshift-gtk
```

That’s it!

# Links

- [Redshift](https://github.com/jonls/redshift) — Redshift adjusts the color temperature of your screen according to your surroundings.
- [ArchWiki – Redshift](https://wiki.archlinux.org/index.php/Redshift)
- [redshift disallowed from using GeoClue](https://github.com/jonls/redshift/issues/636)