rockyourcode: Setup Mariadb via Docker With Spring Boot, Quick Tip: Unicode Characters in Kitty Terminal, Notes On “The Coaching Habit”, Increase Your Chances of Getting Your First Developer Job, Use Jetbrains Mono in VS Code (or: Can You Adjust Line Spacing?), Would I Do It Differently?, Remember to Focus
Hello 👋! Thanks for subscribing.
Sorry for the late newsletter, I totally forgot to send it! 😅
Setup Mariadb via Docker With Spring Boot
Published on: 2021-05-31
tags: Docker, Tutorial, Java
How to run MariaDB inside Docker and connect to it with Spring Boot
Docker with MariaDB
We’ll use yobasystems/alpine-mariadb, a lightweight container image using the open-source MariaDB as MySQL alternative.
Here’s the docker command:
docker run --name mariadb -p 33067:3306 -v /var/lib/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=root_pass -d yobasystems/alpine-mariadb
The command will create a container named mariadb
with a root password (root_pass
). You can connect to the database via localhost
on port 33067.
Spring Boot
Initialize Spring Boot with the Spring Initializer.
Dependencies: Spring Data JPA, MariaDB Driver.
I’ve also added Rest Repositories and Lombok, because my goal was to create a CRUD REST API with Spring.
Setup User and Database
Create two scripts.
The first one is for creating the user (call it 01-user-setup.sql
):
CREATE USER 'myuser'@'%' IDENTIFIED BY 'mypass';
GRANT ALL PRIVILEGES ON * . * TO 'myuser'@'%';
The script creates a new user called myuser
with the password mypass
on all hosts. Of course, you can change the values to your needs.
By default, MySQL and MariaDB restrict connections other than to the local machine. The Docker container runs on a separate network. To connect from your local machine, you’ll need to use the %
wildcard as the host.
The second script creates the database (02-database-setup.sql
):
-- -----------------------------------------------------
-- Schema ecommerce
-- -----------------------------------------------------
DROP SCHEMA IF EXISTS `ecommerce`;
CREATE SCHEMA `ecommerce`;
USE `ecommerce` ;
If you want, you can create your tables here, too. I’ve omitted the additional setup here.
Now, let’s run these scripts via docker:
docker exec -i mariadb sh -c 'mysql --host=localhost --user=root --password=root_pass' < 01-user-setup.sql
And the database schema:
docker exec -i mariadb sh -c 'mysql --host=localhost --user=root --password=root_pass' < 02-database-setup.sql
Explanation:
exec -i mariadb
: run a command in a running container with stdin (-i
) — we named the database container mariadb
sh -c
: run a shell script with a command string operand
'mysql --host=localhost --user=root --password=root_pass'
: this is the command we are running inside the container
< 01-user-setup.sql
: read the file from stdin (on your local computer)
Connect Spring
Find the src/main/resources/application.properties
file in your Spring project and replace it with the following content.
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
# connect via localhost on port 33067
spring.datasource.url=jdbc:mariadb://localhost:33067/ecommerce?useSSL=false&useUnicode=yes&characterEncoding=UTF-8&allowPublicKeyRetrieval=true&serverTimezone=UTC
spring.datasource.username=myuser
spring.datasource.password=mypass
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDB103Dialect
# use update for development
# see https://stackoverflow.com/questions/42135114/how-does-spring-jpa-hibernate-ddl-auto-property-exactly-work-in-spring
spring.jpa.hibernate.ddl-auto=update
spring.data.rest.base-path=/api
My MariaDB version is 10.5.9
, if your version is higher, you might need to adjust the hibernate dialect to a higher version.
You should now be able to connect to the database.
I run the application via Maven like so:
mvn spring:boot run
Links
image credit: Ash from Moddern Afflatus
Quick Tip: Unicode Characters in Kitty Terminal
Published on: 2021-05-30
tags: TIL, DevTools
You can insert unicode characters by name, hex code, recently used or an editable favorites list. Press ctrl+shift+u to start the unicode input widget.
I originally used the excellent unicode.vim for inserting Unicode into Vim, but with Kitty this plugin is not necessary anymore.
Source
Notes On “The Coaching Habit”
Published on: 2021-05-29
tags: Notes
🚀 The Book in 3 Sentences
Stay curious a little bit longer, say less, and ask more questions.
Your advice is not as good as you think it is.
The book offers a toolkit to become a better leader by giving you a framework of principles and questions.
🎨 Impressions
It’s a short book which explains each concept individually, and then offers an actionable script to help you change your behavior. Easy to read.
Who Should Read It?
“The Coaching Habit” is a book for leaders and managers, but I’ve found the attitude and questions useful in everyday life, too.
☘️ How the Book Changed Me
I’ve started an effort to become a better listener. I love to talk, so it’s hard for me to ask questions and to embrace the silence.
Since sprinkling in a few of the 7 questions into my conversations, I’ve realized that a good question can be very powerful.
I’ve also found the tips on how to set boundaries very helpful and try to at least think about my limits before saying yes to something.
✍️ My Top 3 Quotes
When you ask someone [a question], sometimes what follows is silence.
Silence is often a measure of success.
It may be that the person […] is the type who needs a moment or three to formulate the answer in his head before speaking it. In which case you’re giving him that space.
But a Yes is nothing without the No that gives it boundaries and form.
The Secret to saying No is to shift the focus and learn how to say Yes more slowly.
📒 Notes
- The 3P model: what to focus on: a project, a person or a pattern of behavior
- uncover more options by asking questions, the first solution is rarely the best one
- when people talk about the challenge at hand, it’s seldom the actual problem
- coaching for development (shifts focus to the person trying to solve the problem) vs. coaching for performance (everyday solving-the-problem management)
- stick to questions starting with “what”
- if you’re not trying to fix things, you don’t need the backstory
- we often don’t know what we actually want
- get comfortable with silence
- “How can I help?” forces your colleague to make a direct and clear request & forces you to stop leaping into action before you know what’s needed
- ask more questions before committing to a Yes, example: “According to what standard does this need to completed? By when?”, “If I couldn’t do all of this, but could do just a part, what part would you have me do?”
- “Say Yes to the person, but say No to the task.”
The 7 Questions
- The Kickstart Question: “What’s On Your Mind?”
- The AWE Question: “And What Else?”
- The Focus Question: “What’s the Real Challenge Here For You?”
- The Foundation Question: “What Do You Want?”
- The Lazy Question: “How Can I Help?” (Be curious)
- The Strategic Question: “If You’re Saying Yes to This, What Are You Saying No To?”
- The Learning Question: “What Was Most Useful For You?”
Links
- The Coaching Habit by Michael Bungay Stanier
- Ali’s Book Notes Template
Increase Your Chances of Getting Your First Developer Job
Published on: 2021-05-28
tags: Lab
Here are some ideas on how to break into tech without having a Computer Science degree.
The following tips are things that worked for me. Depending on where you live and your skills, some advice might not work.
But maybe these tips will still give you some ideas.
Document Your Learning
Write a blog, create a YouTube channel or publish a podcast. Put your notes on GitHub.
This habit has two benefits: it helps you to learn better, and it also shows future employers that you are putting in the work.
Don’t forget to use Git and GitHub to show your code.
Attend Meetups
The best way to learn about the tech industry is by talking to people already working as developers.
You can ask questions, find out what you need to know to get a job in your area, find folks who talk the same “language” as you.
You also expose yourself to new technologies, as most Meetups feature a tech talk.
You might be interested in giving a talk. The organizers are always happy if someone volunteers, and you don’t have to be an expert. A talk from a beginner’s mind is also valuable.
Build a Good Portfolio
A website that showcases some good-looking projects makes a good impression. Spend a little time on the looks, but don’t neglect the code either.
If possible, don’t use a cloned copy from an Udemy course. At least adjust it slightly, add more functionality, improve the UI, etc.
Josh Comeau has free ebook on Building an Effective Dev Portfolio.
Know What You Want
I knew I wanted to become a salaried employee, not a freelancer.
There are also other concerns for a job: commute time, team size, how the company is organized, diversity, what kind of work you’ll be doing, expectations for overtime, and so forth.
For web developers, do you want to work in an agency or rather a product-based company? Most of the time, the agency takes on new client projects.
That means, you’ll have the chance to work on different domains and probably with newer technology (“greenfield” projects).
With product-based companies you’ll work on parts of the product for a long time, maintaining and updating it constantly. This kind of work offers different challenges and rewards.
Think about what you would like to get out of “getting a job as a developer”. It needs to be a good fit for you, so that you can do your best work.
Apply For Jobs Even If You Don’t Meet All Requirements
Most job boards show a “wishlist” of what the employer (or recruiter) wants. You’ll most likely don’t fulfill all requirements.
Most asks are not hard limits. You will get a few rejections for sure, but if you have a solid cover letter and portfolio you can mitigate the missing requirements.
As an example, having no Computer Science degree does not automatically disqualify you from a job.
You Might Not Need to Do Whiteboard Challenges
I was very nervous about having to solve algorithm challenges. It’s not something that I enjoy, and I did not prepare for it.
After the first few interviews I realized that whiteboard coding challenges are rather uncommon here, so I’m glad that I didn’t spend my time on preparing for things that I did not need.
I suggest to get a few job interviews to see how the interviewing process works in your area.
Links
Use Jetbrains Mono in VS Code (or: Can You Adjust Line Spacing?)
Published on: 2021-05-27
tags: DevTools, TIL
VS Code is the default editor/IDE at my future day job.
Today I wanted to switch the default font to the free JetBrains Mono font.
The font is easy to read and it also comes with font ligatures, a feature that I love for programming.
How To Use JetBrains Mono As Your Font With Recommended Settings
Download the Font
Find the installation instructions on the official website.
For Arch Linux:
pacman -S ttf-jetbrains-mono
Line Spacing in VS Code
You should open your user settings (settings.json):
Command Palette > Open Settings (JSON)
The website for the font explains that the recommended settings are a font size of 13 and line spacing of 1.2.
Here’s what it should look like in VS Code:
{
"editor.fontFamily": "JetBrains Mono",
"editor.fontSize": 13,
"editor.fontLigatures": true, // optional
}
But didn’t you tell me to set the line spacing?
Yes, I did. You can set the editor.lineHeight
in VS Code (which is the same as line spacing). Don’t confuse it with editor.letterSpacing
.
Line spacing is the vertical distance between lines of text. Most writers use either double-spaced lines or single-spaced lines—nothing in between—because those are the options presented by word processors. 1
In VS Code, editor.lineHeight
is an absolute value, so setting it to 1.2
does not work. The line height is in “…in CSS pixels of the amount of space used for lines vertically.”.
There’s currently an open issue to allow the user to set line spacing as a relative value, but the feature is not implemented yet.
It looks like the default line spacing defaults to 1.35 relative to the font size.
For a font size of 13
, setting the value in editor.lineHeight
to 22
has the same effect as keeping the default (1.35 relative?). I’ve manually bumped it down to 21
.
Links
Would I Do It Differently?
Published on: 2021-05-26
tags: Thoughts
It took me around 5 years to learn to code and to switch careers.
Programming started out as a hobby for me when I was on parental leave. I enjoyed learning to code.
I didn’t feel confident that I could get a job as a web developer.
I had a decent-paying and secure job as a tax officer. One of the perks was being able to work part-time and to work from home, even before the pandemic.
It’s a good job if you have younger children.
Recently someone asked me: “What would you do differently if you could go back?”
I answered something along the lines: “More focus. I learned JavaScript as first programming language, but had trouble applying it to solve problems. So I tried different ways to learn how to solve problems programmatically. I learned Racket, Clojure, then went back to Python, took a tour of Elixir and so forth.
I could have changed careers earlier if I’d focus more.”
And on the one hand, that’s true.
And on the other hand, it totally neglects my situation.
I needed to have the confidence to know that I can create web applications. At the beginning, I was able to understand code when someone gave it to me. But I was not able to come up with solutions on my own.
I needed the practice, and I also needed to see how different programming languages approached the same problem (a CRUD web application).
My status quo job-wise also played a significant role in my decisions. Leaving the civil service in Germany comes with enormous down-sides (job security, pension).
My goal was never: “Get a job as a software developer as soon as possible.”
Looking back, I probably wouldn’t do anything differently. Every programming language I learned helped me to become a better problem solver.
Most people want to switch careers as fast as possible. For those, a more focused approach makes total sense.
image credit: Caleb Jones
Remember to Focus
Published on: 2021-05-25
tags: Thoughts
This is a reminder for me to focus more.
I easily get distracted by Twitter, Email or Discord.
Cal Newport wrote a book about the topic: Deep Work: Rules for Focused Success in a Distracted World. (Here’s a summary by Derek Sivers.)
I’m notoriously bad at focusing. I sometimes wonder if that comes from having children.
My daughters constantly interrupt me. That’s life. It is also the reason why I’m not a huge fan of “work from home”.
WFH during the pandemic was rather “work from home, home-school at the same time, and also care for the bored kindergarden child”.
While you still get work done, I’m more productive at the office when I don’t have to be a caregiver at the same time.
The Pomodoro technique, a famous time-boxing method, might be one method to bring more structure and focus. It does not help much with external distractions, though.
image credit: Avin CP
I’m going to give the Pomodoro method a try in the next days.
Links
- Deep Work: Rules for Focused Success in a Distracted World by Cal Newport
- Book Summary of “Deep Work” by Derek Sivers
- Pomodoro Technique
Thank you for reading my blog posts.