Author: Kamil

How to create a Google Cloud Function using Gradle with Kotlin DSL (part 2)

How to create a Google Cloud Function using Gradle with Kotlin DSL (part 2)

In a previous article, we created a Gradle project with a simple Cloud Function. Now it’s time to build and deploy it to the cloud.

Before you can deploy anything to the Google Cloud you have to set up your account. If you did that you can skip it. If not, I recommend doing all the steps described in “Before you begin” in this guide. It’s important that you installed and configured Google Cloud CLI on your computer.

Continue reading “How to create a Google Cloud Function using Gradle with Kotlin DSL (part 2)”
How to create a Google Cloud Function using Gradle with Kotlin DSL

How to create a Google Cloud Function using Gradle with Kotlin DSL

The Google Cloud Functions is a great way to run your code without the need to manage a server and runtime environment. Thanks to Cloud Free Tier it is also free of charge up to 2 million calls monthly.

I will use Kotlin language because it is a good choice for backend services. It’s less verbose than Java and has faster compilation than Scala.

Continue reading “How to create a Google Cloud Function using Gradle with Kotlin DSL”
Httpie – a HTTP client not only for the terminal

Httpie – a HTTP client not only for the terminal

Software developers work a lot with REST endpoints nowadays. Sometimes we consume some endpoint exposed by some server and sometimes we create a new REST endpoint. In both cases you need to send a request to the endpoint and see what it returns.

I have been using different HTTP clients like Postman or Insomnia and they were OK. But when it comes to calling an endpoint from a terminal there was only one option: a curl command. Unfortunately it has not intuitive and verbose command line arguments so I am not a fan of it.

There I a very cool alternative and it is called httpie (httpie.io/cli). It comes with a handy http command and it is really easy to use.

Continue reading “Httpie – a HTTP client not only for the terminal”
Different java version for each project

Different java version for each project

Since September 2017 Oracle started releasing new Java language version every 6 months. Of course many versions are non-LTS and I used them only to check out new language features. Last year Java 17 was released (LTS release) and it’s getting more and more adoption.

At my work I usually work with many projects each opened in separate IntelliJ IDEA window. It’s pretty common when you work with microservices. Because each service is maintained by different team it is not unusual that one service is using Java 11 and other requires Java 17.

To install and manage many versions of JDK I prefer to use SDKMAN! (sdkman.io). It manages not only Java SDK but also other language SDKs like Scala, Kotlin. No need to look for new tool or learn how to use them.

Continue reading “Different java version for each project”

Tldr – quick help for console commands

Most of the time I use applications with graphical interface but sometimes I still use console tools. They are often faster and more reliable. In some cases there are no alternatives to some command line tools or simply there is no graphical interface available. The problem is that I always forget how to invoke some specific commands.

In that situations I check man pages or simply google it. There is a small utility called tldr that can display only short documentation (in contrast to man pages) with examples how to use given command. To install this tool use brew formula.

Continue reading “Tldr – quick help for console commands”

Show git branch name in bash command prompt

I work with git command in terminal a lot and I often forget what branch I was working on. Running command git branch often is not very convenient I needed to put git branch in command prompt when I was inside git repository.

I wanted my console to look like this:

eanlr@vps some-repository (master) $ 

To get that you need to add following lines to your .bash_profile file in your home directory:

parse_git_branch() {
  git branch 2> /dev/null | sed -e '/^*/d' -e 's/* (.*)/ (\1)/'
}

export PS1="\u@\h \W[\033[32m]$(parse_git_branch)[\033[00m] $ "

You can of course customize command prompt by changing PS1 variable.

Slow shell startup with Node Version Manager (NVM)

While I was working with some frontend projects I used node and npm tools. The problem is that each projects requires different version of those tools so you need something to manage various versions and switch on demand. Node version manager (nvm) is a great tool for that purpose and I was very satisfied with it.

Unfortunatelly after installing nvm my shell startup became quite slow and it was irritating when I opened new terminal tab. It turned out nvm was responsible for that. As i use frontend tools not very often I decided to load nvm on demand.

I changed a fragment responsible for nvm in my .bash_profile file from this:

. "/usr/local/opt/nvm/nvm.sh"

To that:

load_nvm() {
  . "/usr/local/opt/nvm/nvm.sh"
}

Now when I need node and npm tools i simply run load_nvm and my shell is ready for javascript development.

eanlr@vps ~ $ load_nvm
eanlr@vps ~ $ node -v
v8.9.4