Removing stale local branches in git

At work we use git as our SCM. I love it. For every feature or bug fix we work on we create a branch for it, as most users of git do (or should). This branch will exist both locally and on our central git repository (GitHub). Typically the branch will be reviewed on GitHub and then merged in and the branch will be deleted to clean up the number of branches in GitHub. This creates a small maintenance problem locally. When I run git branch I now see so many branches and I have no idea which ones I actually need or have changes on that I should save.

I spent a little time and created a little script to help me keep my local branches cleaned up. See below if you just want to copy it and try it out.

Here is what happens. I first run git fetch –prune. This command will fetch all the changes from the remote repository and delete any references that exist to remote branches that no longer exist.

After that I can run git branch -avv. This command alone is a pretty neat tool. It will tell you the name of any local branch, the name of a remote branch if it exists, and what the commit message is on the latest commit on that branch. The most important bit of information it gives you is it tells you which local branches have a corresponding remote branch reference but that reference does not exist anymore. This is identified by the keyword “gone” in the output.

After we have got this information, the rest is pretty simple. All we need to do is go through each local branch that has a missing remote reference, check if there are any changes that have not been merged into other branches, and then delete that branch.

Here is the full script. If you name the script something like git-clean-branches (something with a git- prefix), you can run the command like it is built in to git, i.e. git clean-branches. Remember to make it executable and put it on your PATH.


Beautiful IntelliJ Dark Theme on Linux

I have tried several different dark theme options with different IDEs. My primary IDE of choice now is IntelliJ (and the family of JetBrains IDEs, like PyCharm). I tried the new Darcula theme for a little while but just couldn’t stay with it, something about it just irked me.

Today I tried out Sublime text to show some syntax highlighting for a file that doesn’t have it in IntelliJ (VB script…no I don’t write VB script, someone else did and I have to look it over). When I first opened it the theme was just beautiful. I loved it and wanted the same appearance in IntelliJ, and this is what I did to get everything setup

  1. Downloaded and installed the Sublime Monokai Theme from
  2. Changed to the Darcula theme in Settings -> Appearance
  3. Selected SublimeMonokai from Settings -> Editor -> Colors and Fonts
  4. Selected the Consolas Font in Settings -> Editor -> Colors and Fonts -> Font and set the font size to 16
  5. Shutdown IntelliJ and edit the idea.vmoptions file and add -Dawt.useSystemAAFontSettings=lcd and -Dswing.aatext=true

With this setup I can now tolerate a dark theme which is hopefully better for my eyes (right?) and I really like the theme.

Fix Stuck Outgoing Email in GMail for Android

Just ran across a problem today with GMail on my Galaxy Nexus. I had sent 3 emails all containing some photos I took. Went in to GMail a little later and noticed they were still sitting in the outbox marked sending.

I read on a couple forums that quite a few people had the same problem. The only 2 solutions I saw were to either delete the cache and data for the app which clears the email you are sending and other settings in the app. That did not sound like a great idea. Another option someone had was some long extravagant way of replying but not really replying….not sure because I stopped reading

Anyway, I found a pretty simple solution that worked for me. I went to the outbox and opened the email I was sending and selected to forward it and just changed the subject to remove the FWD. Sent it and it worked just fine.

Hope that helps someone else.

Enable Internal Browser in Eclipse on Ubuntu 12.04

I just installed Eclipse Juno on my new Ubuntu 12.04 machine and encountered an error with one of my plugins. It threw an error about an unhandled event loop exception and in the error message it said something about the MOZILLA_FIVE_HOME variable not being set when trying to create a Browser.

I went to the browser preferences and noticed that the internal browser was disabled and it was trying to use Firefox as the browser. It was actually trying to load some of the Firefox libraries that no longer work or exist in Ubuntu (e.g. XULrunner).

To fix this I just installed the proper webkit libraries and after that the internal web browser was enabled and my plugin was working just fine. Here is a quick copy/paste command:

sudo apt-get install libwebkitgtk-1.0-0


Disable sticky edges on Ubuntu 12.04 when using NVidia driver

When using the proprietary NVidia driver on Ubuntu, the displays system preference does not show multiple monitors (just one huge monitor) and thus does not allow you to turn off sticky edges. The sticky edges feature annoys the crap out of me so I had to turn it off. One option is to uninstall the proprietary NVidia driver and use the open source Nouveau driver, but I have never had good experiences with that driver. So I found a way to disable it using the proprietary NVidia driver.

– Install the compizconfig-settings-manager package (sudo apt-get install compizconfig-settings-manager

– Launch CompizConfig Settings Manager

– In the “Desktop” section click on “Ubuntu Unity Plugin”

– Click on the “Experimental” tab

– Change the values for “Launcher Edge Stop Overcome Pressure” and “Edge Stop Velocity” to 1. If you still want a little bit of the sticky edge behavior you can play around with these values but I didn’t want to have my mouse stick at all.

Fun little SSH escape sequences

Today I was doing some things over SSH when I accidentally typed in ~? and hit enter. I was presented with a little help dialog showing a bunch of different SSH escape operators. Here is what I saw:

Supported escape sequences:
  ~.  - terminate connection (and any multiplexed sessions)
  ~B  - send a BREAK to the remote system
  ~C  - open a command line
  ~R  - Request rekey (SSH protocol 2 only)
  ~^Z - suspend ssh
  ~#  - list forwarded connections
  ~&  - background ssh (when waiting for connections to terminate)
  ~?  - this message
  ~~  - send the escape character by typing it twice
(Note that escapes are only recognized immediately after newline.)

I never knew these things existed. I think the one that caught my eye the most was ‘~&’ to background ssh. I have always run into situations where the remote machine will either reboot or the connection will close but it won’t boot me out of SSH and so I have to close the terminal since nothing else will work. If I can just background the ssh process then I can forcefully kill it. I am definitely going to try this out next time it happens.

Disable “Waiting for network configuration” messages on Ubuntu boot

I was just creating a custom live CD for Ubuntu 12.04 and was having a problem with the boot process hanging for several minutes while waiting for the network to be configured. I was trying to see if I could fix it but I have no idea why it is happening for now. I found a bug logged on LaunchPad here that describes a workaround for oneric (11.10) but this fix/workaround is there by default in precise so obviously it didn’t fix my problem.

I didn’t really need networking setup at all and just wanted to skip waiting for the network to be configured. In order to do this you just need to edit the file /etc/init/failsafe.conf. In that file is where it sleeps for several minutes waiting for the network to come up. All I did was:

sudo vim /etc/init/failsafe.conf

I changed the first sleep command to

sleep 5

and then commented out the following lines:

$PLYMOUTH message --text="Waiting for network configuration..." || :
sleep 40
$PLYMOUTH message --text="Waiting up to 60 more seconds for network configuration..." || :
sleep 59

Just place a ‘#’ character at the beginning of each of those lines. Now it will just wait 5 seconds and then continue on.

To my surprise, the network was actually working just fine even though the script thinks it is not.

Just a note, do NOT remove the failsafe.conf file, otherwise it will hang the boot process indefinitely waiting for the network to be “configured.”

The Benefits of Developing a Desktop Linux Distribution for Corresponding Server Distributions

I just happened to be thinking about desktop linux distributions and the effect they have for their corresponding server distributions. I have been a fan of Ubuntu for quite a long time. I took a class in college for web programming and we were forced to use Ubuntu. Ever since then I have used Ubuntu for all of my development and have enjoyed it…up until Canonical decided to screw with the UI. I am not a fan of Unity (or Gnome 3 for that matter but I will take Gnome 3 over Unity). I have setup several different servers to run different web apps and other things and I really prefer to use Ubuntu. The key reason I use the Ubuntu server edition is because I am familiar with all the tools available to manage the system since I use it on my desktop and laptop. I am familiar with how everything works so it makes managing the server much simpler.

Because of the frustration with recent versions of Ubuntu I have started to test out other desktop distributions for my laptop and desktop machines. I first tried using Linux Mint with it’s Cinnamon UI, however I quickly found that Cinnamon was not very mature and didn’t suit my tastes. I guess it’s just like slapping lipstick on a pig, and not very good lipstick either.

After my trials with Linux Mint I almost decided to try out openSuSE. The funny thing is, I work at Novell and work with SuSE Linux Enterprise Server all day and have obviously tried openSuSE before. However, it left a very bad taste in my mouth and several of my colleagues use openSuSE and gripe about it fairly often, so I decided to stay away for now.

That’s when I decided to try out Fedora. I had used fedora before at college (different class) and tested it out briefly on an old laptop I had. Neither of these experiences left a great experience in my mind, but it wasn’t terrible either, the reason Fedora didn’t work so well on my laptop wasn’t really Fedora’s fault. So, anyway, I decided to try out Fedora on my laptop and am absolutely loving it. I love the fact that they have the most recent versions of tons of software. One thing I always loved in Ubuntu was dpkg/apt-get (package management) and the bash completion support…that feature is SERIOUSLY lacking in SuSE and it bugs the crap out of me. However, Fedora’s yum package manager tool is wonderful.

Now, getting to the point where this affects server distributions. Because I have had such an awesome experience with Fedora I am now ready and excited to try out CentOS on my next server that I install. It may still take some getting used to but I know that CentOS/RedHat have a great reputation and I have somewhat of an idea of what to expect.

So everybody that develops a server distribution of Linux, take note and make sure your desktop experience really shines and is delightful to use for engineers that may end up using your server distribution, since we are the ones that will be making the decisions as to what distribution to go with.

Installing Oracle JDK/JRE as default java in Fedora

I copied most of this from a post on a Ubuntu help page and just wanted to copy it down for my own notes since I have had to do this several times. For Fedora I just installed the RPM for the JDK which installs all the java files in /usr/java/jdk1.x.x_xx. To install all the java/javac etc. files so they are picked up by default we need to update the alternatives and set it to pick up the java version installed here, to do this we can just run a little for loop and update the alternatives. This can be copy and pasted as needed but just make sure to change the first line to point to the ‘bin’ directory of your java installation.

export JAVA_BIN_DIR=/usr/java/jdk1.x.x_xx/bin # replace 1.x.x_xx with your installed version
for exe in *; do
sudo update-alternatives --install "/usr/bin/${exe}" "${exe}" "${JAVA_BIN_DIR}/${exe}" 1
sudo update-alternatives --set ${exe} ${JAVA_BIN_DIR}/${exe}

And thats it, test it out by running java -version.

Also, I had a problem where I installed LibreOffice which installed the OpenJDK RPM and it overrode the Oracle java version I had installed, to fix that I just re-ran the above script and it reset it to use the correct java version.

Installing RHEL6 as Paravirtualized VM in XEN

This is probably not a common scenario, but I have RHEL running as a XEN VM on top of SLES (for testing). I am not sure if this is a common problem with XEN or just a problem with SLES but hopefully this will help someone else.

The trouble I had getting RHEL6 to install as a paravirtualized VM on XEN was the vm-install process was trying to boot a kernel from the installation media that didn’t exist. I would get errors that the path /images/xen/vmlinuz didn’t exist and even when I fixed that after rebooting it would fail because it couldn’t find the correct kernel. To get around this just takes a few little steps.

First, you need to copy the installation media to a web server and make a symbolic link from /images/pxeboot/ to /images/xen and so when XEN launches the installation it will pick up the pxeboot vmlinuz image which actually works just fine.

The next step is at the end of the installation don’t reboot. You need to go to the console on the VM. With the gui vm-install you can just hit the menu item ‘Send Key’->’Ctrl-Alt-F2′. Now you need to go to the /mnt/sysimage/boot directory. Here is where your dom0 xen will look for a kernel to use to boot. It will look for a file called vmlinuz-xen or vmlinuz-xenpae. Look for the default vmlinuz (mine was called vmlinuz-2.6.32-71.el6.i686). Now just make a symbolic link from that file to vmlinuz-xen. It will reboot and find the kernel and everything will work just fine even though there isn’t a specific xen kernel because of (I think) the pv drivers Red Hat decided to keep in there anyway (even though they dropped support for RHEL as a XEN host).

You will need to keep the vmlinuz-xen symbolic link up to date every time there is a new kernel installed, otherwise you will keep running on the original kernel (or the link might get broken if the old version is removed).