Friday, 23 November 2012

Missing menubar in (K)Ubuntu 12.10

After updating to and installing 12.10 of Kubuntu my GTK apps are missing their main menubars. Somewhere I read a cool solution that seems to work right offthe bat:
sudo apt-get purge appmenu-gtk appmenu-gtk3 appmenu-qt

Monday, 10 September 2012


This is a small summary for anyone who struggles often - on Ubuntu recently - to get the so called "Sun Java JDK", now belongs to Oracle onto their system. My strategy is to exclude any kind of Java packages from my installation and download only the self extracting JDK from the Oracle website. Once downloaded and extracted into my home directory I can easily  reference that directory in the various global variables that my softwares are searching for.
On Ubuntu I use a dumb-simple shell script that is put into the /etc/profile.d directory with the extension of .sh. The content of my version is like this:

export WEBIDE_JDK="/home/ikon/app/jdk"export RUBYMINE_JDK="/home/ikon/app/jdk"export SMARTGIT_JAVA_HOME="/home/ikon/app/jdk"export SMARTSYNCHRONIZE_JAVA_HOME="/home/ikon/app/jdk"
Here the /home/ikon/jdk is where I extracted the JDK to. The variable names can be looked up from the starter shell scripts of the softwares. This way I even made those softwares "portable" :)

Thursday, 30 August 2012

Using the same icon theme for GTK under KDE

I wanted to use Clearlooks on both Kde and within Kde all the GTK apps. But GTK apps started to use the default, ugly gnome icon theme. So I made this change to the following file, called .gtkrc-2.0-kde4 and back to business, using Oxygen icon theme everywhere ^_^.

Monday, 27 August 2012

Create desktop launcher in Ubuntu 12.04

There is a certain flaw in usability for power users in the new Ubuntu 12.04 out-of-the-box. I cannot create a desktop shortcut as easy as it was used to be.
Instead, I have to install gnome-panels package and then use this command:
gnome-desktop-item-edit Desktop --create-new
to get a popup that was so natural it is a crime to miss it.

Thursday, 31 May 2012

Find files and do something with them

  • Find removed (deleted) files still in use via /proc:
# find -L /proc/*/fd -links 0 2 > /dev/null
  • Remove .svn folders recursively. (I have seen solutions using the -exec switch, but it is too slow, so I use find's own delete option here)
$ find . -name ".svn" -type d -delete;
  • Find and delete files with multiple choice of names:
$  find /path -name '.DS_Store' -or -name '._*' -delete
  •  Finding file in .h with "raoul" in it ( the "-n" is for displaying line number ):
$  find /path -name "*.h" | grep -n "raoul"
  • Find empty folders:
$  find /path -type d -empty
  • Find empty folder and list:
$  find /path -type d -empty -ls
  • Find empty folder and save result in temporary file:
$  find /path -type d -empty -fls /path/to/tempfile.txt

Saturday, 14 April 2012

How to configure a local subdomain development with Linux


In the following scenario everything is done within one machine. This setup can be recreated with more then one machine as well. Use your imagination!


I want to have subdomains like static.mydomain or whatever.mydomain.


  • any host OS that is capable of running Virtualbox, VMware or your favorite virtualisation software
  • a linux distribution that uses/supplies a small kernel, like Ubuntu server, Fedora without X, Arch or any of your choice, preferably one that you are familiar with. Of course if you are not a linux guru you can  still use a gui, just give enough memory for your guest linux.

Setup process

  1. have your virtualisation software set up on your host
  2. install your linux distro of choice as a guest, it is best to use at least one "Bridged" (my choice) or "Host only" network adapters that every other guest machine can see too if you later need it. 
  3. set up your /etc/resolv.conf file to have your nameservers in the following order:
    (NOTE: only the first one has to be your localhost, the remaining two is your choice of providers)

  4. install the package that has dnsmasq in it or compile it from source.
  5. setup dnsmasq according to the example below:

dnsmasq configuration

Generally the config file is at /etc/dnsmasq.conf.
Let's say you want to have a domain that is resolved by your machine -who take part in the development- as one of the dev machines address on the local network. For example I want to have the domain ikondev to be resolved to the ip address of VM1 (Virtual Machine 1 on the above image). This way we can have several subdomains for ikondev without updating /etc/hosts file each and every time we add a new subdomain to our webserver to listen to.

In your dnsmasq.conf set the following lines: (these lines has to be uncommented too)

  • domain-needed
  • bogus-priv
  • strict-order (this will make this local DNS server to be the main nameserver)
  • address=/ikondev/ (this is the entry for the ikondev domain to point to the machine with You can set up several more entries like this of course)
  • interface=eth0 (eth0 has to be changed to your network interface which connects to the development network)
  • no-dhcp-interface=eth0 (eth0 has to be the same as the one for the previous setting as we do not want to set up a dhcp server)

Final touches

Now all we have to do is restart the network and the dnsmasq services and set all the dev machines primary nameserver to be VM2's ip address as it will be serving our local and mainstream resolves.
Voila! all subdomains typed for ikondev will be resolved as VM1. :)

Thursday, 29 March 2012

Access a remote service localy via ssh

This will be just a short reminder for myself not to forget how to forward a remote service's port to a local one through ssh. Here is the schema:
ssh -i .ssh/ssh_keys/root -L 55432:localhost:5432
With -i we use a private key to the remote host's user named root at the end. Next we say we want to access a local port -55432- and send the data through that one to the remote port -5432-. We want to use our localhost to address the service which is hosted on the machine.

This wraps it up. ^_^

Saturday, 24 March 2012

How to cut FLAC with CUE files

I have read the best and simplest procedure for Windows on this forum thread:

Here is the recipe:
  1. Get Flac, you just need flac.exe, put it in some directory;
  2. Open the .cue file in Foobar;
  3. Select all the tracks, right-click, choose 'convert', choose '...';
  4. Click 'output format', choose FLAC, click 'edit' and set it to 8;
  5. Click 'destination' and choose your options;
  6. Click 'processing' and make sure 'enable decode...' is off, and 'active dsps' is empty;
  7. Click convert, foobar will ask you were you put flac.exe, navigate to it and voila.
You can use the "bit compare" plugin to make sure the new converted tracks are bit identical to the original ones.

Monday, 12 March 2012

Directory tree in Bash

I was recently searching for a bash script that could be used to create the skeleton of a yaml file containing directory structure. The best material I found is here:

With the modification of this line:
find ./ -type d | sed -e 's/[^-][^\/]*\//--/g;s/--/ |-/'
I managed to produce the best skeleton:
find ./ | sed -e 's/[^\/]*\// /g'
Since I still have to shape this file up with more data I am not bothering with finding a method to put the ':' at the end of each directory as I can do it myself with little effort. I use Vim's visual mode to get rid of the extra leading spaces at each line.

Monday, 27 February 2012

Limiting Access with SFTP Jails on Ubuntu

This post is based on this article with it's comments.

In the /etc/ssh/sshd_config file edit the Subsystem like this:
Subsystem sftp internal-sftp
Add these to the end of the file:
Match group filetransfer
  ChrootDirectory %h
  X11Forwarding no
  AllowTcpForwarding no
  ForceCommand internal-sftp
Finally restart the OpenSSH server:
service ssh restart
Create the group for sftp access:
addgroup filetransfer
If you add this group to existing users, then they will be prevented to login via remote shell, though still be available through su.
usermod -G filetransfer username
chown root:root /home/username
chmod 755 /home/username
Now users cannot create anything in their jail, but it can be tuned with the last command. Though I personally use this technique to jail those users that are able to manage their own websites' content through sftp. I add those web directories through mount's bind option as the normal symlinks won't work. You can either add bindings via the /etc/fstab like this:
/existing/dir /dir/pointing/to/existing/one auto bind 0 0
or via the command line:
mount -o bind /existing/dir /dir/pointing/to/existing/one

Friday, 24 February 2012

Convert virtual machine disks VDI to VMDK

I recently wished to migrate my dev vm from VirtualBox To VMware. So the only thing I needed is to convert the VDI virtual disk into VMware's VMDK format as VirtualBox can read several disk types but VMware needs it's own child.
So as long as VirtualBox is still installed, I could use this simple command:
vboxmanage clonehd old_virtualbox_disk.vdi new_vmware_disk.vmdk –format VMDK –variant standard
Obviously, you have to find the vboxmanage executable yourself on your system. This command is crossplatform. :)

Sync MAC address of virtual machine

When I use VirtualBox or VMware I sometimes have to change the network adapters of the virtual quests and there comes the problem in case of my Ubuntu VMs that their ethX adapter's expected MAC address differs from the one they get from the host. Here is that single config file that you have to sync to contain the new address:

The setting containing MAC address in the interface's line is:

 After reboot everything is ok :)

Wednesday, 11 January 2012

Faster transactions in PostgreSQL

First of all: BE WARNED! 

These settings are not recommended for all of you (if any) in production as they might cause you data corruption or loss in case of sudden hardware failure.
I would on suggest to have these settings used in a development environment, where you have to run many tests for your application which include database side create/drop transactions.

My case here was that I ran so much database inclusive tests, that I got fed up with PostgreSQL's ~6s database creation time. So I just Googled it a few days how this could be done in a dev env. So here it is, you just set these two variables in your postgresql.conf file and reastart the database.

Sunday, 8 January 2012

How do I install my Nginx with Passenger

While there are pretty much use to run a project in standalone Passenger I'd rather run it with the web server of the production environment. My choice is Nginx. Not because of it's high load speed as I do not (yet) run any high visited websites or loaded applications, but I have found it's configuration simpler then Apache's. Yes, not modular, you cannot enable, disable some things in runtime, but hey I do not really need that either.

So basically I download the nginx source, extract it somewhere. Install the passenger gem. Then run this command:

rvmsudo passenger-install-nginx-module

If it finds every package installed - note that you might need libpcre3 and libpcre3-dev packages too on Ubuntu - then I choose the option 2 which will let me configure nginx further. When it asks for the extra arguments for configure I use these:

--prefix=/etc/nginx --user=www-data --group=www-data --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx/ --lock-path=/var/lock/nginx.lock --with-cpu-opt=amd64 --without-http_userid_module --without-http_upstream_ip_hash_module --without-http_ssi_module --without-http_split_clients_module --without-http_scgi_module --without-http_proxy_module --without-http_geo_module --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --with-http_gzip_static_module --with-http_ssl_module --without-http_browser_module --without-http_limit_req_module --without-http_limit_zone_module --without-http_map_module --without-http_memcached_module --without-http_referer_module

Note I have --with-cpu-opt=amd64 enabled as my virtual machine can use my CPU directly, which is now a AMD Phenom X6.

All done, let the compilation begin! When it's finished we are good to go to use nginx by it's command.

If you have questions feel free to ask in a comment!

Thursday, 5 January 2012

Mount Windows share on Ubuntu with CIFS

The package that is needed to be installed is called smbfs.

For permament mount at every boot add something like this to /etc/fstab:

// /media/servfolder cifs username=xxxxx,password=yyyyyy,uid=1000,gid=1000,file_mode=0777,dir_mode=0777noserverino,rw,nolinux,iocharset=utf8 0 0

As a shell script, the command would be like this:

mount -t cifs //192.168.x.x/hostdir /opt/clientdir -o username=hostuser,password=hostuserpass,uid=1000,gid=1000,file_mode=0664,dir_mode=0775,noserverino,rw,iocharset=utf8

Wednesday, 4 January 2012

How to center a DIV in a DIV


<div id="outer" style="width:100%">
    <div id="inner">Foo foo</div>


#inner {
    width: 50%;
    margin: auto;

Tuesday, 3 January 2012

Vim: Format different type of code in one file

Let's say you have a PHP file with some HTML code mixed in.

:set filetype=html

And then highlight your text and hit  = . BOOM! HTML formatting succes.