teleren/devto huggingface dataset:
Lazy Beans in Spring
Tags: lazy, spring, java, beans
Published: 2020-10-05 02:48:27

Beans are created on startup when the application context is created (eagerly). But, lazy beans are created the first time they are used. Its use is not recommended.

```java
@Lazy
@Component("jdbcRepository")
public class JdbcRepositoryImpl implements AppRepository {
	...
}
```

When we put the @Lazy annotation over the @Configuration class, all the methods with @Bean annotation should be loaded lazily.
CUSTOMIZING (COLORS) DJANGO ADMIN PANEL
Tags: django, webdev, python, writing
Published: 2020-10-05 02:45:11

In this blog we’ll see how to change the default Django admin panel colors. we have always seen Django admin with a standard greenish-blue color but we can customize Django admin theme and change its color because everything can be edited and customized which is one of the coolest parts of this great framework.

Let’s dive into how to do that, The main question here arises, why would someone wants to change the color scheme of the admin aside from the obvious reason that they like some other color better.

There are a couple of different ways of achieving that, but for now we will achieve this using third-party package. 

Using A Package:

There is this package available which we can use django-admin-interface to change the color of admin.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/w72y4k6m6qqyfowa16ts.png)

This provides enough customization for a regular user.

When using this approach:

It is easy to Implement and change the color whenever we want dynamically without having to change the code.
It can change solid colors. Gradients or other custom changes are not available.
These changes of color are saved on the DB so on a fresh DB every time it comes with default colors.

Lets Do this

```python
#install package
pip install django-admin-interface
```

Add admin_interface, flat_responsive, flat and colorfield to settings. INSTALLED_APPS
before django.contrib.admin

```python
 INSTALLED_APPS = [ 
#... 
'admin_interface', 
'flat_responsive', # only if django version < 2.0 
'flat', # only if django version < 1.9 
'colorfield', 
'django.contrib.admin', 
#... ] 
X_FRAME_OPTIONS='SAMEORIGIN' # only if django version >= 3.0
```

```shell
python manage.py migrate
python manage.py collectstatic
```

Restart your application server and now you should be able to see a new color scheme added by the package. If you want to customize it further go to your admin and look for “themes” app and do customizations there.

http://localhost:8000/admin/admin_interface/theme/

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

A couple of favorite customizations there apart from colors are:

Use dropdown for your list_filter
Add/Change Favicon and logo for admin
Rounded corners for a slight step towards “modern” design.


Comment down if you like it 👍.also Comment down if you have any queries.

Thank you.
Autowiring in Spring
Tags: spring, java, awtowired, qualifier
Published: 2020-10-05 01:42:19

#Constructor Injection#

```java
	@Autowired
	public AppServiceImpl(AppRepository appRepository) {
		this.appRepository = appRepository;
	}
```

#Method Injection#

```java
	@Autowired
	public setRepository(AppRepository appRepository) {
		this.appRepository = appRepository;
	}
```

#Field Injection#
Not recommended. Hard to unit test.

```java
	@Autowired
	private AppRepository appRepository;
```

#Optional dependencies#
Only inject if dependency exists:

```java
	@Autowired(required=false)
	AppService appService;

	public void method() {
	  if(appService != null) {
	    ...
	  }
	}
```

Using Optional:
```java
	@Autowired
	Optional<AppService> appService;

	public void method() {
	  appService.ifPresent(s -> {
	    ...
	  });
	}
```

#Qualifier Annotation#
When component names are not specified, they are auto-generated. When specified, they allow disambiguation if more than one bean class implements the same interface.

```java
@Component
public class AppServiceImpl implements AppService {
	@Autowired
	public AppServiceImpl(@Qualifier("jdbcRepository") AppRepository appRepository) {
		this.appRepository = appRepository;
	}
}

@Component("jdbcRepository")
public class JdbcRepositoryImpl implements AppRepository {
	...
}
```
Como criar um projeto React Native com TypeScript
Published: 2020-10-05 01:33:57

Faaaala Dev's, no meu primeiro post vou ensinar a vocês a como criar um projeto React Native usando o TypeScript, já sabemos que o TS é o "amigo inteligente" do JavaScript, por isso ele vai ser cada vez mais usado no mercado já que as tipagens são de extrema importância na segurança de resposta e na manutenção do código. Já imaginou se o seu código começa a ficar muito grande e daí, no meio do caminho aparece aquele indesejável `undefined`? Isso vai te frustar bastante 😅, mas não se preocupe nós vamos mudando aos poucos tudo para o TypeScript 😎.

Lembrando que não é para *destruirmos o JavaScript de uma vez por todas*, até porque ao final tudo é `bundle`, ou seja, JavaScript.

#### Vamos definir o diretório

Eu particularmente gosto de deixar meus projetos em documentos, então bora navegar até lá.

**No terminal**, garanta que você esteje na raíz do usuário padrão do sistema.

```
$ cd ~
```

Agora que você está no usuário, navegue até `documentos`, para isso vamos usar o `cd` que significa *change directory*.

```
$ cd Documents/
```

Beleza, vamos criar uma pasta para o nosso projeto, usaremos o `mkdir` que significa *make directory*.

```
$ mkdir app
``` 

### ⚠️Atenção aqui!⚠️

De acordo com as últimas recomendações do pessoal do React não é legal ter o **React Native CLI** instalada globalmente no sistema, então vamos removê-los.

** Desinstalar **
```
$ npm uninstall -g react-native-cli

  ou

$ yarn remove -g react-native-cli
```


**Finalmente** podemos usar a **cli** do **React Native** para criar um projeto usando **TypeScript**. Então bora lá ...

```
$ npx react-native init FirstAppWithReactNativeAndTS --template react-native-template-typescript 
```

Beleza Dev's espero que vocês tenham gostado desse primeiro post, fico por aqui e até a próxima.
What I worked on in September and the idea of Learning in Public
Tags: beginners
Published: 2020-10-05 01:21:56

---
title: What I worked on in September and the idea of Learning in Public
published: true
description: 
tags: beginners,
//cover_image: https://direct_url_to_image.jpg
---
A little bit ago I picked up a book written by [swyx]() ([The Coding Career Handbook](https://swyx.podia.com/coding-career-handbook/5nwsf) - it's awesome, seriously scope it out) and in one of the chapters he talks about the idea of [learning in public](https://www.swyx.io/learn-in-public/). Basically the idea is to document everything you do and don't be afraid to be wrong as long as you're trying to be correct. People notice when others are genuinely learning and are more willing to lend a hand if you're stuck or don't understand something.

There's a lot to this idea and definitely read his post about it. It's a scary thing starting out in a new field and trying to act like you belong and know what you're doing.

But you know what? It's ok if you don't know everything, you're going to be constantly learning. I remember how difficult some things in Ruby were back in my 2nd week of bootcamp, but I got over those things because I practiced and learned. I'd probably laugh at the things that were roadblocks then and I'll laugh at the things that are roadblocks now.

I need to do better about discussing the things I'm learning and this is a start to that.

#### September

September started off pretty busy, I officially started my job search and doing that made me realize how much work I had to do on my whole setup. Nothing like fear of failure to motivate you to improve.

I ended up deploying [4 projects](https://github.com/denvermullets) and wrote a few blogs about that process since it was a pain. As a beginner to deploying production websites I had to learn a ton of new terms and concepts. I still feel I ended up accepting defeat and using a 3rd party service for some of it, but it was worth it to me to get back to coding.

It also was a busy month for getting back into talks and lectures as me and some of my cohort mates ended up attending a React conference by [Geekle](https://react.geekle.us/) and then later I attended a Vue.js workshop by Frontend Masters.

I spent a little bit of time learning Express and Node.js since my previous knowledge was comically low. I wanted to make an app that let me control my Nanoleaf lights and I made good progress on that, hopefully I can finish that up in October.

September was honestly a lot of groundwork with my resume and portfolio projects, although I had a pretty active article on [how to use github as your portfolio](https://dev.to/denvermullets/how-to-use-your-github-s-profile-readme-as-a-portfolio-page-336e).

I just keep reminding myself that it's a marathon, not a race. Here's to an active October!
Just Starting my journey
Tags: html, css, javascript, python
Published: 2020-10-05 01:03:13

Greetings to all who can read this short story, I do not have much to contribute even to this fascinating world of web development, before I did not know anything about anything, I did not know how to put a hello or what html meant, I only knew what was part of a website, I always thought that web development was based only on wordpress, and I saw that people made videos saying that a website was made in a few minutes and I said, this is developing a website? How is it possible that something so complex can only be based on putting images and just typing a few lines, apply plugins and that's it? Well, I still don't know the big difference between web development and the wordpress world, I'm still trying to figure out how that part of writing code in a markup language like html, giving it color and styles with css and giving it animations and more with javascript, and get to wordpress and (eye this I see in videos) put images pay the hosting put the writings take care of the appearance changing the themes and place some plugins and that's it we have an optimized website that can be positioned and many things, this seemed pretty straightforward to me. I went to Youtube, I looked for some tutorials from some very good developers who teach a lot like Fazt, Drew Ryan, Traversy Media and several others, well I've learned from them since I have not been able to pay for a course due to lack of money. Apart from that my laptop has been burned five days ago and incidentally I was a victim of the underworld and my phone was stolen so I was left without a job and without any means to learn, sometimes I ask to borrow the laptop from my cousin and I go a little little, although my desire to learn is great. Well I extended a lot I hope to continue here and learn more and apply my knowledge for all those who wish to learn
My Sinatra Portfolio Project.
Published: 2020-10-05 00:50:38

Hey guys this is my blog post for my phase two portfolio project. I started this project off by reviewing all of my notes and reviewing all of the study group videos. After that was finished I pulled up visual studios to get started. I decided to create a web app called SpoilerAlert which is basically a website you can go to when you want to talk about the latest episodes of your favorite show with fellow fans without having to worry about spoiling it for fans who have yet to see it. I admittedly had some environmental issues to start out with I switched into this cohort from a cohort that did not use canvas so I had become accustomed to the learn ide. When I switched over to a local environment everything fell apart. I finally after many hours of struggle and research discovered my issue with the assistance of my cohort lead. I was back on track and to start the project I began by installing the corneal gem to create the skeleton of my project. I decided that my models were going to have to be users, and threads. In my application a user has many threads so from there I had the frame work set now it was time to create my database. Using rake I created a database that contained two different tables one for each of my models. With my database created it was time to fill out my views folders, nothing like some good old fashioned HTML. Having recently reviewed the course work for HTML and with the help of w3schools.com I was able to complete the task of filling out all of my views folders. All that was left was to code my routes. Writing routes was the most difficult part of this project for me even after I watched the videos and reviewed the courses it was still hard for me to understand. After a brief call with my cohort lead I had a significantly better understanding. I finished writing my routes and all there was left to do was mount my controllers in my config.ru file. one for each of my views not to mention the application controller. Finally after hours of work it was time to run my server I typed shotgun into my terminal and hit enter. The result of hours of work was an error of course so then I went into trouble shooting mode and fixed that error only to find another error waiting in its place. This went on for about 2 hours in total but after all of this it was finally time. My website was up it was running smoothly admittedly not the prettiest piece of work but she was mine. I quickly pushed my project to github and was finished.
Converting explicit into implicit configuration in Spring
Tags: annotation, spring, java, configuration
Published: 2020-10-05 00:39:00

Before (explicit bean definition)

```java
@Configuration
public class AppConfig {

	@Bean
	public AppService appService() {
		return new AppServiceImpl(appRepository());
	}

	@Bean
	public AppRepository appRepository() {
		...
	}
}
```

After (implicit configuration)

```java
@Configuration
@ComponentScan("com.services")
public class AppConfig {
}

@Component
public class AppServiceImpl implements AppService {
	@Autowired
	public AppServiceImpl(AppRepository appRepository) {
		this.appRepository = appRepository;
	}
}
```
What I wish I knew as a beginner
Tags: webdev, career, advice, beginners
Published: 2020-10-05 00:37:02

# 1. Get comfortable with mental blocks
Since starting my coding journey two years ago I can't even begin to tell you how many times I've ran into a problem that felt like I'd never solve. Hours and days spent wondering if I'm actually cut out for this. You will always have these moments throughout your coding journey. These blocks are easily the greatest learning opportunities you will encounter. So look forward to them and just know with each one you get past, (because you will get past them), the next one gets a little bit easier.

#2. Constantly Comparing
The worst thing you can do is compare yourself to other devs. Like all social media you're only seeing the highlights. You don't get to see the years of learning, days and weeks spent struggling to find a solution to a problem, you get the idea. Everyone started as a code newbie. :)

#3. Breaking out of tutorial hell
Be specific about what you want/need to learn. Don't do a course for the sake of doing it. Go into the course knowing what you want out of it. This is best paired when working on a project and needing to implement something that you lack knowledge of.

Hopefully this will help you stay sane along your coding journey. If it were easy everybody would be doing it! :)
Tornando o VSCode o seu único ambiente de desenvolvimento com Docker e Kubernetes
Tags: kubernetes, docker, containers, vscode
Published: 2020-10-13 03:11:04

---
title: Tornando o VSCode o seu único ambiente de desenvolvimento com Docker e Kubernetes
published: true
date: 2020-10-05 00:34:43 UTC
tags: kubernetes,docker,containers,vscode
canonical_url: https://blog.lsantos.dev/tornando-o-vscode-o-seu-unico-ambiente-de-desenvolvimento-com-docker-e-kubernetes/
cover_image: https://raw.githubusercontent.com/khaosdoctor/blog-assets/master/images/2020/10/EjFnoT5XcA0bb9-.jpg
---

No dia 3 de outubro participei da **BrazilJS.live()** um evento completamente online organizado pela já conhecida equipe da BrazilJS!

Neste dia decidi ser um pouco mais ousado e trazer para vocês uma palestra completamente Hands On sobre como podemos transformar o nosso editor do coração, o [**VSCode**](https://code.visualstudio.com/?WT.mc_id=personal-blog-ludossan) no único ambiente de desenvolvimento quando estamos tratando de **[Azure](https://azure.microsoft.com/en-us/), [Docker](https://docs.microsoft.com/dotnet/architecture/microservices/container-docker-introduction/docker-defined?WT.mc_id=personal-blog-ludossan) e [Kubernetes](https://docs.microsoft.com/azure/aks/?WT.mc_id=personal-blog-ludossan)**.

Nesta palestra de mais ou menos 30 minutos, abro meu [VSCode](https://code.visualstudio.com/?WT.mc_id=personal-blog-ludossan) e mostro as incríveis extensões do [Docker](https://docs.microsoft.com/dotnet/architecture/microservices/container-docker-introduction/docker-defined?WT.mc_id=personal-blog-ludossan) e do [Kubernetes](https://docs.microsoft.com/azure/aks/?WT.mc_id=personal-blog-ludossan) que permitem que você faça a gestão completa de qualquer cluster [Kubernetes](https://docs.microsoft.com/azure/aks/?WT.mc_id=personal-blog-ludossan) diretamente de dentro do editor, além disso, temos também a capacidade de fazer qualquer modificação e manipular o [Docker](https://docs.microsoft.com/dotnet/architecture/microservices/container-docker-introduction/docker-defined?WT.mc_id=personal-blog-ludossan) em si diretamente de dentro do [Code](https://code.visualstudio.com/?WT.mc_id=personal-blog-ludossan)!

Dá uma olhada como foi:

<iframe width="612" height="344" src="https://www.youtube.com/embed/wgzlljXoU_s?start=2405&amp;feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

## Links

Você pode encontrar as duas extensões nestes links:

- [Extensão do Docker para VSCode](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker&WT.mc_id=personal-blog-ludossan)
- [Extensão do Kubernetes para VSCode](https://marketplace.visualstudio.com/items?itemName=ms-kubernetes-tools.vscode-kubernetes-tools&WT.mc_id=personal-blog-ludossan)
【Vim】Setting to automatically remove white space at the end of a line when starting and saving
Tags: vim, vimrc, linux, webdev
Published: 2020-10-05 00:27:20

## Introduction
- The following points bothered me when editing in vim and I investigated whether they could be resolved.
  - I have to remove it manually or by command every time because "habit or unintentional" whitespace is put at the end of a line.
  - Sometimes I forget to delete them.
  - In order to prevent deletion, I want to perform automatic deletion not only at the time of saving, but also at the time of starting.
- So, we'll use the autocmd function to write an automatic deletion setting.

## Result
- Open `.vimrc` (configuration file)

```bash
vim ~/.vimrc
```

- Write the following to `.vimrc`

```vim
" auto remove blank
augroup vimrc
autocmd BufRead,BufWrite * if ! &bin | silent! %s/\s\+$//ge | endif
augroup END
```

- Loading settings in the vim

```vim
:source ~/.vimrc
```

- As a test, enter a blank space at the end of a line in the file, and if it is automatically deleted when the file is started or saved, it's done.

## Link
- [autocmd](http://vimdoc.sourceforge.net/htmldoc/autocmd.html)
Analyzing Angular bundle with Webpack Bundle Analyzer
Tags: angular, bundle, performance
Published: 2020-10-05 00:05:27

---
title: Analyzing Angular bundle with Webpack Bundle Analyzer
published: true
description: Let's take a look into our bundle to see what we find
tags: #angular #bundle #performance
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/lvgwywdaw2rww0qmq8cu.png
---

Angular, and every modern web application, includes dependencies to makes our life easier. Even most of them are optimised, this is not free at all. Every dependency we add is going to increase our bundle. 

We don't want to re-invent the wheel, but I think before adding more stuff to our bundle we should ask before:
* Is this exactly what I need?
* How is going to impact the bundle?

Another important thing to consider is that we should implement lazy-loading as much as we can in order to split our code better and improve the performance. You can take a look to this [post](https://dev.to/salimchemes/optimising-angular-performance-with-lazy-loading-and-quicklink-3j66) for more details.

**So, what is this post about? We will review webpack-bundle-analyzer, a tool to see what is inside of our bundle. It will create an interactive treemap visualization of the contents of all your bundles. We can navigate the map to identify what can be removed/optimized**

Steps to install
```javascript
 npm install --save-dev webpack-bundle-analyzer
 
 ng build --stats-json

 npx webpack-bundle-analyzer dist/your-project-name/stats.json  
```

Note that after dist/ you need to set your project name, I am using an example project including some extra dependencies to be reviewed on the map. In a real world app, you will probably have more dependencies and modules to analyze

After running the last command line you will have this
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/4ojp5ikhoi4teld39t2m.png)

This is how the map looks
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/jmc3g6s5vpzlf4jqzif1.gif)

Now let's navigate moment js, as you can see, moment is not a small dependency
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/zhufyrq35gju5y2z2nff.gif)

Finally we can look for a specific module
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/xtxo78qmeop1fp8rc95q.gif)

Conclusions
webpack-bundle-analyzer is a very useful tool to
* Get a big picture of our project
* Identify dependencies that can be replaced with small ones
* Identify big modules and split them in smaller pieces

References
* [webpack-bundle-analyzer] (https://www.npmjs.com/package/webpack-bundle-analyzer)