tag:blogger.com,1999:blog-48112304114638022772024-02-19T08:20:19.145+01:00pb's blog about life and ITAnonymoushttp://www.blogger.com/profile/11194363658850134703noreply@blogger.comBlogger71125tag:blogger.com,1999:blog-4811230411463802277.post-85936911735343127922015-09-19T07:26:00.001+02:002015-09-19T07:26:09.438+02:00Adding new machine to rc files sync<p>Some time ago I wrote a post on <a href="http://peter-butkovic.blogspot.com/2014/10/linux-productivity-tools-for-me.html">linux productivity tools I use</a>. <br>
As from time to time I need to install new machine that would benefit from the synced rc files, I’ll document the steps required (as rediscovering it every time is rather a waste of time).</p>
<h2 id="what-id-need">What I’d need</h2>
<p>I’ll use the previously introduced: <br>
* <a href="https://github.com/robbyrussell/oh-my-zsh">oh-my-zsh</a> <br>
* <a href="https://github.com/andsens/homeshick">homeshick</a> <br>
* vim’s <a href="https://github.com/VundleVim/Vundle.vim">vundle plugin</a> and <br>
* <a href="https://tmux.github.io/">tmux</a> with <a href="https://github.com/tmuxinator/tmuxinator">tmuxinator</a> <br>
* powerline fonts</p>
<p>Please note: order is important here, otherwise some install steps might fail. </p>
<h2 id="oh-my-zsh">oh-my-zsh</h2>
<p>Install via:</p>
<pre style="" class="prettyprint prettyprinted"><code><span class="pln">sh </span><span class="pun">-</span><span class="pln">c </span><span class="str">"$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"</span></code></pre>
<h2 id="homeshick">homeshick</h2>
<p>Install via:</p>
<pre style="" class="prettyprint prettyprinted"><code><span class="pln">git clone git</span><span class="pun">:</span><span class="com">//github.com/andsens/homeshick.git $HOME/.homesick/repos/homeshick</span></code></pre>
<p>Get existing dotfiles via:</p>
<pre style="" class="prettyprint prettyprinted"><code><span class="pln">cd $HOME</span><span class="pun">/.</span><span class="pln">homesick</span><span class="pun">/</span><span class="pln">repos
$HOME</span><span class="pun">/.</span><span class="pln">homesick</span><span class="pun">/</span><span class="pln">repos</span><span class="pun">/</span><span class="pln">homeshick</span><span class="pun">/</span><span class="pln">bin</span><span class="pun">/</span><span class="pln">homeshick clone </span><span class="pun"><</span><span class="pln">your git repo</span><span class="pun">></span></code></pre>
<p>For me, as I use the private bitbucket repo, I just had to add the ssh keys generated to bitbucket first:</p>
<ol>
<li>generate ssh key via (following <a href="https://help.github.com/articles/generating-ssh-keys/">https://help.github.com/articles/generating-ssh-keys/</a>)</li>
<li>go to repo on bitbucket via web browser</li>
<li>add generated key at: <code>Settings</code> -> <code>Deployment keys</code></li>
</ol>
<p>And run the</p>
<pre style="" class="prettyprint prettyprinted"><code><span class="pln">cd $HOME</span><span class="pun">/.</span><span class="pln">homesick</span><span class="pun">/</span><span class="pln">repos
$HOME</span><span class="pun">/.</span><span class="pln">homesick</span><span class="pun">/</span><span class="pln">repos</span><span class="pun">/</span><span class="pln">homeshick</span><span class="pun">/</span><span class="pln">bin</span><span class="pun">/</span><span class="pln">homeshick clone git@bitbucket</span><span class="pun">.</span><span class="pln">org</span><span class="pun">:</span><span class="pln">typekpb</span><span class="pun">/</span><span class="pln">dotfiles</span><span class="pun">.</span><span class="pln">git</span></code></pre>
<p>Make sure to let homeshick symlink all the dotfiles from the repo (you might want to back up those to be overwritten). You’ll be prompted for symlinking stuff.</p>
<h2 id="vims-vundle-plugin">vim’s vundle plugin</h2>
<p>As a prerequisite you’d need (g)vim installed (install instructions would be distro specific).</p>
<p>Install vundle plugin via:</p>
<pre style="" class="prettyprint prettyprinted"><code><span class="pln">git clone https</span><span class="pun">:</span><span class="com">//github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim</span></code></pre>
<p>Afterwards install all the vundle managed plugins via running in the vim:</p>
<pre style="" class="prettyprint prettyprinted"><code><span class="pun">:</span><span class="typ">BundleInstall</span></code></pre>
<h2 id="tmuxinator">tmuxinator</h2>
<p>Make sure to install tmux and ruby first (probably from the distro packages available).</p>
<pre style="" class="prettyprint prettyprinted"><code><span class="pln">gem install tmuxinator</span></code></pre>
<p>if it’s to be installed globally, use:</p>
<pre style="" class="prettyprint prettyprinted"><code><span class="pln">sudo gem install tmuxinator</span></code></pre>
<h2 id="powerline-fonts">powerline fonts</h2>
<p>Following the <a href="https://powerline.readthedocs.org/en/latest/installation/linux.html#fonts-installation">official instructions</a>:</p>
<pre style="" class="prettyprint prettyprinted"><code><span class="pln">cd </span><span class="pun">/</span><span class="pln">tmp
wget https</span><span class="pun">:</span><span class="com">//github.com/powerline/powerline/raw/develop/font/PowerlineSymbols.otf</span><span class="pln">
wget https</span><span class="pun">:</span><span class="com">//github.com/powerline/powerline/raw/develop/font/10-powerline-symbols.conf</span><span class="pln">
mkdir </span><span class="pun">~/.</span><span class="pln">fonts
mv </span><span class="typ">PowerlineSymbols</span><span class="pun">.</span><span class="pln">otf </span><span class="pun">~</span><span class="str">/.fonts/</span><span class="pln">
fc</span><span class="pun">-</span><span class="pln">cache </span><span class="pun">-</span><span class="pln">vf </span><span class="pun">~</span><span class="str">/.fonts/</span><span class="pln">
mkdir </span><span class="pun">-</span><span class="pln">p </span><span class="pun">~</span><span class="str">/.config/</span><span class="pln">fontconfig</span><span class="pun">/</span><span class="pln">conf</span><span class="pun">.</span><span class="pln">d</span><span class="pun">/</span><span class="pln">
mv </span><span class="lit">10</span><span class="pun">-</span><span class="pln">powerline</span><span class="pun">-</span><span class="pln">symbols</span><span class="pun">.</span><span class="pln">conf </span><span class="pun">~</span><span class="str">/.config/</span><span class="pln">fontconfig</span><span class="pun">/</span><span class="pln">conf</span><span class="pun">.</span><span class="pln">d</span><span class="pun">/</span></code></pre>
<p>after restart seems to work OK.</p>
<p>Done :)</p>Anonymoushttp://www.blogger.com/profile/11194363658850134703noreply@blogger.com0tag:blogger.com,1999:blog-4811230411463802277.post-20965542823910817792015-01-06T20:08:00.001+01:002015-01-06T20:08:50.425+01:00Ubuntu 14.04 with HP Deskjet 930c<p>I’ve got old printer: HP Deskjet 930c. Following steps were necessary to use it with my Ubuntu 14.04:</p>
<ol>
<li>Printer: start + connect it via USB</li>
<li>download HP drivers bundle called: HP Linux Imaging and Printing from: <a href="http://hplipopensource.com/hplip-web/gethplip.html">http://hplipopensource.com/hplip-web/gethplip.html</a></li>
<li>install bundle via (answering couple yes/overwrite questions):</li>
</ol>
<pre style="" class="prettyprint prettyprinted"><code><span class="pln">chmod </span><span class="pun">+</span><span class="pln">x hplip</span><span class="pun">-</span><span class="lit">3.14</span><span class="pun">.</span><span class="lit">10.run</span><span class="pln"> </span><span class="pun">&&</span><span class="pln"> </span><span class="pun">./</span><span class="pln">hplip</span><span class="pun">-</span><span class="lit">3.14</span><span class="pun">.</span><span class="lit">10.run</span><span class="pln"> </span></code></pre>
<p>You should see your new printer afterwards.</p>Anonymoushttp://www.blogger.com/profile/11194363658850134703noreply@blogger.com3tag:blogger.com,1999:blog-4811230411463802277.post-42960770834990831392014-10-24T12:32:00.001+02:002014-10-24T12:41:56.998+02:00Linux productivity tools for me<p>This is the stack/are the tools that <strong>keep me productive in my day to day programming experience on linux</strong>.</p>
<p>Well, first of all let me tell you, that this might not fit your needs , as I’m a full time java programmer so have OS choices open (still I won’t go to my java-related stuff here, to make infos general and possibly usable for non-java guys as well.).</p>
<p>Linux is my choice for quite some years already and this post won’t detail the reasons, rather will focus on tools/utilities that help me survive in this world.</p>
<h2 id="distro">Distro</h2>
<p>Well, let’s start from the ground. I don’t have a clear winner here. In fact I run currently 3 different ones (didn’t count my router and phone here):</p>
<ul>
<li><a href="http://fedoraproject.org/"><strong>Fedora</strong></a> - on my work laptop</li>
<li><a href="http://xubuntu.org/"><strong>Xubuntu</strong></a> - on my home laptop</li>
<li><a href="http://www.raspbian.org/"><strong>Raspbian</strong></a> (Debian) - on my Raspberry Pi server</li>
</ul>
<p>In fact the info present in this post won’t detail too much on the 3.rd one, as it’s a server that just runs. The only thing I need there is a ssh access and that’s pretty much it, so this post would be rather short for that one :)</p>
<p>The reasons for Fedora, and Ubuntu in my case are:</p>
<ul>
<li><strong>stability</strong> (well, let’s say things don’t crash that often for me),</li>
<li><strong>packages</strong> for most of the SW I need <strong>available in repositories</strong> and</li>
<li>the software packages are <strong>not at some archaic versions</strong>.</li>
</ul>
<h2 id="window-manager">Window manager</h2>
<p>Well, the nice thing is that most common window managers are available across all the popular distros. <strong>My choice here is <a href="http://www.xfce.org/">Xfce</a></strong>. </p>
<p>Well, I don’t hate others, this just fits my needs best:</p>
<ul>
<li><strong>no</strong> need for <strong>fancy effects</strong> for me as</li>
<li><strong>speed</strong> is rather my preference. </li>
<li>still I need <strong>something that I would not fight with every day</strong>.</li>
</ul>
<p><strong>Project I’m keeping my eye on is: <a href="http://lxqt.org/">LXQt</a></strong>. Still waiting for a more stabilized release (0.8 was released recently, which says to be ready for production desktops, but I’d plan to give it a try with the next release as well as when I have some time to set it up).</p>
<h2 id="shell">Shell</h2>
<p>I have 2 candidates here:</p>
<ul>
<li><strong>bash</strong> and</li>
<li><strong>zsh</strong>.</li>
</ul>
<p><strong>bash I use for scripting</strong>. It’s been my choice for quite some time already and I don’t see a need for change any time soon. As I’m quite used to it and the most people/projects I share the scripts with are OK with that/have used it already.</p>
<p><strong>zsh as my default shell</strong>. This is still the world I consider new to me (see my <a href="http://peter-butkovic.blogspot.de/2014/06/migrating-from-bash-to-zsh.html">recent post on that</a>).</p>
<h2 id="shell-env-sync">Shell env sync</h2>
<p>As I have multiple machines I’m working on, there are 2 essential projects in the area for me:</p>
<ul>
<li><a href="https://github.com/robbyrussell/oh-my-zsh"><strong>oh-my-zsh</strong></a> as well as</li>
<li><a href="https://github.com/andsens/homeshick"><strong>homeshick</strong></a>.</li>
</ul>
<p><strong>oh-my-zsh</strong></p>
<p>Provides for my zsh:</p>
<ul>
<li><strong>nicely/systematically structured plugin</strong> approach,</li>
<li><strong>autocompletition</strong> and</li>
<li>all sorts of <strong>aliases</strong>.</li>
</ul>
<p>To document my use case a bit here, these are the plugins I have present in my <code>.zshrc</code>:</p>
<pre style="" class="prettyprint prettyprinted"><code><span class="pln">plugins</span><span class="pun">=(</span><span class="pln">git mvn glassfish yum colored</span><span class="pun">-</span><span class="pln">man vagrant z common</span><span class="pun">-</span><span class="pln">aliases gradle homeshick vim</span><span class="pun">-</span><span class="pln">interaction powerline tmuxinator tmux</span><span class="pun">)</span></code></pre>
<p>Please note: Some are not available officially, and in the time of writing are just present as pull request from me to the project. Namely:</p>
<ul>
<li><a href="https://github.com/robbyrussell/oh-my-zsh/pull/3142">homeshick</a> and</li>
<li><a href="https://github.com/robbyrussell/oh-my-zsh/pull/3139">powerline</a>.</li>
</ul>
<p>Well, might sound like a self promotion, but feel free to check and provide feedback on these if you find them useful.</p>
<h2 id="homeshick">Homeshick</h2>
<p>Lets me <strong>synchronize</strong> all my custom zsh plugins as well as <code>.bashrc</code> files <strong>over git repository</strong>.</p>
<p>The only <strong>requirements</strong> are:</p>
<ul>
<li><strong>git and bash</strong> on all the clients</li>
<li>and the <strong>git repo</strong> accessible from all my clients.</li>
</ul>
<p>In my case, there are things I don’t want to expose to public, but have no problem to have it hosted in some private git repo. So <a href="https://bitbucket.org/"><strong>bitbucket</strong></a> is my choice, as I have there <strong>private git repo for free for the purpose</strong>.</p>
<h2 id="shell-sessions-bootstrapping">Shell sessions bootstrapping</h2>
<p>There are 2 important projects for me here:</p>
<ul>
<li><a href="http://tmux.sourceforge.net/"><strong>tmux</strong></a> and</li>
<li><a href="https://github.com/tmuxinator/tmuxinator"><strong>tmuxinator</strong></a>.</li>
</ul>
<p>Tmux and tmuxinator enable me to have just one yaml formatted file for bootstrapping my terminals.</p>
<p>I preffer it to having multiple tabs open in some GUI terminal, as it:</p>
<ul>
<li><strong>bootstraps all my shells</strong> daily in a same/reproducible way,</li>
<li>provides me with the <strong>nice way on organizing</strong> these and</li>
<li><strong>navigation</strong> between these works with <strong>keyboard only</strong> <strong>=></strong> switching between different tasks becomes after some time of usage just a <strong>routine</strong>.</li>
</ul>
<p>So no more searching in countless cards/windows for particular task.</p>
<h2 id="shell-productivity">Shell productivity </h2>
<p>I don’t want to list all the linux utils I use, as I guess I’d make list too long and too boring (even for me to write). So let’s just name some, that I consider worth it:</p>
<ul>
<li><a href="http://beyondgrep.com/"><strong>ack</strong></a> - powerful grep replacement (I might document in the separate blog post),</li>
<li><strong>notify-send</strong> and</li>
<li>all sorts of aliases and zsh/bash functions, that would be too many to list here, moreover might be too specific and useless for others.</li>
</ul>
<h2 id="notify-send">Notify-send</h2>
<p>I <a href="http://peter-butkovic.blogspot.de/2013/06/making-notify-send-work-on-fedora-17.html">blogged about notify-send already</a>. </p>
<p>I use it for all the app-server (in my case Glassfish) lifecycle management operations (start/stop/restart domain) as well as deployment stuff.</p>
<p>As these:</p>
<ul>
<li>take <strong>quite some time to finish</strong> and </li>
<li><strong>might end up with errors</strong>, </li>
</ul>
<p>I let it myself updated with <strong>notification having</strong>:</p>
<ul>
<li><strong>exit code</strong></li>
<li>chunk of the <strong>last couple lines from the log file</strong>.</li>
</ul>
<p>This is great, as I can work in parallel and it <strong>gets my attention, once the job is done.</strong></p>
<h2 id="desktop-app-launcher">Desktop app launcher</h2>
<p>Without having an option for fast startup of my favourite programs I’d waste my time searching the icons or menus.</p>
<p>As Xfce doesn’t provide me with the powerful one, I use: <a href="https://launchpad.net/synapse-project"><strong>Synapse</strong></a>.</p>
<h2 id="file-manager">File manager</h2>
<p>Well, there are times when I play with files in the command line, but sometimes it just fits better to use some UI for the purpose.</p>
<p>My choice is <a href="http://www.krusader.org/"><strong>Krusader</strong></a>. Well, the most stuff I need is available, namely:</p>
<ul>
<li><strong>file/folder manipulation</strong>,</li>
<li><strong>file folder comparison</strong> and</li>
<li><strong>file/folder contents search</strong>.</li>
</ul>
<p>The only thing that bothers me is the fact that development is rather stalled in the project.</p>
<p>Still, viable alternative might be: <a href="http://doublecmd.sourceforge.net/"><strong>Double commander</strong></a>, which seem to be even <strong>cross-platform</strong> and can <strong>use the total commander plugins</strong> (which used to be my choice on windows for the purpose).</p>
<h2 id="editor">Editor</h2>
<p>I tried to live with <a href="https://wiki.gnome.org/Apps/Gedit"><strong>Gedit</strong></a> and <strong>for simple note-taking</strong> it might be a good choice, however as I like to play with ruby these days, I tried to find something that would help more in the area. </p>
<h2 id="gvim">(G)Vim</h2>
<p>After searching I came to conclusion, that <a href="http://www.vim.org/"><strong>(G)Vim</strong></a> is quite popular in the Linux world. </p>
<p>Well, it’s worth to mention vim joke here, which expresses the feelings of many on this editor: <a href="https://twitter.com/iamdevloper/status/499623319008985088"><strong>Infinite Vim monkey theorem</strong></a> (see <a href="http://en.wikipedia.org/wiki/Infinite_monkey_theorem">Infinite monkey theorem</a> for explanation).</p>
<p>Still, I’ve seen:</p>
<ul>
<li><strong>many people favouring</strong> it,</li>
<li>it’s the first editor I remember to have available once logging in to my school linux account (OK no real argument, just sentiment),</li>
<li>it seemed to provide <strong>countless plugins</strong> for all sorts of stuff and</li>
<li>it’s <strong>incredibly powerful</strong>, as far as I’ve seen and learning it might pay back.</li>
</ul>
<p>So I decided cca 2 years back to uninstall the editors I’ve been used to and force myself to use (G)Vim.</p>
<p><strong>Great source of information</strong> was for me: <a href="http://vimcasts.org/"><strong>vimcasts</strong></a>, which helped me a lot in the area.</p>
<p>Well, I plan to document my <code>.vimrc</code> setup in a separate post, as it could make this one way too long.</p>
<h2 id="files-sync-tool">Files sync tool</h2>
<p><a href="http://www.cis.upenn.edu/~bcpierce/unison/"><strong>Unison</strong></a> is my choice her. For more info on my use case, see this <a href="http://peter-butkovic.blogspot.de/2013/08/raspberry-pi-driven-dropbox-alternative.html">blog post</a>.</p>
<h2 id="conclusion">Conclusion</h2>
<p>Hope you find some inspiration here. And would be glad to hear from you guys about any I missed, but you could not live without.</p>
<p>Still, I can’t believe anyone read this far. As I guess I would not force myself to :).</p>Anonymoushttp://www.blogger.com/profile/11194363658850134703noreply@blogger.com15tag:blogger.com,1999:blog-4811230411463802277.post-85393885848243542972014-07-11T15:43:00.003+02:002014-07-11T15:43:55.923+02:00Kindle for offline html docs reading<p>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.</p>
<p>I bought myself Kindle, my beach holiday is just a day away, so it’s time to fill the reader with content.</p>
<h2 id="goal">Goal</h2>
<p>Get an online html docs to Kindle for offline reading.</p>
<h2 id="required-software">Required software</h2>
<ul>
<li><a href="https://www.gnu.org/software/wget/">wget</a> - download program</li>
<li><a href="http://calibre-ebook.com/">calibre</a> - ebook reader/converter/…</li>
</ul>
<h2 id="process">Process</h2>
<ol>
<li>find the docs you’re interested in (I’ll refer to <code><http://your-manual.com></code> as the url of the docs of my interest)</li>
<li>download it (I used wget to do so, inspired by <a href="http://stackoverflow.com/questions/5240161/how-do-you-use-wget-with-mk-option-to-mirror-a-site-and-its-externally-linked">stackoverflow answer</a>, please note this is expecting all docs no one domain only): <br>
<code> <br>
wget --recursive --timestamping -l inf --no-remove-listing --page-requisites <http://your-manual.com> <br>
</code></li>
<li>start calibre</li>
<li>drag&drop the downloaded index (main) page to calibre</li>
<li>convert to mobi format (via right click on the book and choosing <code>Convert Books</code> -> <code>Convert individually</code> afterwards editing metadata and choosing <code>mobi</code> as the <code>Output format</code>)</li>
<li>connect your kindle (via usb)</li>
<li>send ebook to device - via right clicking the ebook and choosing: <code>Send to device</code> -> <code>Send to main memory</code></li>
<li>done!</li>
</ol>
<h2 id="the-valuable-part">The valuable part</h2>
<p>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.</p>Anonymoushttp://www.blogger.com/profile/11194363658850134703noreply@blogger.com3tag:blogger.com,1999:blog-4811230411463802277.post-89891810219328263232014-06-25T16:40:00.001+02:002014-06-25T16:53:00.801+02:00Migrating from bash to zsh<p>These are my steps in <strong>migration from bash to zsh</strong>. I’m documenting these to keep the future reference for me (and possibly other readers as well).</p>
<h2 id="motivation">Motivation?</h2>
<p>Check out the Slideshare presentation: <a href="http://de.slideshare.net/jaguardesignstudio/why-zsh-is-cooler-than-your-shell-16194692">Why Zsh is Cooler than Your Shell</a></p>
<h2 id="current-shell">Current shell</h2>
<p>to <strong>find out the current shell</strong>:</p>
<pre style="" class="prettyprint prettyprinted"><code><span class="pln">ps </span><span class="pun">-</span><span class="pln">p $$</span></code></pre>
<p>it’s useful during migration to make sure the new shell is really in use.</p>
<h2 id="migration">Migration</h2>
<p>Migration itself included (on my Fedora) reconfiguring:</p>
<ul>
<li><p><strong>default shell</strong> <br>
(inspired by: <a href="http://unix.stackexchange.com/questions/39881/running-chsh-does-not-change-shell">http://unix.stackexchange.com/questions/39881/running-chsh-does-not-change-shell</a>)</p>
<pre style="" class="prettyprint prettyprinted"><code><span class="pln">chsh </span><span class="pun">-</span><span class="pln">s </span><span class="pun">/</span><span class="pln">bin</span><span class="pun">/</span><span class="pln">zsh</span></code></pre></li>
<li><p><strong>konsole</strong> <br>
in <code>Settings</code> -> <code>Edit Current Profile</code> <br>
for: <code>Shell</code> type:</p>
<pre style="" class="prettyprint prettyprinted"><code><span class="str">/bin/</span><span class="pln">zsh</span></code></pre></li>
<li><p><strong>gnome-terminal</strong> <br>
no changes required, seems to go for the default shell.</p></li>
<li><p><strong>xterm</strong> <br>
no changes required, seems to go for the default shell.</p></li>
<li><p><strong>tmux</strong> <br>
(from: <a href="http://superuser.com/questions/253786/how-can-i-make-tmux-use-my-default-shell">http://superuser.com/questions/253786/how-can-i-make-tmux-use-my-default-shell</a>) <br>
in the: <code>~/.tmux.conf</code> added:</p>
<pre style="" class="prettyprint prettyprinted"><code><span class="kwd">set</span><span class="pun">-</span><span class="pln">option </span><span class="pun">-</span><span class="pln">g </span><span class="kwd">default</span><span class="pun">-</span><span class="pln">shell </span><span class="pun">/</span><span class="pln">bin</span><span class="pun">/</span><span class="pln">zsh</span></code></pre></li>
</ul>
<h2 id="oh-my-zsh">oh-my-zsh</h2>
<p>There exists users’ maintained collection of <code>zsh</code> customizations, that I found useful. Called: <a href="https://github.com/robbyrussell/oh-my-zsh"><strong>oh-my-zsh</strong></a>. (Please note the amazing Github’s - Star count. Once seeing that I didn’t doubt I’ll give it a try.)</p>
<p>For <strong>installation</strong> I just went for:</p>
<pre style="" class="prettyprint prettyprinted"><code><span class="pln">curl </span><span class="pun">-</span><span class="pln">L http</span><span class="pun">:</span><span class="com">//install.ohmyz.sh | sh</span></code></pre>
<h2 id="oh-my-zsh-with-powerline">oh-my-zsh with powerline</h2>
<p>I’m used to <a href="https://github.com/Lokaltog/powerline"><strong>powerline</strong></a> everywhere (<code>(g)vim</code>/<code>konsole</code>/<code>tmux</code>/<code>bash</code>) already, so let’s keep it working in <code>zsh</code> as well.</p>
<p>I created file: <code>~/.oh-my-zsh/custom/powerline.zsh</code> with contents:</p>
<pre style="" class="prettyprint prettyprinted"><code><span class="pun">.</span><span class="pln"> </span><span class="pun">~</span><span class="str">/.local/</span><span class="pln">lib</span><span class="pun">/</span><span class="pln">python2</span><span class="pun">.</span><span class="lit">7</span><span class="pun">/</span><span class="pln">site</span><span class="pun">-</span><span class="pln">packages</span><span class="pun">/</span><span class="pln">powerline</span><span class="pun">/</span><span class="pln">bindings</span><span class="pun">/</span><span class="pln">zsh</span><span class="pun">/</span><span class="pln">powerline</span><span class="pun">.</span><span class="pln">zsh</span></code></pre>
<p>Please note: You need to go for the actual location of <code>powerline</code> installation on your system.</p>
<p>and in the file: <code>~/.zshrc</code> I had to comment out line:</p>
<pre style="" class="prettyprint prettyprinted"><code><span class="com"># ZSH_THEME="robbyrussell"</span></code></pre>
<p>otherwise <code>oh-my-zsh</code> theme seems to conflict with <code>powerline</code> one.</p>
<h2 id="oh-my-zsh-plugins">oh-my-zsh plugins</h2>
<p>The real benefit of <code>oh-my-zsh</code> commes with plugins, so I went for those I find useful. Via changing the file: <code>~/.zshrc</code> having:</p>
<pre style="" class="prettyprint prettyprinted"><code><span class="pln">plugins</span><span class="pun">=(</span><span class="pln">git mvn glassfish yum colored</span><span class="pun">-</span><span class="pln">man vagrant z common</span><span class="pun">-</span><span class="pln">aliases gradle</span><span class="pun">)</span></code></pre>
<h2 id="oh-my-zsh-custom-stuff">oh-my-zsh custom stuff</h2>
<p>As my <code>~/.bashrc</code> held already quite some customizations, I migrated those to: </p>
<pre style="" class="prettyprint prettyprinted"><code><span class="pun">~</span><span class="str">/.oh-my-zsh/</span><span class="pln">custom</span><span class="com">/*.zsh</span></code></pre>
<p>Even this part was nice, as I could tidy up things a bit and omit unused stuff. Moreover I decided to create multiple <code>*.zsh</code> files (as these are auto-loaded) to achieve modularity.</p>
<h2 id="done">Done</h2>
<p>Honestly in the beginning, I had no clue how much I would enjoy my new shell.</p>Anonymoushttp://www.blogger.com/profile/11194363658850134703noreply@blogger.com2tag:blogger.com,1999:blog-4811230411463802277.post-53417817766282651332014-06-13T00:16:00.001+02:002014-06-13T00:16:45.575+02:00Xfce: How to disable toolbar text in KDE apps<p>Recently I’ve experienced quite a funny situation. I use <strong>Krusader</strong> for file browsing that calls <strong>Kompare</strong> for file comparisons. However I was not able to copy changes from left to right (or vice versa) in the compared files, as <strong>I could not see all the toolbar buttons (these were too big)</strong>. I didn’t even notice for quite some time, that there are others, not displayed on my screen. </p>
<p><strong>But who needs text description in toolbars</strong>? Well, I don’t!</p>
<p>I remembered global setting from the Gnome world that it should be possible, so searched from the KDE equivalent.</p>
<p>Found it (in my Fedora + Xfce) in:</p>
<p>Xfce menu button -> <code>Options</code> (hope this one is right, as I have it as <code>Einstellungen</code>) -> <code>KDE SystemOptions</code> (for me <code>KDE SystemEinstellungen</code>) -> <code>Style</code> (<code>Stil</code>) -> <code>Fine Tuning</code> tab -> <code>Toolbars</code> section <br>
where I just chose <code>No Text</code> in the both: <code>Main toolbar text</code> as well as in the <code>Secondary toolbar text</code>.</p>
<p>That did the job for me.</p>Anonymoushttp://www.blogger.com/profile/11194363658850134703noreply@blogger.com0tag:blogger.com,1999:blog-4811230411463802277.post-37305940469545028702014-06-13T00:00:00.001+02:002014-06-13T00:02:28.375+02:00Apache Ant tasks for JMX access<p>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.</p><div class="se-section-delimiter"></div>
<h2 id="ant-tasks-for-jmx-operations">Ant tasks for JMX operations</h2>
<p>I decided to follow <a href="http://tomcat.apache.org/tomcat-8.0-doc/monitoring.html#Manage_Tomcat_with_JMX_remote_Ant_Tasks">Tomcat documentation</a> and used ant tasks distributed with tomcat.</p>
<p>Just for the record the <strong>usage is not restricted to Tomcat deployed JMX mBeans</strong>. For me it worked for java process accessible via JConsole via Remote connection.</p><div class="se-section-delimiter"></div>
<h2 id="retrieving-the-library">Retrieving the library</h2>
<ol>
<li>As I wanted to get the latest version I used maven central repository “search by classname” feature and searched for: <code>org.apache.catalina.ant.jmx.JMXAccessorTask</code> (see the <a href="http://search.maven.org/#search%7Cga%7C1%7Cfc:%22org.apache.catalina.ant.jmx.JMXAccessorTask%22">query</a>)</li>
<li>afterwards I went for the <a href="http://search.maven.org/#search%7Cga%7C1%7Ca:%22tomcat-catalina-ant%22">tomcat 8 jar file</a> (called <code>tomcat-catalina-ant-8.0.8.jar</code>)</li>
<li>and just copyied the latest available to my <code>$ANT_HOME/lib</code> dir.</li>
</ol>
<h2 id="usage">Usage</h2>
<p>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: <code>org/apache/catalina/ant/jmx/antlib.xml</code>, following were present for me:</p><div class="se-section-delimiter"></div>
<pre style="" class="prettyprint prettyprinted"><code><span class="tag"><typedef</span><span class="pln">
</span><span class="atn">name</span><span class="pun">=</span><span class="atv">"open"</span><span class="pln">
</span><span class="atn">classname</span><span class="pun">=</span><span class="atv">"org.apache.catalina.ant.jmx.JMXAccessorTask"</span><span class="pln"> </span><span class="tag">/></span><span class="pln">
</span><span class="tag"><typedef</span><span class="pln">
</span><span class="atn">name</span><span class="pun">=</span><span class="atv">"set"</span><span class="pln">
</span><span class="atn">classname</span><span class="pun">=</span><span class="atv">"org.apache.catalina.ant.jmx.JMXAccessorSetTask"</span><span class="pln"> </span><span class="tag">/></span><span class="pln">
</span><span class="tag"><typedef</span><span class="pln">
</span><span class="atn">name</span><span class="pun">=</span><span class="atv">"get"</span><span class="pln">
</span><span class="atn">classname</span><span class="pun">=</span><span class="atv">"org.apache.catalina.ant.jmx.JMXAccessorGetTask"</span><span class="pln"> </span><span class="tag">/></span><span class="pln">
</span><span class="tag"><typedef</span><span class="pln">
</span><span class="atn">name</span><span class="pun">=</span><span class="atv">"invoke"</span><span class="pln">
</span><span class="atn">classname</span><span class="pun">=</span><span class="atv">"org.apache.catalina.ant.jmx.JMXAccessorInvokeTask"</span><span class="pln"> </span><span class="tag">/></span><span class="pln">
</span><span class="tag"><typedef</span><span class="pln">
</span><span class="atn">name</span><span class="pun">=</span><span class="atv">"query"</span><span class="pln">
</span><span class="atn">classname</span><span class="pun">=</span><span class="atv">"org.apache.catalina.ant.jmx.JMXAccessorQueryTask"</span><span class="pln"> </span><span class="tag">/></span><span class="pln">
</span><span class="tag"><typedef</span><span class="pln">
</span><span class="atn">name</span><span class="pun">=</span><span class="atv">"create"</span><span class="pln">
</span><span class="atn">classname</span><span class="pun">=</span><span class="atv">"org.apache.catalina.ant.jmx.JMXAccessorCreateTask"</span><span class="pln"> </span><span class="tag">/></span><span class="pln">
</span><span class="tag"><typedef</span><span class="pln">
</span><span class="atn">name</span><span class="pun">=</span><span class="atv">"unregister"</span><span class="pln">
</span><span class="atn">classname</span><span class="pun">=</span><span class="atv">"org.apache.catalina.ant.jmx.JMXAccessorUnregisterTask"</span><span class="pln"> </span><span class="tag">/></span><span class="pln">
</span><span class="tag"><typedef</span><span class="pln">
</span><span class="atn">name</span><span class="pun">=</span><span class="atv">"equals"</span><span class="pln">
</span><span class="atn">classname</span><span class="pun">=</span><span class="atv">"org.apache.catalina.ant.jmx.JMXAccessorEqualsCondition"</span><span class="pln"> </span><span class="tag">/></span><span class="pln">
</span><span class="tag"><typedef</span><span class="pln">
</span><span class="atn">name</span><span class="pun">=</span><span class="atv">"condition"</span><span class="pln">
</span><span class="atn">classname</span><span class="pun">=</span><span class="atv">"org.apache.catalina.ant.jmx.JMXAccessorCondition"</span><span class="pln"> </span><span class="tag">/></span></code></pre>
<p>out of these, I gave following a try:</p><div class="se-section-delimiter"></div>
<pre style="" class="prettyprint prettyprinted"><code><span class="pln">org</span><span class="pun">.</span><span class="pln">apache</span><span class="pun">.</span><span class="pln">catalina</span><span class="pun">.</span><span class="pln">ant</span><span class="pun">.</span><span class="pln">jmx</span><span class="pun">.</span><span class="typ">JMXAccessorTask</span><span class="pln">
org</span><span class="pun">.</span><span class="pln">apache</span><span class="pun">.</span><span class="pln">catalina</span><span class="pun">.</span><span class="pln">ant</span><span class="pun">.</span><span class="pln">jmx</span><span class="pun">.</span><span class="typ">JMXAccessorInvokeTask</span><span class="pln">
org</span><span class="pun">.</span><span class="pln">apache</span><span class="pun">.</span><span class="pln">catalina</span><span class="pun">.</span><span class="pln">ant</span><span class="pun">.</span><span class="pln">jmx</span><span class="pun">.</span><span class="typ">JMXAccessorQueryTask</span></code></pre>
<p>For the demonstration purposes I’m using Glassfish 4.0.</p>
<h2 id="example-listing-jmx-mbeans">Example: Listing JMX MBeans</h2>
<p>Let’s assume we want to retrieve the MBean by name (namely: <code>java.lang:type=Memory</code>). Please note username and password were not required for access (otherwise they should be specified via respective properties). </p>
<p>Noteworthy here is the <code>resultproperty</code>, which could hold array from which we could get a name. So having in ant build script:</p><div class="se-section-delimiter"></div>
<pre style="" class="prettyprint prettyprinted"><code><span class="tag"><typedef</span><span class="pln">
</span><span class="atn">name</span><span class="pun">=</span><span class="atv">"jmxQuery"</span><span class="pln">
</span><span class="atn">classname</span><span class="pun">=</span><span class="atv">"org.apache.catalina.ant.jmx.JMXAccessorQueryTask"</span><span class="pln"> </span><span class="tag">/></span><span class="pln">
</span><span class="tag"><jmxQuery</span><span class="pln">
</span><span class="atn">host</span><span class="pun">=</span><span class="atv">"localhost"</span><span class="pln">
</span><span class="atn">port</span><span class="pun">=</span><span class="atv">"8686"</span><span class="pln">
</span><span class="atn">echo</span><span class="pun">=</span><span class="atv">"true"</span><span class="pln">
</span><span class="atn">name</span><span class="pun">=</span><span class="atv">"java.lang:type=Memory"</span><span class="pln">
</span><span class="atn">resultproperty</span><span class="pun">=</span><span class="atv">"memory"</span><span class="pln"> </span><span class="tag">/></span><span class="pln">
</span><span class="tag"><echo></span><span class="pln">Retrieved MBeans count: ${memory.Length}</span><span class="tag"></echo></span><span class="pln">
</span><span class="tag"><echo></span><span class="pln">The 1.st one has name: ${memory.0.Name}</span><span class="tag"></echo></span></code></pre>
<p>results for me in following output:</p><div class="se-section-delimiter"></div>
<pre style="" class="prettyprint prettyprinted"><code><span class="pln"> </span><span class="pun">[</span><span class="pln">jmxQuery</span><span class="pun">]</span><span class="pln"> memory</span><span class="pun">.</span><span class="typ">Length</span><span class="pun">=</span><span class="lit">1</span><span class="pln">
</span><span class="pun">[</span><span class="pln">jmxQuery</span><span class="pun">]</span><span class="pln"> memory</span><span class="pun">.</span><span class="lit">0.Name</span><span class="pun">=</span><span class="pln">java</span><span class="pun">.</span><span class="pln">lang</span><span class="pun">:</span><span class="pln">type</span><span class="pun">=</span><span class="typ">Memory</span><span class="pln">
</span><span class="pun">[</span><span class="pln">echo</span><span class="pun">]</span><span class="pln"> </span><span class="typ">Retrieved</span><span class="pln"> </span><span class="typ">MBeans</span><span class="pln"> count</span><span class="pun">:</span><span class="pln"> </span><span class="lit">1</span><span class="pln">
</span><span class="pun">[</span><span class="pln">echo</span><span class="pun">]</span><span class="pln"> </span><span class="typ">The</span><span class="pln"> </span><span class="lit">1.st</span><span class="pln"> one has name</span><span class="pun">:</span><span class="pln"> java</span><span class="pun">.</span><span class="pln">lang</span><span class="pun">:</span><span class="pln">type</span><span class="pun">=</span><span class="typ">Memory</span></code></pre>
<h2 id="example-invoking-operation-via-jmx">Example: Invoking operation via JMX</h2>
<p>Here is a 2 step approach required:</p>
<ol>
<li>connect to remote server via JMX and afterwards</li>
<li>invoke the operation on the particular MBean.</li>
</ol>
<p>For demonstration purposes, let’s assume we want to call garbage collection (via invoking operation: <code>gc()</code> on MBean named: <code>java.lang:type=Memory</code>)</p>
<p>Sample ant build file chunk does the job (please note <code>ref</code> property value that has to be the same across these 2 tasks):</p><div class="se-section-delimiter"></div>
<pre style="" class="prettyprint prettyprinted"><code><span class="tag"><typedef</span><span class="pln">
</span><span class="atn">name</span><span class="pun">=</span><span class="atv">"jmxOpen"</span><span class="pln">
</span><span class="atn">classname</span><span class="pun">=</span><span class="atv">"org.apache.catalina.ant.jmx.JMXAccessorTask"</span><span class="pln"> </span><span class="tag">/></span><span class="pln">
</span><span class="tag"><typedef</span><span class="pln">
</span><span class="atn">name</span><span class="pun">=</span><span class="atv">"jmxInvoke"</span><span class="pln">
</span><span class="atn">classname</span><span class="pun">=</span><span class="atv">"org.apache.catalina.ant.jmx.JMXAccessorInvokeTask"</span><span class="pln"> </span><span class="tag">/></span><span class="pln">
</span><span class="tag"><jmxOpen</span><span class="pln">
</span><span class="atn">host</span><span class="pun">=</span><span class="atv">"localhost"</span><span class="pln">
</span><span class="atn">port</span><span class="pun">=</span><span class="atv">"8686"</span><span class="pln">
</span><span class="atn">ref</span><span class="pun">=</span><span class="atv">"glassfish"</span><span class="pln">
</span><span class="atn">failOnError</span><span class="pun">=</span><span class="atv">"true"</span><span class="pln"> </span><span class="tag">/></span><span class="pln">
</span><span class="tag"><jmxInvoke</span><span class="pln">
</span><span class="atn">name</span><span class="pun">=</span><span class="atv">"java.lang:type=Memory"</span><span class="pln">
</span><span class="atn">operation</span><span class="pun">=</span><span class="atv">"gc"</span><span class="pln">
</span><span class="atn">echo</span><span class="pun">=</span><span class="atv">"true"</span><span class="pln">
</span><span class="atn">delimiter</span><span class="pun">=</span><span class="atv">" "</span><span class="pln">
</span><span class="atn">failOnError</span><span class="pun">=</span><span class="atv">"true"</span><span class="pln">
</span><span class="atn">ref</span><span class="pun">=</span><span class="atv">"glassfish"</span><span class="pln"> </span><span class="tag">/></span></code></pre>
<h2 id="further-information">Further information</h2>
<p>For more details, I recommend reading the official <a href="http://tomcat.apache.org/tomcat-8.0-doc/monitoring.html#Manage_Tomcat_with_JMX_remote_Ant_Tasks">Tomcat documentation</a> as well as <a href="http://tomcat.apache.org/tomcat-8.0-doc/monitoring.html#Manage_Tomcat_with_JMX_remote_Ant_Tasks">Javadocs</a>.</p>Anonymoushttp://www.blogger.com/profile/11194363658850134703noreply@blogger.com0tag:blogger.com,1999:blog-4811230411463802277.post-2066766803798803502014-06-12T22:20:00.001+02:002014-06-12T22:20:48.382+02:00Using Genius TVGo DVB-T03 on Fedora<p>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 <strong>Fedora</strong> (16) with my <strong>Genius TVGo DVB-T03 device</strong>. </p>
<p>The most of the steps were inspired by fedora wiki: <a href="https://fedoraproject.org/wiki/DavidTimms/DVB">https://fedoraproject.org/wiki/DavidTimms/DVB</a> </p>
<h2 id="dvb-t-required-package">DVB-T required package</h2>
<p>I installed <code>dvb-apps</code> package via:</p>
<pre style="" class="prettyprint prettyprinted"><code><span class="pln">sudo yum install dvb</span><span class="pun">-</span><span class="pln">apps</span></code></pre>
<p>Afterwards checked the file list in package via:</p>
<pre style="" class="prettyprint prettyprinted"><code><span class="pln">rpm </span><span class="pun">-</span><span class="pln">q </span><span class="pun">--</span><span class="pln">fileprovide dvb</span><span class="pun">-</span><span class="pln">apps</span></code></pre>
<p>which contained also:</p>
<pre style="" class="prettyprint prettyprinted"><code><span class="str">/usr/</span><span class="pln">bin</span><span class="pun">/</span><span class="pln">scandvb</span></code></pre>
<p>(please note we’ll need this one later).</p><div class="se-section-delimiter"></div>
<h2 id="firmware">Firmware</h2>
<p>I plugged in my dvb-t usb and seen after running <code>dmesg</code>:</p>
<pre style="" class="prettyprint prettyprinted"><code><span class="pun">[</span><span class="lit">11140.318728</span><span class="pun">]</span><span class="pln"> usb </span><span class="lit">2</span><span class="pun">-</span><span class="lit">1.2</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> high</span><span class="pun">-</span><span class="pln">speed USB device number </span><span class="lit">6</span><span class="pln"> </span><span class="kwd">using</span><span class="pln"> ehci</span><span class="pun">-</span><span class="pln">pci
</span><span class="pun">[</span><span class="lit">11140.397936</span><span class="pun">]</span><span class="pln"> usb </span><span class="lit">2</span><span class="pun">-</span><span class="lit">1.2</span><span class="pun">:</span><span class="pln"> </span><span class="typ">New</span><span class="pln"> USB device found</span><span class="pun">,</span><span class="pln"> idVendor</span><span class="pun">=</span><span class="lit">0458</span><span class="pun">,</span><span class="pln"> idProduct</span><span class="pun">=</span><span class="lit">4012</span><span class="pln">
</span><span class="pun">[</span><span class="lit">11140.397946</span><span class="pun">]</span><span class="pln"> usb </span><span class="lit">2</span><span class="pun">-</span><span class="lit">1.2</span><span class="pun">:</span><span class="pln"> </span><span class="typ">New</span><span class="pln"> USB device strings</span><span class="pun">:</span><span class="pln"> </span><span class="typ">Mfr</span><span class="pun">=</span><span class="lit">1</span><span class="pun">,</span><span class="pln"> </span><span class="typ">Product</span><span class="pun">=</span><span class="lit">2</span><span class="pun">,</span><span class="pln"> </span><span class="typ">SerialNumber</span><span class="pun">=</span><span class="lit">0</span><span class="pln">
</span><span class="pun">[</span><span class="lit">11140.397952</span><span class="pun">]</span><span class="pln"> usb </span><span class="lit">2</span><span class="pun">-</span><span class="lit">1.2</span><span class="pun">:</span><span class="pln"> </span><span class="typ">Product</span><span class="pun">:</span><span class="pln"> DVB</span><span class="pun">-</span><span class="pln">T </span><span class="lit">2</span><span class="pln">
</span><span class="pun">[</span><span class="lit">11140.397956</span><span class="pun">]</span><span class="pln"> usb </span><span class="lit">2</span><span class="pun">-</span><span class="lit">1.2</span><span class="pun">:</span><span class="pln"> </span><span class="typ">Manufacturer</span><span class="pun">:</span><span class="pln"> </span><span class="typ">Afatech</span><span class="pln">
</span><span class="pun">[</span><span class="lit">11140.557325</span><span class="pun">]</span><span class="pln"> usbcore</span><span class="pun">:</span><span class="pln"> registered </span><span class="kwd">new</span><span class="pln"> </span><span class="kwd">interface</span><span class="pln"> driver dvb_usb_af9015
</span><span class="pun">[</span><span class="lit">11140.557753</span><span class="pun">]</span><span class="pln"> usb </span><span class="lit">2</span><span class="pun">-</span><span class="lit">1.2</span><span class="pun">:</span><span class="pln"> dvb_usb_v2</span><span class="pun">:</span><span class="pln"> found a </span><span class="str">'Genius TVGo DVB-T03'</span><span class="pln"> </span><span class="kwd">in</span><span class="pln"> cold state
</span><span class="pun">[</span><span class="lit">11140.557900</span><span class="pun">]</span><span class="pln"> usb </span><span class="lit">2</span><span class="pun">-</span><span class="lit">1.2</span><span class="pun">:</span><span class="pln"> dvb_usb_v2</span><span class="pun">:</span><span class="pln"> </span><span class="typ">Did</span><span class="pln"> </span><span class="kwd">not</span><span class="pln"> find the firmware file </span><span class="str">'dvb-usb-af9015.fw'</span><span class="pun">.</span><span class="pln"> </span><span class="typ">Please</span><span class="pln"> see linux</span><span class="pun">/</span><span class="typ">Documentation</span><span class="pun">/</span><span class="pln">dvb</span><span class="pun">/</span><span class="pln"> </span><span class="kwd">for</span><span class="pln"> more details on firmware</span><span class="pun">-</span><span class="pln">problems</span><span class="pun">.</span><span class="pln"> </span><span class="typ">Status</span><span class="pln"> </span><span class="pun">-</span><span class="lit">2</span><span class="pln">
</span><span class="pun">[</span><span class="lit">11140.557905</span><span class="pun">]</span><span class="pln"> usb </span><span class="lit">2</span><span class="pun">-</span><span class="lit">1.2</span><span class="pun">:</span><span class="pln"> dvb_usb_v2</span><span class="pun">:</span><span class="pln"> </span><span class="str">'Genius TVGo DVB-T03'</span><span class="pln"> error </span><span class="kwd">while</span><span class="pln"> loading driver </span><span class="pun">(-</span><span class="lit">2</span><span class="pun">)</span></code></pre>
<p>so searched a bit and found + downloaded rpm from: <a href="http://pkgs.org/fedora-centos-rhel-opensuse-mandriva/olea/dvb-usb-af9015-fw-4.95.0-1.noarch.rpm.html">http://pkgs.org/fedora-centos-rhel-opensuse-mandriva/olea/dvb-usb-af9015-fw-4.95.0-1.noarch.rpm.html</a></p>
<p>Afterwards installed the downloaded firmware via: </p>
<pre style="" class="prettyprint prettyprinted"><code><span class="pln">sudo rpm </span><span class="pun">-</span><span class="pln">ivh dvb</span><span class="pun">-</span><span class="pln">usb</span><span class="pun">-</span><span class="pln">af9015</span><span class="pun">-</span><span class="pln">fw</span><span class="pun">-</span><span class="lit">4.95</span><span class="pun">.</span><span class="lit">0</span><span class="pun">-</span><span class="lit">1.noarch</span><span class="pun">.</span><span class="pln">rpm</span></code></pre>
<p>And finally unplugged and plugged to usb again to see:</p>
<pre style="" class="prettyprint prettyprinted"><code><span class="pun">[</span><span class="lit">11796.948500</span><span class="pun">]</span><span class="pln"> usb </span><span class="lit">2</span><span class="pun">-</span><span class="lit">1.1</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> high</span><span class="pun">-</span><span class="pln">speed USB device number </span><span class="lit">7</span><span class="pln"> </span><span class="kwd">using</span><span class="pln"> ehci</span><span class="pun">-</span><span class="pln">pci
</span><span class="pun">[</span><span class="lit">11797.038703</span><span class="pun">]</span><span class="pln"> usb </span><span class="lit">2</span><span class="pun">-</span><span class="lit">1.1</span><span class="pun">:</span><span class="pln"> </span><span class="typ">New</span><span class="pln"> USB device found</span><span class="pun">,</span><span class="pln"> idVendor</span><span class="pun">=</span><span class="lit">0458</span><span class="pun">,</span><span class="pln"> idProduct</span><span class="pun">=</span><span class="lit">4012</span><span class="pln">
</span><span class="pun">[</span><span class="lit">11797.038714</span><span class="pun">]</span><span class="pln"> usb </span><span class="lit">2</span><span class="pun">-</span><span class="lit">1.1</span><span class="pun">:</span><span class="pln"> </span><span class="typ">New</span><span class="pln"> USB device strings</span><span class="pun">:</span><span class="pln"> </span><span class="typ">Mfr</span><span class="pun">=</span><span class="lit">1</span><span class="pun">,</span><span class="pln"> </span><span class="typ">Product</span><span class="pun">=</span><span class="lit">2</span><span class="pun">,</span><span class="pln"> </span><span class="typ">SerialNumber</span><span class="pun">=</span><span class="lit">0</span><span class="pln">
</span><span class="pun">[</span><span class="lit">11797.038720</span><span class="pun">]</span><span class="pln"> usb </span><span class="lit">2</span><span class="pun">-</span><span class="lit">1.1</span><span class="pun">:</span><span class="pln"> </span><span class="typ">Product</span><span class="pun">:</span><span class="pln"> DVB</span><span class="pun">-</span><span class="pln">T </span><span class="lit">2</span><span class="pln">
</span><span class="pun">[</span><span class="lit">11797.038725</span><span class="pun">]</span><span class="pln"> usb </span><span class="lit">2</span><span class="pun">-</span><span class="lit">1.1</span><span class="pun">:</span><span class="pln"> </span><span class="typ">Manufacturer</span><span class="pun">:</span><span class="pln"> </span><span class="typ">Afatech</span><span class="pln">
</span><span class="pun">[</span><span class="lit">11797.041521</span><span class="pun">]</span><span class="pln"> usb </span><span class="lit">2</span><span class="pun">-</span><span class="lit">1.1</span><span class="pun">:</span><span class="pln"> dvb_usb_v2</span><span class="pun">:</span><span class="pln"> found a </span><span class="str">'Genius TVGo DVB-T03'</span><span class="pln"> </span><span class="kwd">in</span><span class="pln"> cold state
</span><span class="pun">[</span><span class="lit">11797.042331</span><span class="pun">]</span><span class="pln"> usb </span><span class="lit">2</span><span class="pun">-</span><span class="lit">1.1</span><span class="pun">:</span><span class="pln"> dvb_usb_v2</span><span class="pun">:</span><span class="pln"> downloading firmware </span><span class="kwd">from</span><span class="pln"> file </span><span class="str">'dvb-usb-af9015.fw'</span><span class="pln">
</span><span class="pun">[</span><span class="lit">11797.119176</span><span class="pun">]</span><span class="pln"> usb </span><span class="lit">2</span><span class="pun">-</span><span class="lit">1.1</span><span class="pun">:</span><span class="pln"> dvb_usb_v2</span><span class="pun">:</span><span class="pln"> found a </span><span class="str">'Genius TVGo DVB-T03'</span><span class="pln"> </span><span class="kwd">in</span><span class="pln"> warm state
</span><span class="pun">[</span><span class="lit">11797.542424</span><span class="pun">]</span><span class="pln"> usb </span><span class="lit">2</span><span class="pun">-</span><span class="lit">1.1</span><span class="pun">:</span><span class="pln"> dvb_usb_v2</span><span class="pun">:</span><span class="pln"> will </span><span class="kwd">pass</span><span class="pln"> the complete MPEG2 transport stream to the software demuxer
</span><span class="pun">[</span><span class="lit">11797.542542</span><span class="pun">]</span><span class="pln"> DVB</span><span class="pun">:</span><span class="pln"> registering </span><span class="kwd">new</span><span class="pln"> adapter </span><span class="pun">(</span><span class="typ">Genius</span><span class="pln"> </span><span class="typ">TVGo</span><span class="pln"> DVB</span><span class="pun">-</span><span class="pln">T03</span><span class="pun">)</span><span class="pln">
</span><span class="pun">[</span><span class="lit">11797.575204</span><span class="pun">]</span><span class="pln"> i2c i2c</span><span class="pun">-</span><span class="lit">7</span><span class="pun">:</span><span class="pln"> af9013</span><span class="pun">:</span><span class="pln"> firmware version </span><span class="lit">4.95</span><span class="pun">.</span><span class="lit">0.0</span><span class="pln">
</span><span class="pun">[</span><span class="lit">11797.578207</span><span class="pun">]</span><span class="pln"> usb </span><span class="lit">2</span><span class="pun">-</span><span class="lit">1.1</span><span class="pun">:</span><span class="pln"> DVB</span><span class="pun">:</span><span class="pln"> registering adapter </span><span class="lit">0</span><span class="pln"> frontend </span><span class="lit">0</span><span class="pln"> </span><span class="pun">(</span><span class="typ">Afatech</span><span class="pln"> AF9013</span><span class="pun">)...</span><span class="pln">
</span><span class="pun">[</span><span class="lit">11797.589973</span><span class="pun">]</span><span class="pln"> tda18271 </span><span class="lit">7</span><span class="pun">-</span><span class="lit">00c0</span><span class="pun">:</span><span class="pln"> creating </span><span class="kwd">new</span><span class="pln"> instance
</span><span class="pun">[</span><span class="lit">11797.597341</span><span class="pun">]</span><span class="pln"> TDA18271HD</span><span class="pun">/</span><span class="pln">C1 detected </span><span class="pun">@</span><span class="pln"> </span><span class="lit">7</span><span class="pun">-</span><span class="lit">00c0</span><span class="pln">
</span><span class="pun">[</span><span class="lit">11797.802656</span><span class="pun">]</span><span class="pln"> </span><span class="typ">Registered</span><span class="pln"> IR keymap rc</span><span class="pun">-</span><span class="pln">empty
</span><span class="pun">[</span><span class="lit">11797.802848</span><span class="pun">]</span><span class="pln"> input</span><span class="pun">:</span><span class="pln"> </span><span class="typ">Genius</span><span class="pln"> </span><span class="typ">TVGo</span><span class="pln"> DVB</span><span class="pun">-</span><span class="pln">T03 </span><span class="kwd">as</span><span class="pln"> </span><span class="pun">/</span><span class="pln">devices</span><span class="pun">/</span><span class="pln">pci0000</span><span class="pun">:</span><span class="lit">00</span><span class="pun">/</span><span class="lit">0000</span><span class="pun">:</span><span class="lit">00</span><span class="pun">:</span><span class="lit">1d</span><span class="pun">.</span><span class="lit">0</span><span class="pun">/</span><span class="pln">usb2</span><span class="pun">/</span><span class="lit">2</span><span class="pun">-</span><span class="lit">1</span><span class="pun">/</span><span class="lit">2</span><span class="pun">-</span><span class="lit">1.1</span><span class="pun">/</span><span class="pln">rc</span><span class="pun">/</span><span class="pln">rc0</span><span class="pun">/</span><span class="pln">input12
</span><span class="pun">[</span><span class="lit">11797.803814</span><span class="pun">]</span><span class="pln"> rc0</span><span class="pun">:</span><span class="pln"> </span><span class="typ">Genius</span><span class="pln"> </span><span class="typ">TVGo</span><span class="pln"> DVB</span><span class="pun">-</span><span class="pln">T03 </span><span class="kwd">as</span><span class="pln"> </span><span class="pun">/</span><span class="pln">devices</span><span class="pun">/</span><span class="pln">pci0000</span><span class="pun">:</span><span class="lit">00</span><span class="pun">/</span><span class="lit">0000</span><span class="pun">:</span><span class="lit">00</span><span class="pun">:</span><span class="lit">1d</span><span class="pun">.</span><span class="lit">0</span><span class="pun">/</span><span class="pln">usb2</span><span class="pun">/</span><span class="lit">2</span><span class="pun">-</span><span class="lit">1</span><span class="pun">/</span><span class="lit">2</span><span class="pun">-</span><span class="lit">1.1</span><span class="pun">/</span><span class="pln">rc</span><span class="pun">/</span><span class="pln">rc0
</span><span class="pun">[</span><span class="lit">11797.803825</span><span class="pun">]</span><span class="pln"> usb </span><span class="lit">2</span><span class="pun">-</span><span class="lit">1.1</span><span class="pun">:</span><span class="pln"> dvb_usb_v2</span><span class="pun">:</span><span class="pln"> schedule remote query interval to </span><span class="lit">500</span><span class="pln"> msecs
</span><span class="pun">[</span><span class="lit">11797.803832</span><span class="pun">]</span><span class="pln"> usb </span><span class="lit">2</span><span class="pun">-</span><span class="lit">1.1</span><span class="pun">:</span><span class="pln"> dvb_usb_v2</span><span class="pun">:</span><span class="pln"> </span><span class="str">'Genius TVGo DVB-T03'</span><span class="pln"> successfully initialized </span><span class="kwd">and</span><span class="pln"> connected</span></code></pre>
<p>so firmware seems to work now.</p><div class="se-section-delimiter"></div>
<h2 id="generating-channelsconf">Generating channels.conf</h2>
<p>Following command did the job for me (as I’m located in Bayern):</p>
<pre style="" class="prettyprint prettyprinted"><code><span class="pln">scandvb </span><span class="pun">/</span><span class="pln">usr</span><span class="pun">/</span><span class="pln">share</span><span class="pun">/</span><span class="pln">dvb</span><span class="pun">/</span><span class="pln">dvb</span><span class="pun">-</span><span class="pln">t</span><span class="pun">/</span><span class="pln">de</span><span class="pun">-</span><span class="typ">Bayern</span><span class="pln"> </span><span class="pun">></span><span class="pln"> channels</span><span class="pun">.</span><span class="pln">conf</span></code></pre><div class="se-section-delimiter"></div>
<h2 id="enjoying-the-broadcasts">Enjoying the broadcasts</h2>
<p>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:</p>
<pre style="" class="prettyprint prettyprinted"><code><span class="pln">vlc channels</span><span class="pun">.</span><span class="pln">conf</span></code></pre>
<p>made it and I could watch the game!</p>Anonymoushttp://www.blogger.com/profile/11194363658850134703noreply@blogger.com1tag:blogger.com,1999:blog-4811230411463802277.post-72282954546564035152014-06-06T09:15:00.001+02:002014-06-06T09:15:40.747+02:00Eclipse plugin for svn integration<p>I’ve found it tricky to install Eclipse plugin providing svn integration. </p>
<p>The problem is:</p>
<ul>
<li>which <strong>plugin</strong> to choose,</li>
<li>which <strong>version</strong> of the plugin to choose as well as </li>
<li>which <strong>packages</strong> to install.</li>
</ul>
<p>I’m running latest Eclipse (Kepler SR2) and plugin of my choice is <a href="http://subclipse.tigris.org"><strong>subclipse</strong></a>.</p>
<p>The Eclipse plugin <strong>update site</strong> has to be chosen <strong>based on the svn version</strong> installed on the machine (check it running <code>svn --version</code>):</p>
<ul>
<li>for version 1.8.x: <a href="http://subclipse.tigris.org/update_1.10.x">http://subclipse.tigris.org/update_1.10.x</a> and</li>
<li>for version 1.7.x: <a href="http://subclipse.tigris.org/update_1.8.x">http://subclipse.tigris.org/update_1.8.x</a>.</li>
</ul>
<p>Following <strong>packages</strong> were required for installation (for me):</p>
<ul>
<li>Subclipse (Required)</li>
<li>SVNKit Client Adapter (Not Required)</li>
<li>SVNKit Library</li>
</ul>
<p>That’s it! As it covers my Eclipse/svn day-to-day workflow.</p>Anonymoushttp://www.blogger.com/profile/11194363658850134703noreply@blogger.com1tag:blogger.com,1999:blog-4811230411463802277.post-34488116266128132432014-03-04T23:03:00.001+01:002014-03-04T23:04:47.409+01:00Markdown editor for blogger<p>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. </p>
<p>There I could go:</p>
<ul>
<li>either for <code>WYSIWYG</code> editor or</li>
<li>manual <code>HTML</code> writing.</li>
</ul>
<p>However <code>WYSIWYG</code> generates too much <code>HTML</code> I don’t need. Moreover some pre-publish manual <code>HTML</code> editing is a pain then. And the other option I consider it rather slow/unproductive.</p>
<p>So, I looked for other options, and found <strong><a href="http://stackedit.io">stackedit.io</a></strong>. Even this post is (and <a href="http://peter-butkovic.blogspot.de/2014/03/postgres-and-oracle-compatibility-with_4.html">couple</a> <a href="http://peter-butkovic.blogspot.de/2014/03/p6py-200-is-out.html">others</a> as well) written in it.</p>
<h2 id="stackedit">stackedit </h2>
<p><strong>I consider Stackedit great</strong> as it:</p>
<ul>
<li>is Markdown editor, </li>
<li>is open source (see <a href="https://github.com/benweet/stackedit">github repo</a>),</li>
<li>has awesome UI (including live preview, key bindings, …),</li>
<li>has integration with other popular services that I use anyway: <br>
<ul><li>for storage (<a href="https://drive.google.com">google drive</a>, …) and</li>
<li>for publishing (<a href="https://www.blogger.com/">blogger</a>,…),</li></ul></li>
<li>has active community (just check the stars count and commit activity on the <a href="https://github.com/benweet/stackedit">github repo</a>) and</li>
<li>has impressive feedback time (resolution on my <a href="https://github.com/benweet/stackedit/issues/341">issues/questions</a> came in <a href="https://github.com/benweet/stackedit/issues/336">couple hours</a>)</li>
</ul>
<p>So my post writing/editing workflow goes like this:</p>
<ol>
<li>write/edit post on <a href="https://stackedit.io">stackedit.io</a>,</li>
<li>sync it to <a href="https://drive.google.com">google drive</a> and</li>
<li>publish/republish it to <a href="https://www.blogger.com/">blogger</a>.</li>
</ol>
<p>That’s it! No further in-blogger updates required! </p><div class="se-section-delimiter"></div>
<h2 id="blogger-specifics">Blogger specifics</h2>
<p>Still there are some specifics in my workflow (to provide smooth blogger integration).</p>
<ul>
<li>using the Interpreted variables: <code>title</code> and <code>tags</code> via:</li>
</ul>
<pre style="" class="prettyprint prettyprinted"><code><span class="pun">---</span><span class="pln">
title</span><span class="pun">:</span><span class="pln"> </span><span class="typ">Markdown</span><span class="pln"> editor </span><span class="kwd">for</span><span class="pln"> blogger
tags</span><span class="pun">:</span><span class="pln"> blogger markdown stackedit</span><span class="pun">.</span><span class="pln">io
</span><span class="pun">---</span></code></pre>
<ul>
<li>syntax highlighting via <a href="https://code.google.com/p/google-code-prettify/">prettify</a> (I use in my blog posts) on blogger works for me using: <a href="https://help.github.com/articles/github-flavored-markdown#fenced-code-blocks">Github fenced code blocks</a></li>
</ul>Anonymoushttp://www.blogger.com/profile/11194363658850134703noreply@blogger.com30tag:blogger.com,1999:blog-4811230411463802277.post-12209114420254070062014-03-04T21:44:00.001+01:002014-03-04T21:45:44.101+01:00p6spy 2.0.0 is out!<p><strong>After 8 years <a href="https://github.com/p6spy/p6spy">P6spy</a></strong> came to it’s next <strong>stable release</strong>! <br>
You can get it <a href="https://github.com/p6spy/p6spy/wiki/Download">here</a>.</p>
<p>The last stable release happened (based on <a href="http://search.maven.org/#search%7Cgav%7C1%7Cg:%22p6spy%22%20AND%20a:%22p6spy%22">maven central repo</a>) on 27-Dec-2005 (1.3 version). That is quite some time, so one would expect many things to happen in the meantime. Well the truth is that project was (half) dead for quite some time.</p><div class="se-section-delimiter"></div>
<h2 id="changes">Changes</h2>
<p>I can’t comment on full history since 1.3 release (since my interest in project started last summer), still I’ve noticed following:</p>
<ul>
<li>project hosting was moved from <a href="http://sourceforge.net/projects/p6spy/">sourceforge</a> to <a href="https://github.com/p6spy/p6spy"><strong>github</strong></a>,</li>
<li>major part of the <strong>legacy code</strong> was <strong>refactored</strong>,</li>
<li><strong>Java 6/7 JDBC API</strong> support introduced,</li>
<li><p><strong>proxying via modified <code>JDBC</code> <code>URL</code>s only</strong> was implemented, <br>
So for for MySQL original url would be:</p>
<pre style="" class="prettyprint prettyprinted"><code><span class="pln">jdbc</span><span class="pun">:</span><span class="pln">mysql</span><span class="pun">:</span><span class="com">//<hostname>:<port>/<database></span></code></pre>
<p>the one proxied via p6spy would one:</p>
<pre style="" class="prettyprint prettyprinted"><code><span class="pln">jdbc</span><span class="pun">:</span><span class="pln">p6spy</span><span class="pun">:</span><span class="pln">mysql</span><span class="pun">:</span><span class="com">//<hostname>:<port>/<database></span></code></pre>
<p>without a need for any further configuration,</p></li>
<li><strong>XA Datasource support</strong> has been introduced,</li>
<li>configuration via: <br>
<ul><li><strong>system/environment properties</strong> and</li>
<li><strong>JMX properties</strong></li>
<li>as an alternative to file configuration only</li>
<li>or even <strong>zero config use case</strong> supported,</li></ul></li>
<li><strong>slf4j</strong> support (more flexible as previously used log4j),</li>
<li>junit tests were migrated to <strong>junit 4</strong> (well most of the old ones were failing anyway),</li>
<li><strong>Continuous integration using Travis</strong> was setup providing testing on popular: <br>
<ul><li>DB systems (namely: <strong>Oracle</strong>, <strong>DB2</strong>, <strong>PostgreSQL</strong>, <strong>MySQL</strong>, <strong>H2</strong>, <strong>HSQLDB</strong>, <strong>SQLite</strong>, <strong>Firebird</strong>, and <strong>Derby</strong>), see build status on: <a href="https://travis-ci.org/p6spy/p6spy">travis-ci</a> as well as </li>
<li>application servers (namely: <strong>Wildfly</strong> 8, <strong>JBoss</strong> 4.2, 5.1, 6.1, 7.1, <strong>Glassfish</strong> 3.1, 4.0, <strong>Jetty</strong> 7.6, 8.1, 9.1, <strong>Tomcat</strong> 6, 7, 8, <strong>Resin</strong> 4, <strong>Jonas</strong> 5.3 and <strong>Geronimo</strong> 2.1, 2.2), see build status on: <a href="https://travis-ci.org/p6spy/p6spy-it">travis-ci</a>.</li></ul></li>
</ul><div class="se-section-delimiter"></div>
<h2 id="full-changelog">Full changelog</h2>
<p>For the full changelog, see issues fixed in: <a href="https://github.com/p6spy/p6spy/issues?milestone=2&state=closed">2.0.0-alpha1</a> as well as <a href="https://github.com/p6spy/p6spy/issues?milestone=1&state=closed">2.0.0</a>.</p>Anonymoushttp://www.blogger.com/profile/11194363658850134703noreply@blogger.com0tag:blogger.com,1999:blog-4811230411463802277.post-61729619607656787122014-03-04T20:37:00.001+01:002014-03-05T11:32:40.613+01:00Postgres and Oracle compatibility with Hibernate<p>There are situations your JEE application needs to support Postgres and Oracle as a Database. <br>
Hibernate should do the job here, however there are some specifics worth mentioning. <br>
While enabling Postgres for application already running Oracle I came across following tricky parts:</p>
<ul>
<li><code>BLOBs</code> support,</li>
<li><code>CLOBs</code> support,</li>
<li>Oracle not knowing <code>Boolean</code> type (using <code>Integer</code>) instead and</li>
<li><code>DUAL</code> table.</li>
</ul>
<p>These were the tricks I had to apply to make the <code>@Entity</code> classes running on both of these.</p>
<p>Please note I’ve used Postgres 9.3 with Hibernate 4.2.1.SP1.</p>
<h2 id="blobs-support">BLOBs support</h2>
<p>The problem with Postgres is that it offers 2 types of BLOB storage: </p>
<ul>
<li><code>bytea</code> - data stored in table</li>
<li><code>oid</code> - table holds just identifier to data stored elsewhere</li>
</ul>
<p>I guess in the most of the situations you can live with the <code>bytea</code> as well as I did. The other one as far as I’ve read is to be used for some huge data (in gigabytes) as it supports streams for IO operations.</p>
<p>Well, it sounds nice there is such a support, however using Hibernate in this case can make things quite problematic (due to need to use the specific annotations), especially if you try to achieve compatibility with Oracle. </p>
<p>To see the trouble here, see <a href="https://stackoverflow.com/questions/3677380/proper-hibernate-annotation-for-byte">StackOverflow: proper hibernate annotation for byte[]</a></p>
<p>All- the combinations are described there:</p>
<pre style="" class="prettyprint prettyprinted"><code><span class="pln">annotation postgres oracle works on
</span><span class="pun">-------------------------------------------------------------</span><span class="pln">
</span><span class="kwd">byte</span><span class="pun">[]</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> </span><span class="lit">@Lob</span><span class="pln"> oid blob oracle
</span><span class="kwd">byte</span><span class="pun">[]</span><span class="pln"> bytea raw</span><span class="pun">(</span><span class="lit">255</span><span class="pun">)</span><span class="pln"> postgresql
</span><span class="kwd">byte</span><span class="pun">[]</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> </span><span class="lit">@Type</span><span class="pun">(</span><span class="pln">PBA</span><span class="pun">)</span><span class="pln"> oid blob oracle
</span><span class="kwd">byte</span><span class="pun">[]</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> </span><span class="lit">@Type</span><span class="pun">(</span><span class="pln">BT</span><span class="pun">)</span><span class="pln"> bytea blob postgresql</span></code></pre>
<p>where <code>@Type(PBA)</code> stands for: <code>@Type(type="org.hibernate.type.PrimitiveByteArrayBlobType")</code> and <code>@Type(BT)</code> stands for: <code>@Type(type="org.hibernate.type.BinaryType")</code>.</p>
<p>These result in all sorts of Postgres errors, like:</p>
<blockquote>
<p>ERROR: column “foo” is of type oid but expression is of type bytea</p>
</blockquote>
<p>or</p>
<blockquote>
<p>ERROR: column “foo” is of type bytea but expression is of type oid</p>
</blockquote>
<p>Well, there seems to be a solution, still it includes patching of Hibernate library (something I see as the last option when playing with 3.rd party library).</p>
<p>There is also a reference to official blog post from the Hibernate guys on the topic: <a href="http://in.relation.to/Bloggers/PostgreSQLAndBLOBs">PostgreSQL and BLOBs</a>. Still solution described in blog post seems not working for me and based on the comments, seems to be invalid for more people.</p>
<h2 id="blobs-solved">BLOBs solved</h2>
<p>OK, so now the optimistic part.</p>
<p>After quite some debugging I ended up with the Entity definition like this :</p>
<pre style="" class="prettyprint prettyprinted"><code class="language-java"><span class="lit">@Lob</span><span class="pln">
</span><span class="kwd">private</span><span class="pln"> </span><span class="kwd">byte</span><span class="pun">[]</span><span class="pln"> foo</span><span class="pun">;</span></code></pre>
<p>Oracle has no trouble with that, moreover I had to customize the Postgres dialect in a way:</p>
<pre style="" class="prettyprint prettyprinted"><code class="language-java"><span class="kwd">public</span><span class="pln"> </span><span class="kwd">class</span><span class="pln"> </span><span class="typ">PostgreSQLDialectCustom</span><span class="pln"> </span><span class="kwd">extends</span><span class="pln"> </span><span class="typ">PostgreSQL82Dialect</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
</span><span class="lit">@Override</span><span class="pln">
</span><span class="kwd">public</span><span class="pln"> </span><span class="typ">SqlTypeDescriptor</span><span class="pln"> remapSqlTypeDescriptor</span><span class="pun">(</span><span class="typ">SqlTypeDescriptor</span><span class="pln"> sqlTypeDescriptor</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
</span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">sqlTypeDescriptor</span><span class="pun">.</span><span class="pln">getSqlType</span><span class="pun">()</span><span class="pln"> </span><span class="pun">==</span><span class="pln"> java</span><span class="pun">.</span><span class="pln">sql</span><span class="pun">.</span><span class="typ">Types</span><span class="pun">.</span><span class="pln">BLOB</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
</span><span class="kwd">return</span><span class="pln"> </span><span class="typ">BinaryTypeDescriptor</span><span class="pun">.</span><span class="pln">INSTANCE</span><span class="pun">;</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="kwd">return</span><span class="pln"> </span><span class="kwd">super</span><span class="pun">.</span><span class="pln">remapSqlTypeDescriptor</span><span class="pun">(</span><span class="pln">sqlTypeDescriptor</span><span class="pun">);</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="pun">}</span></code></pre>
<p>That’s it! Quite simple right? That works for persisting to <code>bytea</code> typed columns in Postgres (as that fits my usecase).</p>
<h2 id="clobs-support">CLOBs support</h2>
<p>The errors in misconfiguration looked something like this:</p>
<pre style="" class="prettyprint prettyprinted"><code><span class="pln">org</span><span class="pun">.</span><span class="pln">postgresql</span><span class="pun">.</span><span class="pln">util</span><span class="pun">.</span><span class="typ">PSQLException</span><span class="pun">:</span><span class="pln"> </span><span class="typ">Bad</span><span class="pln"> value </span><span class="kwd">for</span><span class="pln"> type </span><span class="kwd">long</span><span class="pln"> </span><span class="pun">:</span><span class="pln"> </span><span class="pun">...</span></code></pre>
<p>So first I’ve found (on <a href="http://www.shredzone.de/cilla/page/299/string-lobs-on-postgresql-with-hibernate-36.html">String LOBs on PostgreSQL with Hibernate 3.6</a>) following solution:</p>
<pre style="" class="prettyprint prettyprinted"><code class="language-java"><span class="lit">@Lob</span><span class="pln">
</span><span class="lit">@Type</span><span class="pun">(</span><span class="pln">type </span><span class="pun">=</span><span class="pln"> </span><span class="str">"org.hibernate.type.TextType"</span><span class="pun">)</span><span class="pln">
</span><span class="kwd">private</span><span class="pln"> </span><span class="typ">String</span><span class="pln"> foo</span><span class="pun">;</span></code></pre>
<p>Well, that works, but for Postgres only.</p>
<p>Then there was a suggestion (on <a href="https://stackoverflow.com/questions/5043992/postgres-utf-8-clobs-with-jdbc">StackOverflow: Postgres UTF-8 clobs with JDBC</a>) from to go for:</p>
<pre style="" class="prettyprint prettyprinted"><code class="language-java"><span class="lit">@Lob</span><span class="pln">
</span><span class="lit">@Type</span><span class="pun">(</span><span class="pln">type</span><span class="pun">=</span><span class="str">"org.hibernate.type.StringClobType"</span><span class="pun">)</span><span class="pln">
</span><span class="kwd">private</span><span class="pln"> </span><span class="typ">String</span><span class="pln"> foo</span><span class="pun">;</span></code></pre>
<p>That pointed me the right direction (the funny part was that it was just a comment to some answers). It was quite close, but didn’t work for me in all cases, still resulted in errors in my tests. </p>
<h2 id="clobs-solved">CLOBs solved</h2>
<p>The important was <code>@deprecation</code> javadocs in the <code>org.hibernate.type.StringClobType</code> that brought me to working one:</p>
<pre style="" class="prettyprint prettyprinted"><code class="language-java"><span class="lit">@Lob</span><span class="pln">
</span><span class="lit">@Type</span><span class="pun">(</span><span class="pln">type</span><span class="pun">=</span><span class="str">"org.hibernate.type.MaterializedClobType"</span><span class="pun">)</span><span class="pln">
</span><span class="kwd">private</span><span class="pln"> </span><span class="typ">String</span><span class="pln"> foo</span><span class="pun">;</span></code></pre>
<p>That works for both Postgres and Oracle, without any further hacking (on Hibernate side) needed.</p><div class="se-section-delimiter"></div>
<h2 id="boolean-type">Boolean type</h2>
<p>Oracle knows no <code>Boolean</code> type and the trouble is that Postgres does. As there was also some plain SQL present, I ended up In Postgres with error:</p>
<blockquote>
<p>ERROR: column “foo” is of type boolean but expression is of type integer</p>
</blockquote>
<p>I decided to enable cast from <code>Integer</code> to <code>Boolean</code> in Postgres rather than fixing all the plain SQL places (in a way found in <a href="http://forums.devshed.com/postgresql-help-21/automatically-casting-from-integer-to-boolean-632699.html">Forum: Automatically Casting From Integer to Boolean</a>):</p>
<pre style="" class="prettyprint prettyprinted"><code class="language-sql"><span class="pln">update pg_cast </span><span class="kwd">set</span><span class="pln"> castcontext </span><span class="pun">=</span><span class="pln"> </span><span class="str">'i'</span><span class="pln"> </span><span class="kwd">where</span><span class="pln"> oid </span><span class="kwd">in</span><span class="pln"> </span><span class="pun">(</span><span class="pln"> </span><span class="kwd">select</span><span class="pln"> c</span><span class="pun">.</span><span class="pln">oid </span><span class="kwd">from</span><span class="pln"> pg_cast c inner join pg_type src on src</span><span class="pun">.</span><span class="pln">oid </span><span class="pun">=</span><span class="pln"> c</span><span class="pun">.</span><span class="pln">castsource inner join pg_type tgt on tgt</span><span class="pun">.</span><span class="pln">oid </span><span class="pun">=</span><span class="pln"> c</span><span class="pun">.</span><span class="pln">casttarget </span><span class="kwd">where</span><span class="pln"> src</span><span class="pun">.</span><span class="pln">typname like </span><span class="str">'int%'</span><span class="pln"> </span><span class="kwd">and</span><span class="pln"> tgt</span><span class="pun">.</span><span class="pln">typname like </span><span class="str">'bool%'</span><span class="pun">);</span></code></pre>
<p>Please note you should run the <code>SQL</code> update by user with provileges to update catalogs (probably not your postgres user used for DB connection from your application), as I’ve learned on <a href="https://stackoverflow.com/questions/21753225/postgres-permission-denied-on-updating-pg-catalog-pg-cast">Stackoverflow: Postgres - permission denied on updating pg_catalog.pg_cast</a>.</p>
<h2 id="dual-table">DUAL table</h2>
<p>There is one more specific in the Oracle I came across. If you have plain SQL, in Oracle there is <code>DUAL</code> table provied (see more info on <a href="https://en.wikipedia.org/wiki/DUAL_table">Wikipedia on that</a>) that might harm you in Postgres.</p>
<p>Still the solution is simple. In Postgres create a view that would fill the similar purpose. It can be created like this:</p>
<pre style="" class="prettyprint prettyprinted"><code class="language-sql"><span class="pln">create </span><span class="kwd">or</span><span class="pln"> replace view dual </span><span class="kwd">as</span><span class="pln"> </span><span class="kwd">select</span><span class="pln"> </span><span class="lit">1</span><span class="pun">;</span></code></pre>
<h2 id="conclusion">Conclusion</h2>
<p>Well that should be it. Enjoy your cross DB compatible JEE apps.</p>Anonymoushttp://www.blogger.com/profile/11194363658850134703noreply@blogger.com0tag:blogger.com,1999:blog-4811230411463802277.post-58273677118815815462014-01-21T13:16:00.002+01:002014-01-21T13:16:42.860+01:00yeoman - testing with mocha and chai instead of jasmineI've been playing around with <a href="http://yeoman.io/">yeoman</a> these days. It seems like project worth a try for my free time single page application.
<br /><br />
After the inital setup (using AngularJS generator) I decided to let my tests run with <a href="http://visionmedia.github.io/mocha/">mocha</a> + <a href="http://chaijs.com/">chai</a> (with <a href="http://chaijs.com/guide/styles/#expect">expect asertions</a>) rather than jasmine (generated by default).
<br /><br />
In fact it was super-simple. The diffs that matter:
<pre class="prettyprint lang-js">
diff --git a/yo/karma.conf.js b/yo/karma.conf.js
index bc0e168..385045f 100644
--- a/yo/karma.conf.js
+++ b/yo/karma.conf.js
@@ -7,7 +7,7 @@ module.exports = function(config) {
basePath: '',
// testing framework to use (jasmine/mocha/qunit/...)
- frameworks: ['jasmine'],
+ frameworks: ['mocha', 'chai'],
// list of files / patterns to load in the browser
files: [
diff --git a/yo/package.json b/yo/package.json
index 3e3db14..9649a55 100644
--- a/yo/package.json
+++ b/yo/package.json
@@ -34,7 +34,8 @@
"karma-html2js-preprocessor": "~0.1.0",
"karma-firefox-launcher": "~0.1.3",
"karma-script-launcher": "~0.1.0",
- "karma-jasmine": "~0.1.5",
+ "karma-mocha": "~0.1.1",
+ "karma-chai": "~0.0.2",
"karma-coffee-preprocessor": "~0.1.2",
"requirejs": "~2.1.10",
"karma-requirejs": "~0.2.1",
diff --git a/yo/test/spec/controllers/main.js b/yo/test/spec/controllers/main.js
index eb7cda2..f9becde 100644
--- a/yo/test/spec/controllers/main.js
+++ b/yo/test/spec/controllers/main.js
@@ -17,6 +17,6 @@ describe('Controller: MainCtrl', function () {
}));
it('should attach a list of awesomeThings to the scope', function () {
- expect(scope.awesomeThings.length).toBe(3);
+ expect(scope.awesomeThings.length).to.equal(3);
});
});
</pre>
Afterwards just running (to fetch missing packages):
<pre class="prettyprint lang-sh">
npm install
</pre>
and tests succeed:
<pre class="prettyprint lang-sh">
grunt test
</pre>Anonymoushttp://www.blogger.com/profile/11194363658850134703noreply@blogger.com0tag:blogger.com,1999:blog-4811230411463802277.post-88743643601706275912013-12-17T11:26:00.001+01:002013-12-17T11:26:31.668+01:00Liquibase - implementing custom type.There are some <b>things to keep in mind</b> while implementing custom type in liquibase. Let's see how to create one.
<br /><br />
<h2>Existing database types</h2>
Well, this might be the biggest advantage of using/hacking the open source projects. You have a chance to see how are things done. This is useful to find your inspiration, the places that require modifications and the hooks to existing system.
<br /><br />
Classes worth checking for our purposes are in the package:
<pre class="prettyprint lang-java">
liquibase.datatype.core
</pre>
You can browse them <a href="https://github.com/liquibase/liquibase/tree/master/liquibase-core/src/main/java/liquibase/database">directly on github</a>.
<br /><br />
<h2>Sample custom BlobType implementation</h2>
Let's assume we're about to modify BlobType.
Our implementation could look like this:
<pre class="prettyprint linenums lang-java">
package liquibase.datatype.core;
import liquibase.database.Database;
import liquibase.database.core.PostgresDatabase;
import liquibase.datatype.DataTypeInfo;
import liquibase.datatype.DatabaseDataType;
import liquibase.datatype.LiquibaseDataType;
@DataTypeInfo(name = "blob", aliases = { "longblob", "longvarbinary", "java.sql.Types.BLOB",
"java.sql.Types.LONGBLOB", "java.sql.Types.LONGVARBINARY", "java.sql.Types.VARBINARY",
"varbinary" }, minParameters = 0, maxParameters = 0, priority = LiquibaseDataType.PRIORITY_DATABASE)
public class BlobTypeTest extends BlobType {
public DatabaseDataType toDatabaseDataType(Database database) {
// handle the specifics here, you can go for the per DB specifics, let's assume Postgres
if (database instanceof PostgresDatabase) {
// your custom type here
}
// use defaults for all the others
return super.toDatabaseDataType(database);
}
}
</pre>
<h2>Specifics to keep in mind</h2>
There are some specifics that should be considered:
<ul>
<li><b>DataType priority is important</b>
<br/><br/>
To make sure our type will be considered in favor to default implementation. We're going for:
<pre class="prettyprint lang-java">
priority = LiquibaseDataType.PRIORITY_DATABASE
</pre>
where the default one (in the supertype) is:
<pre class="prettyprint lang-java">
priority = LiquibaseDataType.PRIORITY_DEFAULT
</pre>
This just means that our implementation should be considered in favor to default one.
<br/><br/>
See method:
<pre class="prettyprint lang-java">
liquibase.datatype.DataTypeFactory.register()
</pre>
implementation for details.
</li>
<li><b>DataType registration considers specific packages to be scanned only</b>
<br/><br/>
We have more options here, but our stuff should go to any of these:
<ul>
<li>any of those listed in jar/MANIFEST.MF property:
<pre class="prettyprint">
Liquibase-Package
</pre>
Where the default set in the liquibase-core-3.0.8.jar is:
<pre class="prettyprint">
Liquibase-Package: liquibase.change,liquibase.database,liquibase.parse
r,liquibase.precondition,liquibase.datatype,liquibase.serializer,liqu
ibase.sqlgenerator,liquibase.executor,liquibase.snapshot,liquibase.lo
gging,liquibase.diff,liquibase.structure,liquibase.structurecompare,l
iquibase.lockservice,liquibase.ext
</pre>
</li>
<li>comma separated custom package list provided via system property called:
<pre class="prettyprint lang-java">
liquibase.scan.packages
</pre>
</li>
<li>if all of the above are empty, note the fallback package list is used. As implementation says:
<pre class="prettyprint linenums lang-java">
if (packagesToScan.size() == 0) {
addPackageToScan("liquibase.change");
addPackageToScan("liquibase.database");
addPackageToScan("liquibase.parser");
addPackageToScan("liquibase.precondition");
addPackageToScan("liquibase.datatype");
addPackageToScan("liquibase.serializer");
addPackageToScan("liquibase.sqlgenerator");
addPackageToScan("liquibase.executor");
addPackageToScan("liquibase.snapshot");
addPackageToScan("liquibase.logging");
addPackageToScan("liquibase.diff");
addPackageToScan("liquibase.structure");
addPackageToScan("liquibase.structurecompare");
addPackageToScan("liquibase.lockservice");
addPackageToScan("liquibase.ext");
}
</pre>
</li>
<br />
</ul>
See method:
<pre class="prettyprint lang-java">
ServiceLocator.setResourceAccessor()
</pre>
implementation for details.
<br/><br/>
Well, as you might have noticed, I'm lazy enough as I went for the already registered package:
<pre class="prettyprint lang-java">
liquibase.datatype.core
</pre>
so it worked once my implementation is on the classpath.
</li>
</ul>
That should be it.
<br/><br />
<h2>Debugging ant task</h2>
It's allways good idea to debug once playing around with the custom changes in the 3.rd party code.<br />
As I went for ant task, just addopted ANT_OPTS variable. In my case (as I'm on linux) following worked:<br />
<pre class="prettyprint lang-sh">
export ANT_OPTS="-Xdebug -agentlib:jdwp=transport=dt_socket,server=y,address=8000"
</pre>
remote debugging was possible afterwards.<br />
<br />
To check if custom type is registered, check in the debug session the constructor:
<pre class="prettyprint lang-java">
DataTypeFactory.DataTypeFactory()
</pre>
local variable "classes" contents after line:
<pre class="prettyprint lang-java">
classes = ServiceLocator.getInstance().findClasses(LiquibaseDataType.class);
</pre>
to see all the types found. <br /><br />
That should provide you the basics on liquibase types hacking.Anonymoushttp://www.blogger.com/profile/11194363658850134703noreply@blogger.com0tag:blogger.com,1999:blog-4811230411463802277.post-15092013449154427002013-12-16T13:58:00.001+01:002013-12-16T20:13:02.051+01:00Oracle JDK 1.7.0_u45 incompatibility with Glassfish 3.x (Corba)<b>Q</b>: Did you give a try to Glassfish 3.1.x with latest stable JDK (1.7.0_u45)?
<br/>
<b>A</b>: Well, you might be interested in possible trouble there.
<br/>
<br/>
After quite some debugging of weird error happening, namely:
<pre class="prettyprint">
Caused by: java.lang.ArrayIndexOutOfBoundsException: -1636631191
at java.util.HashMap.put(HashMap.java:498)
at java.util.HashSet.add(HashSet.java:217)
...
</pre>
I ended up creating: <a href="https://java.net/jira/browse/GLASSFISH-20927">https://java.net/jira/browse/GLASSFISH-20927</a>
(Btw, it was quite weird, but I'm not allowed to add attachments in their jira :)
<br/>
The problem seems to be in internals of the HashSet -> HashMap. Where Corba doesn't seem to set the expected reference to EMPTY_TABLE in case of empty Set.
Let's see how they proceed with the analysis.Anonymoushttp://www.blogger.com/profile/11194363658850134703noreply@blogger.com0tag:blogger.com,1999:blog-4811230411463802277.post-77227097680021215022013-10-22T19:38:00.002+02:002013-10-23T21:47:30.083+02:00My Firefox browsing privacy settingsI decided to go for a bit more privacy for daily browsing. I don't think I need full security (I'm active in social networks anyway, so that would be the 1.st thing to cut), but let's say at least some. I've been influenced of the <a href="https://duckduckgo.com">duckduckgo</a>'s <a href="http://donttrack.us">donttrack.us</a> and <a href="http://fixtracking.com">fixtracking.com</a> pages.
<br/><br/>
I'm running Linux, so for the browser I have 2 mainstream options:
<ul>
<li>Chrome/Chromium</li>
<li>Firefox</li>
</ul>
The Chrome throws
<pre class="prettyprint">
Segmentation fault (core dumped)
</pre>
at me (on both of my linux machines - Xubuntu/Fedora). Due to lack of motivation I didn't investigate any further (possibly some misbehaving extension). So my options narrow to Firefox only. But that is OK with me. As I'm used to it after some years of usage.
<br/><br/>
<h2>Firefox setup</h2>
I'm using <a href="https://duckduckgo.com/"><b>duckduckgo.com</b></a> as my default search engine in both
<ul>
<li><b>Location bar</b>:
<ul>
<li>To set it, go to page:
<pre class="prettyprint">
about:config
</pre>
and set property:
<pre class="prettyprint">
keyword.URL
</pre>
to:
<pre class="prettyprint">
https://duckduckgo.com/?q=
</pre>
</ul>
and</li>
<li><b>Search bar</b>:
<ul>
<li>To set it click down arrow in the Search bar and choose "Manage Search Engines ..." where move DuckDuckGo to the very top</li>
</ul>
</li>
</ul>
So I can escape from search + profile association promoting me next day all the stuff I searched for a couple days ago.
<br/><br/>
<h2>Add-ons</h2>
Moreover I go for the following add-ons:
<ul>
<li><a href="https://addons.mozilla.org/en-US/firefox/addon/adblock-plus/">Adblock Plus</a> - to block (annoying) ads,</li>
<li><a href="https://addons.mozilla.org/en-US/firefox/addon/betterprivacy/">Better privacy</a> - to clear specific cookies on Firefox shutdown,</li>
<li><a href="https://disconnect.me/">Disconnect me</a> - to get rid of tracking by sites,</li>
<li><a href="https://addons.mozilla.org/en-US/firefox/addon/donottrackplus/">DoNotTrackMe</a> - to block ads and cookies with tracking and</li>
<li><a href="https://www.eff.org/https-everywhere">HTTPS everywhere</a> - to go for HTTPS where possible.</li>
</ul>
<br/><br/>
<h2>Unsecure part</h2>
Well there are some specifics in my setup. As mentioned earlier I'm using social networks for posting, and as I'm lazy enough and like posting with minimal effort, I use also <a href="https://addons.mozilla.org/en-US/firefox/addon/sharethis/">ShareThis</a>. However since installing all the previously mentioned, ShareThis stopped working. Following are the tweaks I had to do to enable it again:
<ul>
<li>DoNoTrackMe - I clicked on toolbar icon and then options wheel in the corner, where I disabled "ShareThis" blocking, </li>
<li>moreover as Sharethis page rendered on sharing has problems with HTTPs certificate, I had to deactivate it in the - HTTPS Everywhere - as well.</li>
<li>Once I'm ready to share site and click Sharethis button in location bar (nothing happens so) I have to go for "Disconnect me" toolbar button and choose "Advertising" category and uncheck "Sharethis". I need to click Sharethis button once again then.</li>
</ul>
That's it for my setup. I don't think I improved my privacy in a radical way, but let's say I went for options that don't hurt my common browsing experience that much. Some (like ads blocking) make it even more pleasant.Anonymoushttp://www.blogger.com/profile/11194363658850134703noreply@blogger.com1tag:blogger.com,1999:blog-4811230411463802277.post-56966074143877682952013-10-22T19:04:00.000+02:002013-10-22T19:04:09.445+02:00Eclipse toolbar housekeepingIt took me quite some time, since I really started to care about all the wasted space in my IDE of choice - Eclipse IDE. The problem is that toolbar contains elements that I never use. Reasons might differ. Some I don't need, for some I use keyboard shortcuts (that I consider faster to use) for the rest I don't have a clue what they're intended for.
<br/><br/>
Once I checked the options, motivated by the removal of "Quick access" element eating my toolbar space (since Eclipse Juno version) I've found the <a href="http://stackoverflow.com/questions/11549283/remove-quick-access-entry-in-eclipse-juno">stackoverflow post</a> providing even more help than I originally expected.
<br/><br/>
It correctly pointed me to yet unresolved <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=362420">Eclipse bug</a>, however that was not what I was looking for. Still there were other answers giving me what I came for.
<br/><br/>
<h2>Removing "Quick access" element</h2>
As <a href="http://stackoverflow.com/a/17646047/1581069">this answer</a> pointed, adding:
<pre class="prettyprint lang-css linenums">
#SearchField {
visibility:hidden;
}
</pre>
to the:
<pre class="prettyprint lang-sh">
<ECLIPSE_HOME>/plugins/org.eclipse.platform_<VERSION>/css/e4_basestyle.css
</pre>
and restarting Eclipse does the job.
<br/><br/>
<h2>Removing toolbar buttons</h2>
As the <a href="http://stackoverflow.com/a/12724182/1581069">other answer</a> pointed, going for: Window -> Customize Prespective ... I was able to get rid of the buttons (I don't need) in my toolbar.
<br/>
Please note: this should be done on per perspective basis.
<br/><br/>
<h2>Conclusion</h2>
Since applying the mentioned, my toolbar behaves and takes one row of my vertical space only. In fact, it's like half empty :)Anonymoushttp://www.blogger.com/profile/11194363658850134703noreply@blogger.com0tag:blogger.com,1999:blog-4811230411463802277.post-90933469503361227442013-10-20T23:46:00.001+02:002013-10-20T23:47:43.398+02:00How I left the output redirection to file.If you feel with linux command line at home, there is often a situation you pipe command outputs. These enable us doing amazing things.
<br/><br/>
However there are times, when console is not the right place to examine the final output and your favourite editor could do much better job.
<br/>
In the past I used to output to file and open afterwards, until,... I've noticed it's possible to <b>pipe directly to editor</b>.
<br/><br/>
Let's assume we're interested in reading tail output in our editor of choice.
<br/><br/>
<h2>Gedit</h2>
As my default editor used to be Gedit for quite some time, let's see it in action:
<pre class="prettyprint lang-sh">
tail -f some.log | gedit
</pre>
No surprise :), I guess. No extra arguments. Nice!
<br/><br/>
Morever gedit even provides me with the indicatior (displayed on the tab), that loading is in progress and automatically refreshes contents.
<br/><br/>
<h2>Gvim</h2>
I'm in process of transition to gvim usage. I've heard about it's power, never really had a chance to dive deep there. However after watching some vimcasts and reading couple reviews, I'm quite amazed. I'm still trying to memorize the keys for specific tasks (that should be just a question of time and frequency of usage of particular ones).
<br/><br/>
I made it already my primary editor (wherever I used to use Gedit before).
<br/><br/>
OK, let's see it in action:
<pre class="prettyprint lang-sh">
tail -f some.log | gvim -R -
</pre>
please note -R is not mandatory, but useful, as it indicates file beeing read only.
<br/><br/>
<h2>Kate</h2>
I'm not really a KDE guy (these days/years :), but this might be be still be useful for those using kate editor:
<pre class="prettyprint lang-sh">
tail -f some.log | kate -i
</pre>
<h2>Bash integration</h2>
In the comments of the <a href="http://www.commandlinefu.com/commands/view/1199/pipe-stdout-to-vim">sites (commandlinefu)</a>, where I've found the solution for gvim was one more usecase that caught my attention. Having in the .bashrc following:
<pre class="prettyprint lang-sh">
function gv() {
$@ | gvim -R -
}
</pre>
Enables me doing:
<pre class="prettyprint lang-sh">
gv tail -f some.log
</pre>
what makes things even more comfortable.
Sure you could replace the function name, as well as the editor with the ones you prefer.
<br/><br/>
Well, that's it, enjoy (or forget it if you find it useless :) or if interested, share how you achieve it with your editor of choice.Anonymoushttp://www.blogger.com/profile/11194363658850134703noreply@blogger.com0tag:blogger.com,1999:blog-4811230411463802277.post-91054268337755273402013-10-20T23:26:00.001+02:002013-10-21T19:43:25.511+02:00XML processing in shell.<b>Q:</b> Have you ever been struggling with <b>xml processing in shell</b>?<br />
<b>A:</b> There's an elegant tool: <b>Xmlstarlet</b> (<a href="http://xmlstar.sourceforge.net/">http://xmlstar.sourceforge.net/</a>).<br />
<br />
<h2>
Why would you care?</h2>
Well, if you:<br />
<ul>
<li>use the <b>shell environment</b> (bash in my case),</li>
<li>have a need for <b>XML data extraction/transformation</b> and</li>
<li>you know/are willing to learn <b>XPath/Xslt</b></li>
</ul>
then you should. In fact it might be the perfect match.<br /><br />
<h2>
Download/Installation</h2>
Follow the <a href="http://xmlstar.sourceforge.net/download.php">official docs</a>.
According to the link, if you're Linux (it's easy as things should be, I guess): "Bundled with your nearest Linux distribution"<br />
<br />
<h2>
Usage</h2>
Well, I'd recommend to check the:<br />
<pre class="prettyprint lang-sh">
man xmlstarlet
</pre>
and
<pre class="prettyprint lang-sh">
xmlstarlet --help
</pre>
I'm going to focus on the one part of the functionality only, namely: <b>data extraction</b>, to see the official help, go for:
<pre class="prettyprint lang-sh">
xmlstarlet sel
</pre>
Output is quite impressive, giving you even some examples, for those lazy (like me), I copy/paste here:
<pre class="prettyprint lang-sh linenums">
XMLStarlet Toolkit: Select from XML document(s)
Usage: xmlstarlet sel <global-options> {<template>} [ <xml-file> ... ]
where
<global-options> - global options for selecting
<xml-file> - input XML document file name/uri (stdin is used if missing)
<template> - template for querying XML document with following syntax:
<global-options> are:
-Q or --quiet - do not write anything to standard output.
-C or --comp - display generated XSLT
-R or --root - print root element <xsl-select>
-T or --text - output is text (default is XML)
-I or --indent - indent output
-D or --xml-decl - do not omit xml declaration line
-B or --noblanks - remove insignificant spaces from XML tree
-E or --encode <encoding> - output in the given encoding (utf-8, unicode...)
-N <name>=<value> - predefine namespaces (name without 'xmlns:')
ex: xsql=urn:oracle-xsql
Multiple -N options are allowed.
--net - allow fetch DTDs or entities over network
--help - display help
Syntax for templates: -t|--template <options>
where <options>
-c or --copy-of <xpath> - print copy of XPATH expression
-v or --value-of <xpath> - print value of XPATH expression
-o or --output <string> - output string literal
-n or --nl - print new line
-f or --inp-name - print input file name (or URL)
-m or --match <xpath> - match XPATH expression
--var <name> <value> --break or
--var <name>=<value> - declare a variable (referenced by $name)
-i or --if <test-xpath> - check condition <xsl:if test="test-xpath">
--elif <test-xpath> - check condition if previous conditions failed
--else - check if previous conditions failed
-e or --elem <name> - print out element <xsl:element name="name">
-a or --attr <name> - add attribute <xsl:attribute name="name">
-b or --break - break nesting
-s or --sort op xpath - sort in order (used after -m) where
op is X:Y:Z,
X is A - for order="ascending"
X is D - for order="descending"
Y is N - for data-type="numeric"
Y is T - for data-type="text"
Z is U - for case-order="upper-first"
Z is L - for case-order="lower-first"
There can be multiple --match, --copy-of, --value-of, etc options
in a single template. The effect of applying command line templates
can be illustrated with the following XSLT analogue
xml sel -t -c "xpath0" -m "xpath1" -m "xpath2" -v "xpath3"
-t -m "xpath4" -c "xpath5"
is equivalent to applying the following XSLT
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:call-template name="t1"/>
<xsl:call-template name="t2"/>
</xsl:template>
<xsl:template name="t1">
<xsl:copy-of select="xpath0"/>
<xsl:for-each select="xpath1">
<xsl:for-each select="xpath2">
<xsl:value-of select="xpath3"/>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
<xsl:template name="t2">
<xsl:for-each select="xpath4">
<xsl:copy-of select="xpath5"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
XMLStarlet is a command line toolkit to query/edit/check/transform
XML documents (for more information see http://xmlstar.sourceforge.net/)
Current implementation uses libxslt from GNOME codebase as XSLT processor
(see http://xmlsoft.org/ for more details)
</pre>
Please note the switch:
<pre class="prettyprint lang-sh">
-C or --comp - display generated XSLT
</pre>
This can really help if you're struggling on particular problem, to see what's really done in the background.<br />
<br />
Let's jump directly to examples.<br /><br />
<h2>
XmlStarlet in action</h2>
Imagine sample xml (copied from <a href="http://www.w3schools.com/xml/xml_attributes.asp">http://www.w3schools.com/xml/xml_attributes.asp</a>) called sample.xml:
<br />
<pre class="prettyprint lang-xml linenums">
<messages>
<note id="501">
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
<note id="502">
<to>Jani</to>
<from>Tove</from>
<heading>Re: Reminder</heading>
<body>I will not</body>
</note>
</messages>
</pre>
<br /><br />
<h3>
Element value selection</h3>
Let's say, we want to extract all 'from' element values. Using:
<pre class="prettyprint lang-sh">
xmlstarlet sel -t -m "messages" -m "note" -v "from" < sample.xml
</pre>
we get:
<pre class=prettyprint lang-sh>
JaniTove
</pre>
So what have we done?
<ul>
<li>sel - select data or query XML document</li>
<li>-t - template definition</li>
<li>-m "messages" - match "messages" XPath expression</li>
<li>-m "note" - match "note" XPath expression</li>
<li>-v "from" - print value of "from" XPath expression</li>
<li>sample.xml - test input file used</li>
</ul>
Do you want to see the xslt used in the background? No problem, just go for:
<pre class="prettyprint lang-sh linenums">
xmlstarlet sel -C -t -m "messages" -m "note" -v "from" < sample.xml
</pre>
to see:
<pre class="prettyprint lang-xml linenums">
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exslt="http://exslt.org/common" version="1.0" extension-element-prefixes="exslt">
<xsl:output omit-xml-declaration="yes" indent="no"/>
<xsl:template match="/">
<xsl:for-each select="messages">
<xsl:for-each select="note">
<xsl:call-template name="value-of-template">
<xsl:with-param name="select" select="from"/>
</xsl:call-template>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
<xsl:template name="value-of-template">
<xsl:param name="select"/>
<xsl:value-of select="$select"/>
<xsl:for-each select="exslt:node-set($select)[position()&gt;1]">
<xsl:value-of select="'&#10;'"/>
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
</pre>
easy, right?
<br /><br />
<h3>
Selecting xml element</h3>
Do you need whole element, not just value? Go for:
<pre class="prettyprint lang-sh">
xmlstarlet sel -t -m "messages" -m "note" -c "from" < test.xml
</pre>
to see:
<pre class="prettyprint lang-xml">
<from>Jani</from><from>Tove</from>
</pre>
Where only new flag introduced is:
<ul>
<li>-c "from" - print value of "from" XPath expression</li>
</ul>
<br />
<h3>
Attribute values</h3>
Let's end the examples with id-attribute values. Let's assume, we're interested in the note's id attribute values:<br />
<pre class="prettyprint lang-sh">
xmlstarlet sel -t -m "messages" -m "note" -v "@id" < test.xml
</pre>
should result in:
<pre class="prettyprint lang-sh">
501502
</pre>
<h2>Conclusion</h2>
XmlStarlet is much more powerful that shown in the examples above. <br/>
However my goal was not to show it all (if interested, go for <a href="http://xmlstar.sourceforge.net/docs.php">official docs</a>) but rather to show you the tool that can help with xml processing in the shell scripts.<br/>
It can save you from quite some unneeded complexity possibly introduced by sed/awk/grep solutions as it respects commented sections, ... and brings <b>the full XPath power to your scripting</b>.<br/><br/>
Well, I need to admit, that the tool's development is somewhat stalled. Usually, that's not a good indicator. Still I consider it mature and extremely useful.Anonymoushttp://www.blogger.com/profile/11194363658850134703noreply@blogger.com1tag:blogger.com,1999:blog-4811230411463802277.post-12919571980623117722013-09-24T23:16:00.002+02:002013-09-24T23:16:29.682+02:00Energy saving with Raspberry Pi ssh serverI've noticed that after couple days of running my Raspberry Pi server (<a href="http://peter-butkovic.blogspot.com/2013/08/raspberry-pi-driven-dropbox-alternative.html">Raspberry Pi driven Dropbox alternative</a>) I had a problem with connectivity to ssh. Not sure why, but it doesn't really bother me, as I've noticed it only once up to now. Once restarted ssh worked again.
<br/><br/>
Anyway as I <b>don't need it to be running 24/7</b> but rather there are couple hours in night, when there is definitely no need to have it up.
<br/><br/>
<h2>Electronic timer switch</h2>
As I had a chance to buy electronic timer switch at "Flohmarkt" (<a href="http://www.flohmarkt-riem.com/">in Riem</a> seems to be one of the biggest ones), as it was a good deal I bought 3, where 2 seem to work (still it was worth it). After some googling I've found <a href="(http://www.philex.com/assets/downloads/products/76933R_IM_V1_3.pdf)">quite detailed manual</a> (for I guess the British version).
<br/><br/>
<h2>Final setup</h2>
I ended up with following:
<ul>
<li><b>electronic timer switch</b> has been programmed in the way it turns off at 01:00am and goes back on at some time in the morning (depending on weekday or weekend) and</li>
<li><b>cron job</b> has been setup to switch the Raspberry Pi 5 minutes before hard unplug (in my setup are 5 mins enough):
<pre class="prettyprint lang-sh">
# m h dom mon dow command
55 0 * * * /sbin/shutdown -h now
</pre>
</li>
</ul>
That's it. I neither need to worry about hard shutdown (and mess caused to my data) nor about manual startup my ssh server. It's been working fine for couple weeks already for me.Anonymoushttp://www.blogger.com/profile/11194363658850134703noreply@blogger.com0tag:blogger.com,1999:blog-4811230411463802277.post-10554672186768150912013-09-04T10:45:00.000+02:002013-09-04T10:46:14.644+02:00Handling file rollover with tail monitoringThe most of us probably already know the command:
<pre class="prettyprint linenums lang-sh">
tail -f <your_file_to_monitor>
</pre>
it's useful for monitoring whatever has been appended to the file called <your_file_to_monitor>.
<br/><br/>
OK, nothing new here (probably). I could not live without it any more I guess, once I got used to it (as it offers me all the power of linux shell - like piping the output to other command, etc.).
<br/><br/>
The common use case for me is monitoring of the log files created by various java logging frameworks (log4j/sl4j/whatever is used).
<br/><br/>
<h2>Log file rollover problem</h2>
Maybe you've noticed that this works, but from time to time, no more messages are printed. Why that happens? You need to restart it to have it running again.
<br/><br/>
The common problem is the usage of file rollover (for example if file exceeds particular size to be backed up named by specified pattern and logging continues to the empty file named the same as the original one). This is a good practice to prevent log file unlimited growing and keeping some history across application restarts.
<br/><br/>
But the nice guys doing tail considered this option obviously. If you check the man page it has some switches that can be used for the case. Here are the relevant ones:
<pre class="prettyprint linenums lang-sh">
--retry
keep trying to open a file even if it is inaccessible when tail
starts or if it becomes inaccessible later; useful when follow-
ing by name, i.e., with --follow=name
-f, --follow[={name|descriptor}]
output appended data as the file grows; -f, --follow, and --fol-
low=descriptor are equivalent
-F same as --follow=name --retry
</pre>
So to have things running even despite of log file rollover, you should go for:
<pre class="prettyprint linenums lang-sh">
tail -F <your_file_to_monitor>
</pre>
That's it. Easy right?Anonymoushttp://www.blogger.com/profile/11194363658850134703noreply@blogger.com0tag:blogger.com,1999:blog-4811230411463802277.post-35697981437324146162013-09-03T11:12:00.001+02:002013-09-03T11:18:39.061+02:00EJB 3.1 - Local and Remote business interfaces must differHave you ever seen something like this?
<pre class="prettyprint linenums">
Exception during lifecycle processing
java.lang.IllegalStateException: The interface XYZ cannot be both a local and a remote business interface
at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:518)
at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:446)
at com.sun.enterprise.deployment.archivist.Archivist.readRestDeploymentDescriptors(Archivist.java:419)
at com.sun.enterprise.deployment.archivist.Archivist.readDeploymentDescriptors(Archivist.java:396)
at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:271)
at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:280)
at com.sun.enterprise.deployment.archivist.ApplicationArchivist.readModulesDescriptors(ApplicationArchivist.java:611)
at com.sun.enterprise.deployment.archivist.ApplicationArchivist.openWith(ApplicationArchivist.java:229)
at com.sun.enterprise.deployment.archivist.ApplicationFactory.openWith(ApplicationFactory.java:232)
at org.glassfish.javaee.core.deployment.DolProvider.processDOL(DolProvider.java:188)
at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:222)
at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:96)
at com.sun.enterprise.v3.server.ApplicationLifecycle.loadDeployer(ApplicationLifecycle.java:878)
at com.sun.enterprise.v3.server.ApplicationLifecycle.setupContainerInfos(ApplicationLifecycle.java:818)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:374)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:527)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:523)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:356)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:522)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:546)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1423)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1500(CommandRunnerImpl.java:108)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1762)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1674)
at org.glassfish.admin.rest.resources.admin.CommandResource.executeCommand(CommandResource.java:396)
at org.glassfish.admin.rest.resources.admin.CommandResource.execCommandSimpInMultOut(CommandResource.java:234)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:125)
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:152)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:91)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:346)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:341)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:101)
at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:224)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:198)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:946)
at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.service(GrizzlyHttpContainer.java:331)
at org.glassfish.admin.rest.adapter.JerseyContainerCommandService$3.service(JerseyContainerCommandService.java:165)
at org.glassfish.admin.rest.adapter.RestAdapter.service(RestAdapter.java:181)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:246)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
at java.lang.Thread.run(Thread.java:724)
Caused by: The interface XYZ cannot be both a local and a remote business interface
at org.glassfish.ejb.deployment.annotation.handlers.AbstractEjbHandler.setBusinessAndHomeInterfaces(AbstractEjbHandler.java:471)
at org.glassfish.ejb.deployment.annotation.handlers.StatelessHandler.setEjbDescriptorInfo(StatelessHandler.java:143)
at org.glassfish.ejb.deployment.annotation.handlers.AbstractEjbHandler.processAnnotation(AbstractEjbHandler.java:270)
at com.sun.enterprise.deployment.annotation.factory.SJSASFactory$LazyAnnotationHandler.processAnnotation(SJSASFactory.java:148)
at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:344)
at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:375)
at org.glassfish.apf.impl.AnnotationProcessorImpl.processAnnotations(AnnotationProcessorImpl.java:289)
at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:195)
at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:134)
at com.sun.enterprise.deployment.archivist.Archivist.processAnnotations(Archivist.java:626)
at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:462)
... 69 more
</pre>
where XYZ would be the name of the interface referred as Local and Remote from some stateless session bean.
<br/><br/>
Well, once I did migration to Glassfish 4.0 I've noticed that. The message is quite clear, however the question is why that would be a problem. As having one interface serving as Local as well as Remote for stateless session EJB is quite common practice I think.
<br/><br/>
<h2>Root cause</h2>
The <a href="https://community.jboss.org/message/779633">JBoss forum message</a> pointed me to the right direction.
<br/><br/>
The thing is that EJB 3.1 specs (implemented in Glassfish 4.0) section 4.9.7 says:
<pre class="prettyprint">
The same business interface cannot be both a local and a remote business interface of the bean.
</pre>
For those interested, see the full specs on: <a href="http://download.oracle.com/otndocs/jcp/ejb-3.1-fr-eval-oth-JSpec/">http://download.oracle.com/otndocs/jcp/ejb-3.1-fr-eval-oth-JSpec/</a>
<br/><br/>
<h2>Solution</h2>
OK, but how to fix it? I recommend you to read <a href="http://www.adam-bien.com/roller/abien/entry/beans_with_both_views_local">Adam Bien's suggestion</a>.
<br/><br/>
Basically, the idea might be the analogy to package protection present in java and easy solution can be creation of extra interface that would inherit existing one and be used as Local. Possibly having Local suffix.Anonymoushttp://www.blogger.com/profile/11194363658850134703noreply@blogger.com0tag:blogger.com,1999:blog-4811230411463802277.post-2816299911575315702013-09-02T14:16:00.001+02:002013-09-02T14:16:39.531+02:00Is Glassfish 4.0 with Hibernate JPA a dead end?Glassfish 4.0 with Hibernate JPA stable? Nope, see: <a href="https://java.net/jira/browse/GLASSFISH-20716">https://java.net/jira/browse/GLASSFISH-20716</a>
<br/><br/>
You need to go for JPA 2.1. But there is no stable release of Hibernate supporting it yet <a href="https://hibernate.atlassian.net/browse/HHH?selectedTab=com.atlassian.jira.plugin.system.project%3aversions-panel&subset=-1">(https://hibernate.atlassian.net/browse/HHH?selectedTab=com.atlassian.jira.plugin.system.project%3aversions-panel&subset=-1</a>)!
<br/><br/>
Well, what can I say, I was disappointed as well. Unless you do some non-production code, feel free to give it a try with 4.3.0 BetaX. Otherwise, have some rest and cross your fingers for Hibernate guys or look elsewhere.Anonymoushttp://www.blogger.com/profile/11194363658850134703noreply@blogger.com0tag:blogger.com,1999:blog-4811230411463802277.post-5508985882050283342013-08-22T09:42:00.007+02:002013-08-22T19:54:53.186+02:00Raspberry Pi driven Dropbox alternativeAs mentioned earlier I <a href="http://peter-butkovic.blogspot.com/2013/07/raspberry-pi-my-new-home-server-for-70.html">bought <a href="http://www.raspberrypi.org/">Raspberry Pi</a></a>. After some struggles with the board shipping I finally got it almost one month after my order. Components work as expected. I went for official Debian image installation.
<br/><br/>
Lately there has been quite some publicity about privacy and security on the the public services hosting data. So I decided to minimize the <a href="https://www.dropbox.com/">Dropbox</a> usage for file sync and go for locally hosted solution. It doesn't mean I'm out of dropbox, but rather I use it only for things I need to share outside my LAN.
<br/><br/>
<h2>My synchronization requirements</h2>
<ul>
<li>two way sync</li>
<li>non-interactive sync</li>
<li>sync over ssh/local dirs (as pi works with ssh as a server out of the box)</li>
<li>support for star topology - PC1..n (laptops) <-> Server (Raspberry Pi)</li>
<li>keep additional dependencies to be installed on Raspberry low</li>
<li>enable sync within LAN only (as I have quite some restricted internet connection with respect to data transfer quotas)
<li>operating on demand, rather than instantly (I want to use pi for other things as well and it's performance is not too impressive)</li>
</ul>
<br/>
<h2>Alternative synchronization programs</h2>
I checked briefly only following:
<ul>
<li><a href="http://rsync.samba.org/"><b>rsync</b></a>
<ul>
<li>quite popular and maintained,</li>
<li>but <b>not recommended for 2 way sync</b> (as suggested on: <a href="http://stackoverflow.com/questions/2936627/two-way-sync-with-rsync">)Two way sync with rsync</a>.</li>
</ul>
<li><a href="http://http://www.cis.upenn.edu/~bcpierce/unison/"><b>Unison</b></a>
<ul>
<li>quite well known,</li>
<li>but <b>not actively developed any more</b>, still patches seem to be applied from time to time.</li>
</ul>
<li><a href="http://owncloud.org/"><b>ownCloud</b></a>
<ul>
<li>looks actively developed</li>
<li>but compared to other 2 - <b>eats more resources</b> (on both sides, client and server)</li>
</ul>
</ul>
To me, the unison looks like a winner. So I went for it.
<br/><br/>
<h2>Unison setup from scratch on Pi</h2>
I followed these steps:
<ol>
<li><b>[on server]</b> changed default raspberry password via:
<pre class="prettyprint linenums lang-sh">
passwd
</pre>
</li>
<li><b>[on clients and the server]</b> set up password-less authentication for ssh connection (following the <a href="http://www.howtoforge.com/setting-up-unison-file-synchronization-between-two-servers-on-debian-squeeze">howtoforge tutorial</a>)</li>
<li><b>[on clients and the server]</b> installed unison:
<ul>
<li>
For Fedora:
<pre class="prettyprint linenums lang-sh">
sudo yum install unison
</pre>
</li>
<li>
For (X)ubuntu/Debian:
<pre class="prettyprint linenums lang-sh">
sudo apt-get install unison
</pre>
</li>
</ul>
<li><b>[on clients]</b> setup unison with ssh as a synch protocol (following the <a href="http://www.howtoforge.com/setting-up-unison-file-synchronization-between-two-servers-on-debian-squeeze">howtoforge tutorial</a>) with the custom unison preferences file (see next section for reference).</li>
</ol>
That was basically it.
<br/><br/>
<h2>Custom setup</h2>
I created new unison preferences file:
<pre class="prettyprint linenums lang-sh">
~/.unison/unison.prf
</pre>
that has following contents:
<pre class="prettyprint linenums lang-sh">
# WATCH OUT: keep in sync across clients!
# dirs
root = /home/pb/unison
root = ssh://pi@192.168.2.109//media/My Book/pi/unison
# Work silently
batch = true
auto=true
times = true
# logging
log = true
logfile = /home/pb/.unison/unison.log
# Prevent deletion of all files if all files are locally deleted
confirmbigdeletes = true
# Check fast, don’t compare bit by bit
fastcheck = true # "the default on Unix systems", see <a href="http://www.cis.upenn.edu/~bcpierce/unison/download/releases/stable/unison-manual.html">docs</a>
# ignore stuff
ignore = Name *~ ## ignores all files with ~ (gedit backup files)
</pre>
Then I went for one more step. To synchronize via command line I issue following command on my client machines:
<pre class="prettyprint linenums lang-sh">
unison -ui text unison
</pre>
To make my life easier, I created in:
<pre class="prettyprint linenums lang-sh">
~/.bashrc
</pre>
alias:
<pre class="prettyprint linenums lang-sh">
alias u-u="unison -ui text unison"
</pre>
So that I can simply initiate the synchronization with:
<pre class="prettyprint linenums lang-sh">
u-u
</pre>
That's it for my setup. Please note the paths as well as server IP should be adapted in case you'd be using it.
<br/><br/>
<h2>More info/inspiration</h2>
For more information, that I got inspired with, see:
<ul>
<li><a href="http://stackoverflow.com/questions/5891745/unison-star-topology">unison star topology</a></li>
<li><a href="http://www.markus-gattol.name/ws/unison.html">File Synchronization with Unison</a> - really detailed description</li>
<li><a href="http://www.howtoforge.com/setting-up-unison-file-synchronization-between-two-servers-on-debian-squeeze">Setting Up Unison File Synchronization Between Two Servers On Debian Squeeze </a></li>
<li><a href="http://www.cyberciti.biz/faq/unison-file-synchronizer-tool/">UNIX / Linux: HowTo Use unison File Synchronizer</a></li>
</ul>Anonymoushttp://www.blogger.com/profile/11194363658850134703noreply@blogger.com0tag:blogger.com,1999:blog-4811230411463802277.post-38030490076391927472013-08-14T17:24:00.000+02:002013-08-15T21:40:02.624+02:00tail: inotify resources exhaustedI've been facing issue with tail. Once executing:
<pre class="prettyprint linenums lang-sh">
tail -f <filename_to_tail>
</pre>
I got error:
<pre class="prettyprint linenums lang-sh">
tail: die Inotify-Resourcen sind erschöpft
tail: Inotify kann nicht verwendet werden, es wird auf Pollen zurückgegriffen
</pre>
For those of you having english locale, you'd see:
<pre class="prettyprint linenums lang-sh">
tail: inotify resources exhausted
tail: inotify cannot be used, reverting to polling
</pre>
While looking around I've found following to be valuable in understanding the problem and solving it:
<ul>
<li>Stackoverflow: <a href="http://stackoverflow.com/questions/9935253/permanent-fix-to-tail-cannot-watch-log-development-log-no-space-left-on-devi">Permanent fix to tail: cannot watch `log/development.log': No space left on device</a></li>
<li><a href="http://la-samhna.de/samhain/manual/finotify.html">Inotify support on Linux (instantaneous reports, no I/O load)</a></li>
</ul>
So the error itself means that system is getting low on inotify watches, that enable programs to monitor file/dirs changes.
<br/><br/>
To see the currently set limit (including output on my machine), I executed:
<pre class="prettyprint linenums lang-sh">
cat /proc/sys/fs/inotify/max_user_watches
8192
</pre>
Well, I had to decide about the limit. So I went for 1048576 (not sure why :) ). To set it I've found 2 solutions.
<br/><br/>
<h2>Temporary solution (not preserved across restarts)</h2>
As I'm used to sudo, I went for:
<pre class="prettyprint linenums lang-sh">
sudo echo 1048576 > /proc/sys/fs/inotify/max_user_watches
-bash: /proc/sys/fs/inotify/max_user_watches: Keine Berechtigung
</pre>
OK, not working. Complaining about user rights on /proc/sys/fs/inotify/max_user_watches. Then based on: <a href="http://stackoverflow.com/questions/82256/how-do-i-use-sudo-to-redirect-output-to-a-location-i-dont-have-permission-to-wr">How do I use sudo to redirect output to a location I don't have permission to write to?</a> I went for:
<pre class="prettyprint linenums lang-sh">
sudo sh -c 'echo 1048576 > /proc/sys/fs/inotify/max_user_watches'
</pre>
which worked, as the command proofs:
<pre class="prettyprint linenums lang-sh">
cat /proc/sys/fs/inotify/max_user_watches
1048576
</pre>
The problem is that the value is reset each time I rebooted.
<br/><br/>
<h2>Permanent solution (preserved across restarts)</h2>
Adding line:
<pre class="prettyprint linenums lang-sh">
fs.inotify.max_user_watches=1048576
</pre>
to:
<pre class="prettyprint linenums lang-sh">
/etc/sysctl.conf
</pre>
fixed the limit value permanently (even between restarts).
<br/><br/>
<h2>Deeper analysis</h2>
However if you're interested to investigate problem in deep, it would be good idea to find out who is using the resources. There seem to be an idea at <a href="http://unix.stackexchange.com/questions/15509/whos-consuming-my-inotify-resources">unix.stackexchange: Who's consuming my inotify resources?</a>.
<pre class="prettyprint linenums lang-sh">
for foo in /proc/*/fd/*; do readlink -f $foo; done | grep inotify | sort | uniq -c | sort -nr
</pre>
However for me it didn't show any output I could analyse to dig deep.
<br/><br/>
On the other hand I convinced myself that Dropbox is guilty here. Even though I have no proof for that (just read on some of the sources where someone suspected the same service).Anonymoushttp://www.blogger.com/profile/11194363658850134703noreply@blogger.com0