Author Archive

redis: list all the keys

You want to list all the keys in your Redis database. Or, you want to list just some of them.

See the documentation here. Example:

$ redis-cli> KEYS jabba*
1) "jabba:cnt1"
2) "jabba:cnt2"> KEYS *
1) "jabba:cnt1"
2) "jabba:cnt2"
3) "others:counter"
Categories: bash Tags: ,

How to update a GitHub forked repository?

Categories: Uncategorized Tags: , , ,

Upgrade from Ubuntu 14.04 to 16.04

On my laptop I upgraded my Ubuntu to 16.04 but after the restart I didn’t get the graphical interface. The booting stopped and I found myself in a maintenance shell. I also got messages about some hard disk errors.

Well, I also have Windows 8.1 on this laptop and the Windows didn’t do a complete shutdown. Windows 8 does some tricky shutdown to boost the booting process, so it does some kind of half-hibernation. When I used Ubuntu 14.04, I got a message that one partition couldn’t be mounted, “press S to skip”. And I upgraded to 16.04 like this. And this unmountable partition caused this trouble.

So the solution was the following: start Windows 8.1, disable that shitty “fast startup” (see this post for more info), and restart Ubuntu. This time Ubuntu 16.04 booted normally.

Update (20160526)
I upgraded two more machines, there were no real problems. Libreoffice didn’t want to start on one of them, it dropped a “General I/O” error. Here is the cure:

$ sudo apt-get remove --purge libreoffice*
$ sudo apt install libreoffice

It’s a good idea to use “apt” instead of “apt-get”. It does the same thing but in addition you get a nice progress bar.

MongoDB stopped too. Here is how to start it with systemctl:

$ sudo systemctl enable mongodb
$ sudo systemctl start mongodb
# verification:
$ systemctl status mongodb
$ mongo

how to install Neovim under Ubuntu

Under Manjaro I installed neovim with yaourt. It installed version 0.1.4 and it works fine. For Ubuntu, the home page of Neovim suggests a PPA but it installed for me the version 0.1.5-dev, which is a development version.

How to install a specific version under Ubuntu (namely 0.1.4 in this case)?

Visit and find the tagged version 0.1.4. Download the zip, uncompress it, and enter the project folder.

Install the dependencies:

$ sudo apt-get install libtool autoconf automake cmake libncurses5-dev g++

Build and install the project:

$ make cmake
$ make test
$ sudo make install

It’s a good idea to install the “neovim” Python package too:

$ sudo pip2 install neovim
$ sudo pip3 install neovim

Tips taken from here.

Categories: ubuntu, vim Tags: , , ,

[vim] a concrete repeat.vim example

In vim you have a custom mapping that consists of a series of commands. You would like to repeat it with the “.” command but it only repeats the last part of the series of commands, not the whole.

Tim Pope has a plugin for this called repeat.vim . However, he doesn’t give a concrete example in the README so it’s very hard to figure out how it works.

Let’s see the following mapping that surrounds a word with apostrophes:

nnoremap <Leader>' viw<esc>a'<esc>hbi'<esc>lel

Usage: put the cursor on a word and press <Leader>' to surround it.

If you try to repeat it with “.”, it will only repeat the insertion of the second apostrophe.

How to make the whole mapping repeatable:

    nnoremap <silent> <Plug>SurroundWordWithApostrophe  viw<esc>a'<esc>hbi'<esc>lel
        \ :call repeat#set("\<Plug>SurroundWordWithApostrophe", v:count)<cr>                                                                      
    nmap <Leader>'  <Plug>SurroundWordWithApostrophe


Categories: vim Tags: , ,

[vim] I’m back to (neo)vim

May 15, 2016 2 comments

A week ago I returned to vim, more precisely to neovim.

Here is my story…

When I started the university (geez, that was 20 years ago) we got an account to a Unix server. On the first week I logged in and launched Midnight Commander. I wanted to check out the content of a file in my HOME folder so I pressed F3 (view) on it. However, the default editor was “vi” :) I had no idea how to quit this program so I had to ask a senior student in the lab to help me. He was kind and showed me the trick: “:q<Enter>“. So this is how I met vi and after this I avoided it for 3 years. Then I had a Java class where there was a guy who was a big zero in programming. One day he was sitting next to me and he was using Vim! And I was using Joe. He had nice syntax highlighting and he showed me some vim tricks. And I thought “WTF? If this guy could learn it, then I can learn it too.” I asked him about it and he told me that he started it with the command “vimtutor“. I went home and that very afternoon I went through the vimtutor too. I made some notes but I couldn’t memorize all those keyboard shortcuts. In the next few days I went through the tutorial two more times. Then I forced myself to use vim for all my text editing works and I got to like it. When I needed something I looked up how to do it with vim. The commands were logical and soon it was a pain to use any other editor.

Several years passed and I was very satisfied with Vim. I wasn’t a guru and I didn’t use many plugins, but I could solve all my problems with it. Then 2 years ago I heard that Emacs can be vimmified with the Evil plugin. I gave it a try and it was like a “better vim”. It had a nice GUI, I liked its default color scheme, it had a plugin manager, etc. I spent two weeks with its configuration and I could reproduce the majority of my vim settings. It was good.

I have several machines (desktops, laptops) and I used Emacs+Evil everywhere. I keep my settings in Dropbox, so I have the same configuration on all my computers. However, on my older machines Emacs started very slowly. Sometimes I had to wait 20 seconds! So when I wanted to edit a little script, I just launched vim. And it happened more and more often…

And now it’s present time. Two weeks ago I read about Neovim and I liked its features: a modernized vim, async job control, built-in terminal. I decided to give it a try. I created an empty init.vim file (it’s Neovim’s .vimrc equivalent) and transferred from .vimrc the necessary things. It turned out that my .vimrc had lots of obsolete settings that I could drop. On the forums I looked after the popular plugins. I even started learning vimscript :) Now my settings are better than my old Vim settings. I like Neovim and I am going to use it from now on.

If you are interested, then here is my init.vim configuration file for Neovim. It’s a work in progress but it’s already usable.

Expect some (neo)vim posts in the future :)

Categories: Uncategorized, vim Tags: , , ,

[xfce] allow drag & drop of window buttons on the panel

Under Manjaro I have XFCE and one thing bothered me for a long time: window buttons on the bottom panel cannot be reordered with drag & drop. Or is it possible?

Yes, it’s possible, but it was not the default behaviour. Right click on the panel -> Panel -> Panel Preferences… -> Items tab -> Window Buttons, then select edit. Here, under Appearance change the sorting order to “None, allow drag-and-drop“.

Damn, I’ve been using Manjaro for 2 years…


Get every new post delivered to your Inbox.

Join 88 other followers