Quick ebook conversion with Calibre in console

calibre

I mostly use fbless ebook reader, because it works on console and don’t need to switch to X server for reading. Downside is that it recognize only .fb2 or .fb2.zip format, which is not so common. For quick conversion I use Calibre command line tool:

ebook-convert How.to.Convert.Ebooks.epub How.to.Convert.Ebooks.fb2

…quick and efficient.
Happy hacking….

Editing files over ssh in vim

archlinux-logo-dark-200dpi.b42bd35d5916

Need a quick file edit on remote server. With vim it’s easy, use:

vim scp://username@host:port//path/to/file

…or within vim:

:e scp://username@host:port//path/to/file

…or if you are not sure about name of the file, browse remote directory with:

:e vim scp://username@host:port//path/to/directory/

Directory path must end with /.Remote home directory is invoked with:

:e scp://username@host:port/~/

Use rcp instead of scp for ftp access.
Happy hacking….

gpg not working without X server

archlinux-logo-dark-200dpi.b42bd35d5916

If you are trying to use gpg command for encrypt or decrypt data on tty without X server (I use that in combination with yadm, you will probably get this error:

gpg: public key decryption failed: Inappropriate ioctl for device

If you don’t want to switch to X every time, there is a simple solution.Put this line in your ~/.bashrc:

export GPG_TTY=$(tty)

Happy hacking…

Mirakel crash

archlinux-logo-dark-200dpi.b42bd35d5916

If you are using taskwarrior and you are trying to use Mirakel from Google Play Store, there is a 99% chance, that Mirakel crashes every time you want to sync Mirakel with taskwarrior server (By the way, easy way to set up server, is at freecinc, which is web based server and just follow the instructions). There is a workaround for that. Go to Mirakel, download the 2.8.1 version and the Mirakel will sync with server without problem.
You should then disable auto update for Mirakel on Google Play Store.
Happy hacking…

kodi – network ports

kodi-helix-14.1-600x336

If you use XBMC or now Kodi, those are the ports that should be open for full network access:
tcp 8080 – web interface, can be changed,
udp 1900 – dlna,
other ports:
tcp: 1084, 1308, 1131,
tcp (ipv6): 9090 (optional if you use ipv6 connections),
udp: 9777, 12374.
Those are ports that I opened and can be seen with console command:
netstat -ntulp
If you use iptables those are commands:

iptables -A TCP -p tcp --match multiport --dports 1084,1131,1308,8080 -m comment --comment "kodi" -j ACCEPT
iptables -A UDP -p udp --match multiport --dports 1900,9777,12374 -m comment --comment "kodi" -j ACCEPT
iptables-save > /etc/iptables/iptables.rules
systemctl reload iptables

…as root.
Happy hacking…

hstr – improved bash history completition

hh>

When working on command line most of the time, there is always a problem with long commands, for example:
find . -depth -name '* *' -execdir bash \-c 'a="{}";mv -f "$a" ${a// /.}' \;
(this command replace all spaces ‘ ‘ with dots ‘.’ recursively in directories and file names, see my post for explanation)

There is option with ctrl-r or you can use clipboard manager like anamnesis or CopyQ or some other helper. A while ago I stumbled upon hstr on ArchLinux AUR repository (it’s called hh there) and I’m using it since then. The advantages are easier and more efficient browsing with managed history (removing sensitive commands) and option to bookmark favorite commands.
When installed just configure hh with:
hh --show-configuration >> ~/.bashrc
and with the same ctrl-r keyboard shortcut.

For quick introduction you can view video tutorial on Youtube or, when installed read man hh.

Happy hacking….

goto – enhanced cd command

archlinux-logo-dark-200dpi.b42bd35d5916

goto – enhanced ‘cd’ command replacement tool with fuzzy file finder and a directory bookmark saver, similar to autojump.

The usage is simple and effective:

goto -h, -help, h, help  # Prints the Usage

goto "location address"  # Takes you to the "location address"

goto s, -s "shortcut"  # Saves the Current Directory location as "shortcut"

goto l, -l  # Lists all the Bookmarks saved

goto d, -d "shortcut"  # Deletes the "shortcut" saved

goto p, -p "shortcut"   # Prints the GOTO directory for "shortcut"

goto f, -f, find, -find "term"  # Fuzzy-Finds all the file/folder matching REGEX in the working directory

Give it a try…

…and happy hacking.