teleren/devto huggingface dataset:
Docker Compose - servidor FTP
Tags: ftp, docker, linux, storage
Published: 2021-03-27 13:45:52

Oi pessoal vindo com mais um script de docker-compose que eu fiz pra compartilhar e salvar alguns arquivos aqui em casa com um pc antigo que tava de canto aqui, então se você tem um pczinho aí que não tá fazendo nada e quer usar de backup ou só pra algumas coisas pra não encher o disco sem depender de internet acho uma boa.

Eu usei o proftpd foi o serviço ftp mais fácil e simples que achei tinha o vsftpd também mas era um pouco mais complexo.

``` yaml
version: '3.7'

services:
  ftp-container:
    image: kibatic/proftpd
    scale: 3
    network_mode: "host"
    restart: always
    environment:
      FTP_LIST: "usuario:senha"
      USERADD_OPTIONS: "-o --gid 33 --uid 33"
    volumes:
      - "./files:/home/casa"
```

Agora vou explicar algumas configurações que podem ser interessantes vocês mexerem e adaptarem para seu uso:

- **scale -** Nesse script tá usando 3 réplicas mas você usar quantas preferir ou nem mesmo usar, nesse caso é interessante porque se um cair por algum motivo um cair tem mais 2 que podem ser usados.

- **network_mode -** É para o container usando a network do computador hospedeiro no caso o pc que está rodando o FTP, é usado para expor na rede local o serviço então você pode acessar pelo celular ou qualquer outro dispositivo que estiver na sua rede com essa configuração.

- **FTP_LIST -** Aqui é colocado o usuário e a senha dessa forma usuário:senha, pode ser colocado mais de um basta separar cada conta com uma ; detalhe que a senha não pode ter caracteres especiais.

- **USERADD_OPTIONS -** Seta o grupo dos usuários criados, desse jeito que está cria e lê arquivos normalmente.

- **volumes -** A primeira parte é só a pasta que vai ser compartilhada com o FTP, então os arquivos vão pra ela, recomendo criar uma pasta vazia na pasta do script e colocar o nome dela aí, a segunda parte é a pasta que os arquivos vão ficar dentro do container isso é indiferente pode ser qualquer nome.

E tchau qualquer dúvida só chamar 👋
Forced Switching to Adwaita Light Theme
Tags: linux, flatpak, todayilearned
Published: 2021-03-27 13:43:58

Just another short story ...

I love theme Adwaita theme, especially the dark one. So, I always have it enabled by using [GNOME Tweaks](https://gitlab.gnome.org/GNOME/gnome-tweaks). Unfortunately, many applications do not seem to be worked pretty well in dark theme. So, I wanted to know how to run certain [Flatpak](https://flatpak.org/) application in light theme without me changing the global default theme.

In my case, **WPS Office** has a poor display of the font search dropdown list; black text on dark background will never be good. After googling for a while, I got to know that WPS Office was installed at `/var/lib/flatpak/app/com.wps.Office/`. It seemed like all Flatpak applications will be installed either at
- `/var/lib/flatpak/app/` for system-wide installation; or
- `~/.local/share/flatpak/app` for per-user installation.

Exploring the directory structure, I have realised that somehow WPS Office has included its own theme directory at `/var/lib/flatpak/app/com.wps.Office/x86_64/stable/active/files/share/themes/`.

```bash
$ cd /var/lib/flatpak/app/com.wps.Office/x86_64/stable/active/files/share/themes/
$ ls
Adwaita  Adwaita-dark  Default  Emacs  HighContrast  Raleigh
```

I think, this is not common, at least not for most applications. Then, I idly experimented to remove the `Adwaita-dark` folder, so that WPS Office cannot find it anymore. Or at least just to rename it;

```bash
$ sudo mv Adwaita-dark/ Adwaita-dark-bk/
$ sudo mv Adwaita/ Adwaita-dark/
```

Fortunately, it seemed to be worked. Yay! I have managed to force WPS Office to use the light theme instead! Although I cannot explain it.

**For GTK applications,** we can make sure to set the `GTK_THEME` environment variable. For example, for the [Color Picker](https://gitlab.gnome.org/World/gcolor3) application:

```bash
$ sudo flatpak override --env=GTK_THEME=Adwaita nl.hjdskes.gcolor3
```

To unset, just need to set the value to empty:

```bash
$ sudo flatpak override --env=GTK_THEME= nl.hjdskes.gcolor3
```

**For Qt applications,** set the `QT_STYLE_OVERRIDE` variable instead.

You deserve a good day, bye!
Code Smell 64 - Inappropriate Intimacy
Tags: codenewbie, codesmell, webdev, oop
Published: 2021-03-27 13:37:50

Code Smell 64 - Inappropriate Intimacy

*Two classes entangled in love.

# Problems

- Coupling

- Bad Responsibilities Assignments
 
- Bad Cohesion

- Class Interfaces too Public

- Maintainability

- Extensibility

# Solutions

1. Refactor

2. Merge

3. [Replace Hierarchy With Delegation](https://refactoring.com/catalog/replaceSuperclassWithDelegate.html).

# Sample Code

## Wrong

{% gist https://gist.github.com/mcsee/5f9206a8a131b4dcaaa2fd64562c9eca %}

## Right

{% gist https://gist.github.com/mcsee/f94d51d327592ca511b625bac37cb441 %}

# Detection

Some linters graph class relations and protocol dependency. Analyzing the collaboration graph we can infer rules and hints.

# Tags

- Coupling

# Conclusion

It two classes are too related and don't talk much to others we might need to split, merge or refactor them,
Classes should know as little about each other as possible. 

# Relations

{% post https://dev.to/mcsee/code-smell-63-feature-envy-502f %}

# More info

[C2 Wiki](https://wiki.c2.com/?InappropriateIntimacy)

[Refactoring Guru](https://refactoring.guru/es/smells/inappropriate-intimacy)

[Codebuzz](https://www.thecodebuzz.com/awesome-code-inappropriate-intimacy-code-smell-resolution/)
 
# Credits

Photo by <a href="https://unsplash.com/@beccatapert">Becca Tapert</a> on <a href="https://unsplash.com/s/photos/intimate">Unsplash</a>  

* * *

> No matter how slow you are writing clean code, you will always be slower if you make a mess.

_Robert Martin_
Make changes to node_modules files with patch-package
Tags: productivity, javascript, reactnative
Published: 2021-03-27 13:20:38

[Library Link](https://github.com/ds300/patch-package)

**a) Install library**

- 
using yarn:

```
yarn add patch-package postinstall-postinstall --dev
```
- 
or using npm:

```
npm i patch-package --save-dev
```

**b) In `package.json` add**

```
"scripts": {
   ...
   "postinstall": "patch-package"
   }
```

**c) Usage**
First make changes to the files of a particular package in your node_modules folder, then run
```
yarn patch-package package-name
```
_or_
```
npx patch-package package-name
```

_(where **package-name** matches the name of the package you made changes to for example react-native, react-native-push-notification etc...)_

- **Nested packages**
If you are trying to patch a package at, e.g. node_modules/package/node_modules/another-package you can just put a / between the package names:

```
npx patch-package package/another-package
```
It works with scoped packages too

```
npx patch-package @my/package/@my/other-package
```

**d) Finally**
A folder will be created in your project named as `patches` which will include all the library patches you made.
Then you can push the code to your git repository.
Whenever `yarn install` or `npm install` is run all the patches will stay.
Run Java OpenGL (JOGL) on Linux
Tags: linux, jogl, java, debian
Published: 2021-03-27 13:04:54

At first, make sure you have java installed on your system. To check that open Terminal (ctrl + alt + t) and run `java -version` 

![OpenJDK Linux](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jkylsav1h693l4rccnd9.png)

If you don't see any version then you have to install OpenJDK on your system. To do that run these two commands 

`sudo apt-get install openjdk-11-jre`
`sudo apt-get install openjdk-11-jdk`

and check your `java -version` again. 

Once you successfully install java on your system then you have to install JOGL. To do that run this command on terminal.

`sudo apt-get install libjogl2-java` 

After installing JOGL [install eclipse](https://www.eclipse.org/downloads/)

Now Open Eclipse and **Create a Java project** and give your project a name.

![Create a Java Project](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w5ubla79vy16hbpnsafs.png)
You can also find it under File > New > Java Project

After giving a nice name in your project Click **Next** 
![Project Name](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qi342rejtskv3ku9oit5.png)

From the **Libraries** select **Classpath** and click **Add External JARs** ![Add External JARs](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/clomz3pv1w0jjodr2586.png)
 

Navigate to `/usr/share/java/` and choose these two files `jogl2.jar` and `gluegen2-rt.jar`.If you import correctly then You should see those file's paths under **Classpath**. Now click **Finish** (You can skip creating Module).
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bdpt5gb93m9k0vveczr5.png)
 
Now expand your project from the sidebar and right-click on **src** then **Create a new class** 

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jik5bvyjdnmifs39cleb.png)
 

If everything is done correctly a Canvas window will pop up after running your JOGL code!

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r18swcx6f6ccuncgnz2r.png)
Import Project to CodeSanbox.io via GitHub Action
Tags: codesandboxio, angular, github, pullrequest
Published: 2021-03-27 12:58:14

Hello Everyone!

In this post I am going to show you how I was able to generate a link to automatically import your current project to [CodeSandbox](https://codesandbox.io/).

---
## :fax: Import
According to its documentation, CodeSandbox has a way to automatically import a project ([templates](https://codesandbox.io/docs/templates)) from a GitHub repository to its online IDE by simply modifying the GitHub URL of the repository.

> Using GitHubBox.com
An easy way to import a repo to CodeSandbox via URL is with GitHubBox.com. Append 'box' to your github.com URL in between 'hub' and '.com' and it will redirect to CodeSandbox.

Here's an example:

Change the GitHub URL: https://github.com/reduxjs/redux/tree/master/examples/todomvc.

To: https://githubbox.com/reduxjs/redux/tree/master/examples/todomvc.

The result is we take the last part of the url (everything after github.com) and use it in our importer at codesandbox.io/s/github/, adding the repo to CodeSandbox. 
## Github Action

Hence, I created a Github Action that will concatenate the GithubBox.com url to the path of the branch for each newly-created pull request. 

## :books: Reason

Generating a url to an online playground for each pull request created can enhance the review process by:
- instantaneously generating a sandbox for each branch, therefore shortening the visual feedback loop

- providing the ability to play around with the code and provide better code suggestions  
## Workflow
Here's the code of the workflow file you need to add to your project.
```yaml
"on":
  - pull_request
jobs:
  annotate_pull_request:
    runs-on: ubuntu-latest
    name: perform annotation
    steps:
      - name: annotation action step
        id: annotation
        uses: kherin/pr-comment-action@v1.0.1
        with:
          annotation-url: "https://githubbox.com/"
          token: ${{ secrets.GITHUB_TOKEN }}

```
## :briefcase: Usage
### PR Comment
![Pull Request Comment](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zjqiw5gsr2n2145eiorq.png)

### Online Playground
![Online Playground](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2cd6mtl64lfuyghnz9di.png)

## :sparkles: GitHub Action
The source code can be found here:
{% github kherin/pr-comment-action %}

### :wave: Goodbye World

## References

- [https://codesandbox.io/docs/importing](https://codesandbox.io/docs/importing)

- [https://docs.github.com/en/actions/creating-actions/creating-a-javascript-action](https://docs.github.com/en/actions/creating-actions/creating-a-javascript-action)
Questioning old habbits
Tags: android, contacts
Published: 2021-03-27 12:31:16

In this short piece I cover a topic that may sound, well, boring. It's about reading contatcs on Android. But I am not interested in permissions or how to retrieve them most efficently. It's more like getting them at all. Through the years I advocated a rather simple algorithm:

```kotlin
val mainQueryProjection = arrayOf(Contacts._ID)
val mainQuerySelection = """
  ${Contacts.IN_VISIBLE_GROUP} = ? AND 
  ${Contacts.DISPLAY_NAME} IS ?
""".cleanup()
val mainQuerySelectionArgs = arrayOf("1", "a name")
contentResolver.query(
  Contacts.CONTENT_URI,
  mainQueryProjection,
  mainQuerySelection, mainQuerySelectionArgs, null
)?.run {
  if (moveToNext()) {
    val contactId = getString(0)
    println("===> found ($contactId)")
  } else {
    println("a name not found")
  }
  close()
}
```

To find a contact this way, two conditions must be met:

- `Contacts.DISPLAY_NAME` must be `a name`
- `Contacts.IN_VISIBLE_GROUP` must be `1`

[According to the docs](https://developer.android.com/reference/android/provider/ContactsContract.Contacts), `Contacts.IN_VISIBLE_GROUP` is an

> indicator of whether this contact is supposed to be visible
> in the UI. "1" if the contact has at least one raw contact that
> belongs to a visible group; "0" otherwise.

This has been working well through the years and it actually is still working these days. Unless I run that code on my Lenovo Duet. For whatever reason my contacts seem to not be in a visible group. Certainly, in both cases the same Google account had been used.

Now, the check for being visible seemed a good idea, because there had always been contacts that consisted only of an email address. Especially in the early days (when performance was a concern) it was a good idea to filter out unneeded results before the app processed the remaining ones. Today performance is no longer an issue. Still, shouldn't we try to make our apps as efficient as we can?

Certainly.

There's a Google doc called [Retrieve a list of contacts](https://developer.android.com/training/contacts-provider/retrieve-names).

It shows a pragmatic resolutuion:

![Screenshot showing a portion of a webpage](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fd4rihxy12rq3xt84ivj.png)
 
So the idea is: If there's a name let's process the contact. Depending on what your app wants to do you can add additional criteria.

As I have no idea what causes the different behavior I will change my app accordingly. Have you encountered this, too? How did you solve it? Please share your thoughts in the comments.
Running Spring Boot Test via docker
Tags: programming, testing, java, docker
Published: 2021-03-27 12:29:53

Spring boot becoming a common defacto for writing micro-services in the Java ecosystem. We have a lot of frameworks and options to write unit and integration tests are available. Below are the few resources, that I have looked upon in the past to improve my unit testing skills

* [Test Containers](https://www.sivalabs.in/2020/02/spring-boot-integration-testing-using-testcontainers-starter) - By Siva
* [Testing Spring Boot](https://www.baeldung.com/spring-boot-testing)- By Baeldung

We are not going to discuss in detail writing unit-testing. But setting up the necessary things that enable us to independently write end-to-end tests for our spring boot applications. 


## Assumption
Our application is going to be a simple backend service connected with a database. In our case, let's assume it is Postgres. Based on your application architecture the same template can be changed. Below the types of tests we have 
* Controller Level Tests
* Service Level Tests
* Core Business Logic

Most of the time we might miss validating our repository/data layer via tests under the assumption all will be fine. But if we do it, it is always good to ensure we don't end up with weird data issues in production. As I mentioned above `TestContainers` are a good way to write tests including embedded databases. Cored database schema migrations are integrated into the application bootup. We can use tools like `flyway` or `liquibase` to do this. 


## Settings
For our application, we should have the below properties `src/test/java/resource/application.properties` for effective testing

{% gist https://gist.github.com/balaaagi/a1e02965015fab903a66b94e9d826193 %} 



We have passed our values to be env variables. You can refer [here](https://balaaagi.in/post/envsinspringboot/)

### Base Image

Create a base image for your projects and push it to some registry. Either docker hub or anything which can be accessed. Please keep this base image minimal without any confidential details of your project. Let's assume we have a base image named `orgname/base-springboot`

{% gist https://gist.github.com/balaaagi/bd57215588177be2cec52960552d5c25 %} 


We would need a `docker-compose.yml` file to have this setup working end to end. Below is a docker-compose that can be used for reference

{% gist https://gist.github.com/balaaagi/bcc4b75527d566b42128fdbf479cd790 %} 


## How to Run the tests?

Below is the simple command that can be used to run the tests

`docker-compose up --abort-on-container-exit --exit-code-from application_under_test`

What the above command does is spins the DB, application and runs the tests. If a test failed it gets exit. The same command can be used in CI/CD pipelines also. To fasten the process the base image should be built with all common dependencies.
The Laptop Paradox
Tags: programming, discuss
Published: 2021-03-27 12:17:49

**Disclaimer:**  
1. This post is targeted to the audience who are fresh grads/students/Rookie Devs.
2. The configuration shared here is modest, It's not the best.

Ever wondered what is the better laptop for programming/Education, Ok is there a set of metrics for choosing a laptop!? How do we know one is superior to others!?

Let's say we have a budget of 1000USD

Moderate/Typical laptop requirements:

```
RAM: 8GB
MEMORY: 512 GB HDD
GRAPHICS: AMD Radeon Pro 5500M with 4GB of GDDR6 memory/NVIDIA GeForce RTX 2060
CPU Cores: 6
Display: Retina
Battery life: 6-8 hours
```

All the above requirements should fit in 80 % of your budget i.e. 800 USD, Sometimes we might need a higher-end graphics card or more CPU cores or more RAM, These are niche cases like where there might be a requirement to work on Intense video editing or running parallel ML models or running android studios. Depending on use cases we have to make a tradeoff.

If you have some vision issues like me, you would like to consider buying a monitor, keyboard and mouse. Then the budget for the laptop should be trimmed to 70 % and these peripherals should be given 15 % of your budgets.

The next one is the important part, with the leftover budget, you might need to buy some software or course to enhance your productivity. For example, If you're a programmer, to understand certain concepts(beginner/intermediate/advanced) you might need to purchase a course or tool or attend conferences. If you're well versed in a certain topic, you may consider doing a certification, If you're a pro you can help open source.

**Final Thoughts:**
If you're considering buying a laptop for an education/learning/programming purpose, have these above-discussed thoughts in mind, At the end of the day your laptop will never say I won't run the program, you just need to make it work that's why we have the God **The Internet**
Daily Developer Jokes - Saturday, Mar 27, 2021
Tags: jokes, dailydeveloperjokes
Published: 2021-03-27 12:00:18

---
title: "Daily Developer Jokes - Saturday, Mar 27, 2021"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
cover_image: "https://private.xtrp.io/projects/DailyDeveloperJokes/thumbnail_generator/?date=Saturday%2C%20Mar%2027%2C%202021"
published: true
tags: #jokes, #dailydeveloperjokes
---

Generated by Daily Developer Jokes, a project by [Fred Adams](https://xtrp.io/) ([@xtrp](https://dev.to/xtrp) on DEV)

___Read about Daily Developer Jokes on [this blog post](https://xtrp.io/blog/2020/01/12/daily-jokes-bot-release/), and check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/).___
### Today's Joke is...
![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e1258b2d77d4.png)

---
*Have a joke idea for a future post? Email ___[xtrp@xtrp.io](mailto:xtrp@xtrp.io)___ with your suggestions!*

*This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit.*

<!-- 
Joke text:
___Q:___ What's the second movie about a database engineer called?

___A:___ The SQL.
 -->
Key Kubernetes patterns for 2020 
Published: 2021-03-27 11:32:29

1. Expect a rising tide of "Kubernetes-local" programming: Think "not just containerized programming that turns out to be deployable in Kubernetes, yet additionally programming that knows about and ready to offer exceptional benefit when sent in Kubernetes,".

"Programming that is delivered and marked as 'Kubernetes-first' will be progressively normal, conceivably showing as custom assets definitions or Kubernetes Operators."


2. Security will keep on being a prominent center: "As the selection of Kubernetes and sending of holder based applications underway speed up to a lot higher volumes than we've seen to date, we can anticipate that more security incidents should happen," says Rani Osnat, VP of technique at Aqua Security. "The majority of those will be brought about by the information hole around what comprises secure design, and absence of appropriate security tooling." 

It isn't so much that Kubernetes has characteristic security issues, as such. Indeed, there's a noticeable obligation to security locally. It basically accompanies some new contemplations and procedures for overseeing chances, as troublemakers are improving at spotting weaknesses. 

Other key patterns include: 

1. An advance toward alliance 

2. A scramble for talent

3. Endeavors to decrease Kubernetes' asset utilization. 

For full detail on these patterns, obtain [Kubernetes certifications] (https://intellipaat.com/kubernetes-training-course/).
The ultimate "Glitch free JS" library has lost weight!
Tags: tooling, javascript, typescript
Published: 2021-03-27 11:26:16

For the last year [js-coroutines](http://js-coroutines.com) has been enabling me and others to split up glitchy long-running processes over multiple frames to keep our sites and apps running silky smooth and also powering some nice animations and ways of controlling effects and games.  With this library, you can filter/sort or run your own complicated calculations on huge volumes of data without breaking the animations or scrolling of your site.  You do this without Worker threads because passing data to and from them also can cause glitches.

I thought it was time to put the library on a diet and have managed to shrink it by around 30%.  The library is super easy to use with full API documentation and has both imperative and functional programming models supported (including the addition of `compose` in the latest release).

For an example of what you can do with [js-coroutines](http://js-coroutines.com) check out the demos below:

*Smooth animation with heavy weight processing*

{% codesandbox etyft %}

[*A cool little game*](https://codesandbox.io/s/friendly-frog-iuvi6)
Hello, we have sad and happy news! We started making the game from scratch.
Tags: unity3d, gamedev, indiegame, screenshotsaturday
Published: 2021-03-27 11:26:12

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w1dfsj0nbxuvrogf8vxb.gif)


Read the reason for this in our article: store.steampowered.com/news/app/1213020/view/3028081693987661088