Friday, July 11, 2014

Kindle for offline html docs reading

Summer is here, while laying on the beach, you can use the time to learn new programming language or get some overview on the framework of your interest. Possibly the things you had no time left for over the year.

I bought myself Kindle, my beach holiday is just a day away, so it’s time to fill the reader with content.

Goal

Get an online html docs to Kindle for offline reading.

Required software

  • wget - download program
  • calibre - ebook reader/converter/…

Process

  1. find the docs you’re interested in (I’ll refer to <http://your-manual.com> as the url of the docs of my interest)
  2. download it (I used wget to do so, inspired by stackoverflow answer, please note this is expecting all docs no one domain only):

    wget --recursive --timestamping -l inf --no-remove-listing --page-requisites <http://your-manual.com>
  3. start calibre
  4. drag&drop the downloaded index (main) page to calibre
  5. convert to mobi format (via right click on the book and choosing Convert Books -> Convert individually afterwards editing metadata and choosing mobi as the Output format)
  6. connect your kindle (via usb)
  7. send ebook to device - via right clicking the ebook and choosing: Send to device -> Send to main memory
  8. done!

The valuable part

Well, the challenging part is for me always to actually digest the docs. So go ahead and read it (if it’s worth it). Self-discipline, I need to work on that, I guess.

Wednesday, June 25, 2014

Migrating from bash to zsh

These are my steps in migration from bash to zsh. I’m documenting these to keep the future reference for me (and possibly other readers as well).

Motivation?

Check out the Slideshare presentation: Why Zsh is Cooler than Your Shell

Current shell

to find out the current shell:

ps -p $$

it’s useful during migration to make sure the new shell is really in use.

Migration

Migration itself included (on my Fedora) reconfiguring:

oh-my-zsh

There exists users’ maintained collection of zsh customizations, that I found useful. Called: oh-my-zsh. (Please note the amazing Github’s - Star count. Once seeing that I didn’t doubt I’ll give it a try.)

For installation I just went for:

curl -L http://install.ohmyz.sh | sh

oh-my-zsh with powerline

I’m used to powerline everywhere ((g)vim/konsole/tmux/bash) already, so let’s keep it working in zsh as well.

I created file: ~/.oh-my-zsh/custom/powerline.zsh with contents:

. ~/.local/lib/python2.7/site-packages/powerline/bindings/zsh/powerline.zsh

Please note: You need to go for the actual location of powerline installation on your system.

and in the file: ~/.zshrc I had to comment out line:

# ZSH_THEME="robbyrussell"

otherwise oh-my-zsh theme seems to conflict with powerline one.

oh-my-zsh plugins

The real benefit of oh-my-zsh commes with plugins, so I went for those I find useful. Via changing the file: ~/.zshrc having:

plugins=(git mvn glassfish yum colored-man vagrant z common-aliases gradle)

oh-my-zsh custom stuff

As my ~/.bashrc held already quite some customizations, I migrated those to:

~/.oh-my-zsh/custom/*.zsh

Even this part was nice, as I could tidy up things a bit and omit unused stuff. Moreover I decided to create multiple *.zsh files (as these are auto-loaded) to achieve modularity.

Done

Honestly in the beginning, I had no clue how much I would enjoy my new shell.

Friday, June 13, 2014

Xfce: How to disable toolbar text in KDE apps

Recently I’ve experienced quite a funny situation. I use Krusader for file browsing that calls Kompare for file comparisons. However I was not able to copy changes from left to right (or vice versa) in the compared files, as I could not see all the toolbar buttons (these were too big). I didn’t even notice for quite some time, that there are others, not displayed on my screen.

But who needs text description in toolbars? Well, I don’t!

I remembered global setting from the Gnome world that it should be possible, so searched from the KDE equivalent.

Found it (in my Fedora + Xfce) in:

Xfce menu button -> Options (hope this one is right, as I have it as Einstellungen) -> KDE SystemOptions (for me KDE SystemEinstellungen) -> Style (Stil) -> Fine Tuning tab -> Toolbars section
where I just chose No Text in the both: Main toolbar text as well as in the Secondary toolbar text.

That did the job for me.

Apache Ant tasks for JMX access

I wanted to invoke JMX operations from the Ant tasks. However finding usable ant tasks library as well as the usage was rather tricky. So let me share my experience to make things easier for others.

Ant tasks for JMX operations

I decided to follow Tomcat documentation and used ant tasks distributed with tomcat.

Just for the record the usage is not restricted to Tomcat deployed JMX mBeans. For me it worked for java process accessible via JConsole via Remote connection.

Retrieving the library

  1. As I wanted to get the latest version I used maven central repository “search by classname” feature and searched for: org.apache.catalina.ant.jmx.JMXAccessorTask (see the query)
  2. afterwards I went for the tomcat 8 jar file (called tomcat-catalina-ant-8.0.8.jar)
  3. and just copyied the latest available to my $ANT_HOME/lib dir.

Usage

I didn’t have a chance (or motivation?) to check all the tasks available, the full list of tasks available can be seen in the zipped file: org/apache/catalina/ant/jmx/antlib.xml, following were present for me:

<typedef
    name="open"
    classname="org.apache.catalina.ant.jmx.JMXAccessorTask" />
<typedef
    name="set"
    classname="org.apache.catalina.ant.jmx.JMXAccessorSetTask" />
<typedef
    name="get"
    classname="org.apache.catalina.ant.jmx.JMXAccessorGetTask" />
<typedef
    name="invoke"
    classname="org.apache.catalina.ant.jmx.JMXAccessorInvokeTask" />
<typedef
    name="query"
    classname="org.apache.catalina.ant.jmx.JMXAccessorQueryTask" />
<typedef
    name="create"
    classname="org.apache.catalina.ant.jmx.JMXAccessorCreateTask" />
<typedef
    name="unregister"
    classname="org.apache.catalina.ant.jmx.JMXAccessorUnregisterTask" />
<typedef
    name="equals"
    classname="org.apache.catalina.ant.jmx.JMXAccessorEqualsCondition" />
<typedef
    name="condition"
    classname="org.apache.catalina.ant.jmx.JMXAccessorCondition" />

out of these, I gave following a try:

org.apache.catalina.ant.jmx.JMXAccessorTask
org.apache.catalina.ant.jmx.JMXAccessorInvokeTask
org.apache.catalina.ant.jmx.JMXAccessorQueryTask

For the demonstration purposes I’m using Glassfish 4.0.

Example: Listing JMX MBeans

Let’s assume we want to retrieve the MBean by name (namely: java.lang:type=Memory). Please note username and password were not required for access (otherwise they should be specified via respective properties).

Noteworthy here is the resultproperty, which could hold array from which we could get a name. So having in ant build script:

<typedef 
    name="jmxQuery"
    classname="org.apache.catalina.ant.jmx.JMXAccessorQueryTask" />

<jmxQuery
    host="localhost"
    port="8686"
    echo="true"
    name="java.lang:type=Memory"
    resultproperty="memory" />

<echo>Retrieved MBeans count: ${memory.Length}</echo>
<echo>The 1.st one has name: ${memory.0.Name}</echo>

results for me in following output:

 [jmxQuery] memory.Length=1
 [jmxQuery] memory.0.Name=java.lang:type=Memory
     [echo] Retrieved MBeans count: 1
     [echo] The 1.st one has name: java.lang:type=Memory

Example: Invoking operation via JMX

Here is a 2 step approach required:

  1. connect to remote server via JMX and afterwards
  2. invoke the operation on the particular MBean.

For demonstration purposes, let’s assume we want to call garbage collection (via invoking operation: gc() on MBean named: java.lang:type=Memory)

Sample ant build file chunk does the job (please note ref property value that has to be the same across these 2 tasks):

<typedef 
    name="jmxOpen"
    classname="org.apache.catalina.ant.jmx.JMXAccessorTask" />

<typedef 
    name="jmxInvoke"
    classname="org.apache.catalina.ant.jmx.JMXAccessorInvokeTask" />

<jmxOpen
    host="localhost"
    port="8686"
    ref="glassfish"
    failOnError="true" />

<jmxInvoke
    name="java.lang:type=Memory"
    operation="gc"
    echo="true"
    delimiter=" "
    failOnError="true"
    ref="glassfish" />

Further information

For more details, I recommend reading the official Tomcat documentation as well as Javadocs.

Thursday, June 12, 2014

Using Genius TVGo DVB-T03 on Fedora

My other laptop was not available and the start of Football WM 2014 was just less than 30 minutes away. Let’s see if I can watch it on my laptop with Fedora (16) with my Genius TVGo DVB-T03 device.

The most of the steps were inspired by fedora wiki: https://fedoraproject.org/wiki/DavidTimms/DVB

DVB-T required package

I installed dvb-apps package via:

sudo yum install dvb-apps

Afterwards checked the file list in package via:

rpm -q --fileprovide dvb-apps

which contained also:

/usr/bin/scandvb

(please note we’ll need this one later).

Firmware

I plugged in my dvb-t usb and seen after running dmesg:

[11140.318728] usb 2-1.2: new high-speed USB device number 6 using ehci-pci
[11140.397936] usb 2-1.2: New USB device found, idVendor=0458, idProduct=4012
[11140.397946] usb 2-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[11140.397952] usb 2-1.2: Product: DVB-T 2
[11140.397956] usb 2-1.2: Manufacturer: Afatech
[11140.557325] usbcore: registered new interface driver dvb_usb_af9015
[11140.557753] usb 2-1.2: dvb_usb_v2: found a 'Genius TVGo DVB-T03' in cold state
[11140.557900] usb 2-1.2: dvb_usb_v2: Did not find the firmware file 'dvb-usb-af9015.fw'. Please see linux/Documentation/dvb/ for more details on firmware-problems. Status -2
[11140.557905] usb 2-1.2: dvb_usb_v2: 'Genius TVGo DVB-T03' error while loading driver (-2)

so searched a bit and found + downloaded rpm from: http://pkgs.org/fedora-centos-rhel-opensuse-mandriva/olea/dvb-usb-af9015-fw-4.95.0-1.noarch.rpm.html

Afterwards installed the downloaded firmware via:

sudo rpm -ivh dvb-usb-af9015-fw-4.95.0-1.noarch.rpm

And finally unplugged and plugged to usb again to see:

[11796.948500] usb 2-1.1: new high-speed USB device number 7 using ehci-pci
[11797.038703] usb 2-1.1: New USB device found, idVendor=0458, idProduct=4012
[11797.038714] usb 2-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[11797.038720] usb 2-1.1: Product: DVB-T 2
[11797.038725] usb 2-1.1: Manufacturer: Afatech
[11797.041521] usb 2-1.1: dvb_usb_v2: found a 'Genius TVGo DVB-T03' in cold state
[11797.042331] usb 2-1.1: dvb_usb_v2: downloading firmware from file 'dvb-usb-af9015.fw'
[11797.119176] usb 2-1.1: dvb_usb_v2: found a 'Genius TVGo DVB-T03' in warm state
[11797.542424] usb 2-1.1: dvb_usb_v2: will pass the complete MPEG2 transport stream to the software demuxer
[11797.542542] DVB: registering new adapter (Genius TVGo DVB-T03)
[11797.575204] i2c i2c-7: af9013: firmware version 4.95.0.0
[11797.578207] usb 2-1.1: DVB: registering adapter 0 frontend 0 (Afatech AF9013)...
[11797.589973] tda18271 7-00c0: creating new instance
[11797.597341] TDA18271HD/C1 detected @ 7-00c0
[11797.802656] Registered IR keymap rc-empty
[11797.802848] input: Genius TVGo DVB-T03 as /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1/rc/rc0/input12
[11797.803814] rc0: Genius TVGo DVB-T03 as /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1/rc/rc0
[11797.803825] usb 2-1.1: dvb_usb_v2: schedule remote query interval to 500 msecs
[11797.803832] usb 2-1.1: dvb_usb_v2: 'Genius TVGo DVB-T03' successfully initialized and connected

so firmware seems to work now.

Generating channels.conf

Following command did the job for me (as I’m located in Bayern):

scandvb /usr/share/dvb/dvb-t/de-Bayern  > channels.conf

Enjoying the broadcasts

There is no me-tv (that I’m used to it from Ubuntu world), still, there is a vlc, that does the job for me quite well. Just running:

vlc channels.conf

made it and I could watch the game!

Friday, June 6, 2014

Eclipse plugin for svn integration

I’ve found it tricky to install Eclipse plugin providing svn integration.

The problem is:

  • which plugin to choose,
  • which version of the plugin to choose as well as
  • which packages to install.

I’m running latest Eclipse (Kepler SR2) and plugin of my choice is subclipse.

The Eclipse plugin update site has to be chosen based on the svn version installed on the machine (check it running svn --version):

Following packages were required for installation (for me):

  • Subclipse (Required)
  • SVNKit Client Adapter (Not Required)
  • SVNKit Library

That’s it! As it covers my Eclipse/svn day-to-day workflow.

Tuesday, March 4, 2014

Markdown editor for blogger

Markdown is quite popular these days and I like it for it’s simplicity. So I’ve been searching for a way to integrate it in my blog writing workflow. In Blogger, it’s unfortunately not an option.

There I could go:

  • either for WYSIWYG editor or
  • manual HTML writing.

However WYSIWYG generates too much HTML I don’t need. Moreover some pre-publish manual HTML editing is a pain then. And the other option I consider it rather slow/unproductive.

So, I looked for other options, and found stackedit.io. Even this post is (and couple others as well) written in it.

stackedit

I consider Stackedit great as it:

  • is Markdown editor,
  • is open source (see github repo),
  • has awesome UI (including live preview, key bindings, …),
  • has integration with other popular services that I use anyway:
  • has active community (just check the stars count and commit activity on the github repo) and
  • has impressive feedback time (resolution on my issues/questions came in couple hours)

So my post writing/editing workflow goes like this:

  1. write/edit post on stackedit.io,
  2. sync it to google drive and
  3. publish/republish it to blogger.

That’s it! No further in-blogger updates required!

Blogger specifics

Still there are some specifics in my workflow (to provide smooth blogger integration).

  • using the Interpreted variables: title and tags via:
---
title: Markdown editor for blogger
tags: blogger markdown stackedit.io
---