Traversing the alphabet in Scala

If you need to traverse the alphabet in Scala automatically, you can create a loop that proceses the single letters.

The following code was used in a Play Template (view) to traverse the alphabet and show the differnt links depending on the existence of a single letter in the cityLetters sequence. If the letter is in the sequence, the link is active, otherwise inactive.

@(cityLetters: Seq[String] = Seq.empty)

@defining('A' to 'Z'){ alphabet =>
  @for(l <- alphabet) {
    @defining(l.toString) { letter =>
      @if(cityLetters.contains(letter)) {
        <a class="btn btn-default" href="@routes.CityController.listing(letter)">@letter</a>
      } else {
        <a class="btn btn-default" disabled="disabled" href="#">@letter</a>
      }
    }
  }
}

Permission denied while trying to connect with Docker daemon via socket

The following error occured while trying to connect to the Docker daemon after installation.

Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post [...]: dial unix /var/run/docker.sock: connect: permission denied.

The daemon was not accessible by the current user because of lack of permission. The solution is to add the current user to the docker group to gain permission for connection.

sudo usermod -a -G docker $USER

After executing the above command, log out from the current shell and log out from the account.

Tmux configuration and basic commands

Basic configuration for tmux

Tmux canbe configured via .tmux.conf file within the home directory. The following .tmux.conf contains a basic configuration.

# ~/.tmux.conf

set -g default-terminal "screen-256color"   # use 256 colors
set -g history-limit 65536                  # scrollback buffer n lines
set -g default-command zsh                  # disable login-shell

# Set the prefix to ^A.
unbind C-b
set -g prefix ^A
bind a send-prefix

# Bind appropriate commands similar to screen.
# lockscreen ^X x 
unbind ^X
bind ^X lock-server
unbind x
bind x lock-server

# screen ^C c 
unbind ^C
bind ^C new-window
unbind c
bind c new-window

# detach ^D d
unbind ^D
bind ^D detach

# displays * 
unbind *
bind * list-clients

# next ^@ ^N sp n 
unbind ^@
bind ^@ next-window
unbind ^N
bind ^N next-window
unbind " "
bind " " next-window
unbind n
bind n next-window

# title A
unbind A
bind A command-prompt "rename-window %%"

# other ^A
unbind ^A
bind ^A last-window

# prev ^H ^P p ^? 
unbind ^H
bind ^H previous-window
unbind ^P
bind ^P previous-window
unbind p
bind p previous-window
unbind BSpace
bind BSpace previous-window

# windows ^W w 
unbind ^W
bind ^W list-windows
unbind w
bind w list-windows

# quit \ 
unbind '\'
bind '\' confirm-before "kill-server"

# kill K k 
unbind K
bind K confirm-before "kill-window"
unbind k
bind k confirm-before "kill-window"

# redisplay ^L l 
unbind ^L
bind ^L refresh-client
unbind l
bind l refresh-client

# split -v |
unbind |
bind | split-window

# :kB: focus up
unbind Tab
bind Tab select-pane -t:.+
unbind BTab
bind BTab select-pane -t:.-

# " windowlist -b
unbind '"'
bind '"' choose-window

# Powerline
source-file ~/.local/lib/python2.7/site-packages/powerline/bindings/tmux/powerline.conf
# alternatively absolute path to HOME
# Rainbarf
set -g status-left '#(rainbarf --battery --remaining --rgb)'

Basic tmux commands

To start a new tmux terminal, the following command forces the terminal to assume that it supports 256 colors.

> tmux -2

The following commands represent a few basics (based on the configuration from above):

STRG-A This prefix key starts a new commands and will be followed by a command key. (Default prefix key is STRG-B)
STRG-A ↑(Picture upwards) Scrolling mode (Leave via `Enter`)
STRG-A D Detach to background (tmux -2 attach (hold back to foreground))
STRG-A C Create a new terminal witin tmux
STRG-A | Vertical split of the screen
STRG-A % Horizontal split of the screen
STRG-A(hold it) + ArrowKeys Change the size of the terminals

IntelliJ IDEA VM options

Idea vmoptions

The following options for the `idea64.vmoptions` file are prety useful on my system.

-Xms3g
-Xmx3g
-XX:ReservedCodeCacheSize=240m
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-ea
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
-Dawt.useSystemAAFontSettings=lcd
-Dsun.java2d.renderer=sun.java2d.marlin.MarlinRenderingEngine
-XX:MaxMetaspaceSize=1g

Current system

Current system and IDEA version.

  • Ubuntu 16.04.2 LTS
  • IntelliJ Idea IU-171.3691.12