Brno public transportation tickets

Sometimes, my friends from abroad ask me how to get tickets for Brno public transportation operated by the DPMB company. Here you go:

  • BrnoID – buy 1-30 day tickets online. The ticket is tied to your contactless credit card, i.e. when you’re asked to show your ticket by the public transportation staff, you’ll let them read the credit card info using their card reader. The process of getting the ticket this way requires only your email, password and your credit card’s number and expiration. You can pay for the ticket using the same or another credit card.
  • Sejf application – you can use the Android or iOS app to buy tickets valid from 20 min up to 1 day. The web page is in Czech only, the apps are translated. You prepay the app’s account using your credit card and then buy the ticket from the account. Remember, you need to buy the ticket at least approximately 3 minutes before embarking the vehicle. The app will tell you what time the ticket is active from. The prices are 19 CZK for 20 min and 24 CZK for 40 min. Buying the ticket requires an internet connection.
  • Buy a paper ticket
    • In ticket machines
    • In a newsstand
      • Newsstands, especially those close to bus/tram stations, sell the tickets. In Czech, the newsstands are usually called “Trafika”.
      • The tickets they sell are the basic ones you can buy in a ticket machine.
    • Main train station
      • You can buy longer-term Brno public transportation tickets (1-30 days) in the eastern wing of the train station (https://en.mapy.cz/s/3l88y) – the counters that sell international train tickets sell also the public transportation tickets. You can pay cash or with credit card there.
  • Other options not that suitable for foreigners:
    • Buy a ticket with the bus/tram driver. The tickets are more expensive (25 CZK for 15 min, 35 CZK for 90 min), and you may be easily rejected if you don’t have the exact amount in cash. Also, many drivers don’t speak English and are usually not pleasant when approached because of the tickets (even to locals).
    • The cheapest option for one-time tickets, especially when you plan to go on a trip outside of Brno (but within Moravian region), is to use Poseidon app for Android/iOS/Windows. The app is unfortunately in Czech only.
    • Buy the ticket using text/SMS. This works only if you have Czech SIM card: Dopravní podnik města Brna, a.s. – sms-navod-uzivani. Again, you need to buy the ticket around 3 minutes before embarking the vehicle, after you receive the confirmation SMS. Price is 20 CZK for 20 min and 29 CZK for 75 min.

Enlarge LUKS encrypted logical volume

Use case: Having one LVM2 logical volume encrypted with LUKS, that needs to be enlarged.

There is a pretty detailed manual on enlarging encrypted partition here. However that manual is for enlarging LUKS encrypted physical volume, not logical volume, thus some of the steps are a bit different.

  1. Backup your data.
  2. To have more space for the logical volume enlargement, I used gparted tool where I enlarged the LVM2 physical volume (PV) that holds my LVM2 logical volume (LV) with ext4 filesystem which I want to enlarge. I just right-clicked on the partition (/dev/sda2 – the PV with the encrypted LV) and chose Resize/Move. It enlarged both the PV and volume group (VG) which was in my case the solely VG within the PV. This was the easiest solution for me, but you can use pvresize and vgresize commands to do it in terminal.
  3. Prepare live USB/CD, e.g. per instructions here https://fedoraproject.org/wiki/How_to_create_and_use_Live_USB and boot to it.
  4. I chose Fedora Live which has the needed tools (cryptsetup and lvm2) preinstalled, but if your live system doesn’t have these then install them.
  5. Open terminal and switch to root.
  6. Identify your encrypted LV by running lvdisplay. For me it is /dev/mbocek_lvm/home (or /dev/mapper/mbocek_lvm-home or /dev/dm-4, all three are equivalent). To complete the picture, mbocek_lvm is my VG. Run ‘cryptsetup isLuks /dev/mbocek_lvm/home -v’ to make sure this device (logical volume) is the one encrypted – it should return Command succesful.
  7. Decrypt the LV and map the LUKS encrypted counterpart of the LV to whatever name, e.g. crypt1. For that, run ‘cryptsetup luksOpen /dev/mbocek_lvm/home crypt1’. This creates mapping /dev./mapper/crypt1.
  8. Per the abovementioned Ubuntu manual, run ‘vgscan –mknodes’ and ‘vgchange -ay’. I’m not sure whether it’s needed but I did it and no harm done.
  9. Now, because the VG mbocek_lvm that contains the decrypted LV has bigger size with unused space (because of step 2), we can run a command to enlarge the decrypted LV to fill all the unused space. Run ‘lvresize -l +100%FREE /dev/mbocek_lvm/home’. If you need a specific size to be added, consult lvresize man page.
  10. As the LV is resized now we need to resize its LUKS counterpart. Run ‘cryptsetup resize crypt1’.
  11. You can check the new LV size by running ‘lvdisplay’ and the size of the LV’s LUKS counterpart by running ‘cryptsetup status crypt1’ – both should be the same. cryptsetup returns the size in sectors. To find out the size of a sector, run ‘fdisk -l /dev/mapper/crypt1 | grep “Sector size”‘.
  12. Now the PV, VG and LV have the correct size, but one another step is needed – to let the LV’s ext4 filesystem know that the LV is bigger. For that run ‘e2fsck -f /dev/mapper/crypt1’ and then ‘resize2fs -p /dev/mapper/crypt1’.
  13. Hopefully you’re done now 😉

Fedora 23+ post-installation tweaks

This list is intended mainly for my personal use, i.e. the handy cheat sheet of things necessary/nice to have for me on Fedora system.

Autologin

  1. Users – <user> – Automatic Login
  2. Go to ~/.local/share/keyrings
  3. Rename the existing keyrings
  4. On the next restart enter blank new password
  5. Re-login to Online Accounts (Google, etc.), if used

Turn numlock on automatically on startup

  • Add the following to ~/.config/autostart/numlockx.desktop:
    [Desktop Entry]
    Type=Application
    Name=numlockx
    Exec=sh -c ‘numlockx off; xdotool key Num_Lock’
  • Do the same for any other application to be started upon system start (Firefox/Chrome, Double Commander, Sublime, Thunderbird, etc.)

 

Disable ‘Software updates available’ notification

      • gsettings set org.gnome.software download-updates false
      • or disable the Gnome Software completely:
        • sudo systemctl mask packagekit.service

Install Double Commander

      • $ dnf config-manager –add-repo http://download.opensuse.org/repositories/home:/Alexx2000:/doublecmd-svn/Fedora_26/home:Alexx2000:doublecmd-svn.repo
      • $ dnf install doublecmd-gtk
      • Configuration->Options->Tools->Editor->Use External Program: /usr/bin/code
      • Configuration->Options->Tools->Differ->Use External Program: /usr/bin/bcompare
      • Configuration->Options->Tools->Terminal->Command (all): gnome-terminal
      • Configuration->Options->Keys->Hot keys
        • cm_EditPath .. Alt+D
        • cm_RunTerm .. F1
        • cm_Search .. Ctrl+F
        • cm_CompareContent .. Ctrl+Shift+O
      • Configuration->Options->Quick search/filter->Exact name match .. uncheck both Beginning and Ending

Remove old kernels

      • package-cleanup –oldkernels
      • if it’s needed to remove an entry from GRUB list, then also run ‘sudo grub2-mkconfig’

Install RPM fusion repository for codecs, VLC, flash player, etc.

Install GNOME extensions

Tweak up bash

      • edit /etc/bashrc per http://files.bocekm.com/bashrc
      • edit GNOME terminal shortcuts
        • New terminal in new tab: Ctrl+T
        • New terminal in new window: Ctrl+N
        • Close terminal: Ctrl+W

 

Download Roboto font

Switch to Desktop hotkey

      • Use Win+D shortcut for switching to Desktop: Keyboard – Shortcuts – Navigation – Hide all normal windows

Hints:

    • To move window from one display to another use Win+Shift+Left/Right

DD-WRT for TP-LINK WR841N/WR841ND

TP-LINK WR841N (shares the same hardware with WR841ND, which has detachable antennas) is solid and powerful router coming with pretty low price tag. However the original firmware is unstable with not much customizations possible. Let’s install famous Linux-based DD-WRT firmware. Fortunately our WR841N is supported and it’s fairly simple to install this firmware.

  1. As a security measure, perform a 30/30/30 rule
  2. Determine your device hardware version
  3. Go to download location for build r23720 from 13/03/2014 which has been reported as working fine
  4. Search for your device specific build with the HW version suffixed, like v8 in tplink_tl-wr841ndv8, and make sure you download factory-to-ddwrt.bin for the first flash of DD-WRT
  5. Open admin center of the router being connected to computer using RJ45 (not WiFi)
  6. System Tools -> System Upgrade -> Choose File and find the downloaded factory-to-ddwrt.bin
  7. Set the DD-WRT to your liking by connecting to the admin center using default IP address 192.168.1.1, user root and password admin

I was able to achieve the maximum TX power of 21 dBm with the following settings. With default settings the max TX power was 18 dBm.

Wireless Network Mode: NG-Mixed
Channel Width: Turbo (40 MHz)
Regulatory Domain: NEW_ZEALAND
TX Power: 22 dBm
Antenna Gain: 5 dBi

Tested and working with TP-LINK WR841N v8 and DD-WRT build r23598.

WordPress website on Synology NAS

This is a tutorial on how to set up Synology NAS running DiskStation Manager 5.0 so that WordPress website is visible from the internet, even with a dynamic IP address from your internet provider. My goal was to get my own website as cheap as possible. For that I’ve utilized Synology NAS DS214se and domain name registrar easyDNS.

Dynamic DNS

Even though my internet service provider (UPC Czech Republic) offers a static IP for an extra money I didn’t want to accept that before exploring another ways of connecting to my server. Synology provides a complimentary DDNS hostname for you in format <your domain>.synology.me. It’s the same service you can get from well-known noip.com. Connecting to this address gets you always to your NAS, whatever IP address you’ve been provided by your ISP.

Naked domain

Another challenge awaits us when dealing with domain registrars. Even though I had one second-level domain before, it was not possible with my domain registrar to set my apex (aka naked) domain to the *.synology.me DDNS address. That’s not about incompetence of the domain registrar, it’s about limitations of the DNS RFC. However there are a few companies which found a workaround and they provide the ability to set the hostname (not IP address) even for the apex domain. Most of the registrars consider it as a premium service, except for easyDNS, which offers such capability complimentary for domains registered with them. I’ve chosen this way – to get new domain and point it to my NAS.  I’ve googled coupon with $10 discount so my new domain cost $5 instead of $15 for one year.

CMS

I’ve decided for WordPress website publication system because of tons of free templates and little of programming. Synology also offers system Drupal as a DSM package which is similar to WordPress, but because I have zero experience with these systems, I’ve chosen WordPress rather randomly. If you want to go the WordPress way like me, follow these steps to set up your NAS correctly:

  1. Enable Web Station in DSM -> Control Panel -> Web Services
  2. Install WordPress package through DSM Package Center
  3. The installed WordPress is accessible from http://<diskstation hostname>/wordpress by default
  4. To have possibility to move the installation to the root http://<diskstation hostname>, you need to change access permissions of the web folder
  5. Within DSM, go to File Station -> right-click on web folder -> Properties -> Permission -> add write permission to http group
  6. Now go to WordPress admin centre – http://<diskstation hostname>/wordpress/wp-admin
  7. In Settings -> General, change the ‘Site Address (URL)’ to http://<diskstation hostname>. Your WordPress has ‘Move Site Files’ plugin pre-installed (by Synology), which does everything for you.
  8. To change the ‘Site Address (URL)’ to custom internet address, like http://www.bocekm.com, you need to disable the ‘Move Site Files’, which handles moves just in the scope of the NAS
  9. Make sure you have  your router set up to forward port 80 to your NAS.  If your router supports UPnP, enable the port forwarding easily in Control Panel -> Info Center -> Service -> allow Web Station

Tested with Synology DS214se, DSM 5.0-4458 Update 1, WordPress package v3.8.1-018, easyDNS.com Domain Plus package.

Android development on Windows 8.1

Just a few information about using the latest available software (Mar 2014) together with Windows 8.1 (including Update 1) for Android application development. I will be updating this post when coming across another issue.

HAXM

Main reason of this article. If you use Intel HAXM to speedup your Android Virtual Device, do not use the installer downloaded by SDK manager (v1.0.6). There is a bug causing BSOD (CRITICAL_STRUCTURE_CORRUPTION). Just go to Intel site and download fixed v1.0.7 (just for Win 8.1).

ADT bundle

Download the latest 20140321 bundle. If you have download the previous one (I believe from Oct 2013) you would need to update ADT Plugin for Eclipse (to v22.6.1 and above). Go to Help -> Install New Software -> “Work with:” https://dl-ssl.google.com/android/eclipse/ (better to check the address here) -> update Developer Tools.

JDK

JDK 8 seems stable and possible to use with ADT so far.

Google Style

Adopt the Google style of Java code formatting. To setup Eclipse formatter according to this style:

  1. Save this xml to your local drive
  2. Go to Window -> Preferences -> Java -> Code Style -> Formatter
  3. Import the xml from step 1
  4. Activate GoogleStyle profile
  5. Format your code by using Ctrl+Shift+F hotkey

SVN server on Synology DSM 5.0

It’s pretty easy to set up the SVN server together with WebSVN feature. I’m running DSM 5.0 on Synology DiskStation DS214se. Thanks to tagd from this forum post I managed to integrate WebSVN without hassle.

  1. Install SVN package through DSM Package Center
  2. Using the SVN diskstation package UI, create a repository and user who can access it
  3. Enable Web Station in DSM Control Panel and create new Virtual Host let’s say ‘websvn’ on port 80
  4. (Optional) Set up WebSVN
    1. Download WebSVN zip and extract it into a web/websvn folder we created through Virtual Host
    2. Make a copy of web/websvn/include/distconfig.php and rename it to config.php
    3. In config.php add one line somewhere around line 100 as follows:
      $config->addRepository('<repository name>','svn://<diskstation hostname or IP>/<repository name from step 2>',null,'<user from step 2>','<password>');
    4. If you wish to restrict access to the WebSVN page, follow this tutorial with the following updates to it.
      1. It is slightly outdated so if you use DSM 5.0 and later, substitute the /usr/syno/apache/ folder with /etc/httpd/.
      2. To have diff listing working add the following line to config.php somewhere around line 484:
        $config->setTempDir('/etc/websvn');
  5. If you want to work with the repository from outside your local network, set up port forwarding for port 3690 (svn) and port 80 (websvn). If your router supports UPnP, enable the port forwarding easily in Control Panel -> Info Center -> Service.

It worked for me having installed DSM 5.0-4458 Update 1, SVN package v1.8.5-0024 and WebSVN v2.3.3.

Windows 8.1 tips for new users

Coming from Windows 7 or older system to Windows 8.1 one can get easily frustrated by slightly different philosophy of usage. Needless to say that Windows 8.1 improved the user experience for newcomers, especially with the Update 1. Here are some tips which can help you to overcome the frustration a bit.

Go to desktop after startup (instead of Start)

Right Click on taskbar -> Properties -> Navigation -> “When I sign in or close apps on screen, go to the desktop instead of Start”

Language shortcut change from Win + Space to Alt + Shift

Left click keyboard section of taskbar -> Language Preferences -> Advanced Settings -> Change language bar hot keys

Disable automatic restarts

http://blog.laptopmag.com/disable-automatic-restart-windows

Remove folders from This PC

http://www.howtogeek.com/168081/how-to-remove-the-folders-from-my-computer-in-windows-8.1/

Disable OneDrive

http://www.groovypost.com/howto/hide-disable-skydrive-windows-8-1/

Disable required password on wakeup

Press Win+X -> Power Options -> Require a password on wakeup -> Change setting that are currently unavailable (depends on your UAC settings) -> Don’t require a password

Disable autosleep

Press Win+X -> Power Options -> Change when the computer sleeps -> Change advanced power settings -> Sleep/Hibernate -> Sleep/Hibernate after -> Never

Disable password at logon

Press Win+R -> run netplwiz -> uncheck ‘Users must enter a user name and password to use this computer’