Skip to content

Recent Articles

17
Apr

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 https://github.com/y3sh/Intellij-Colors-Sublime-Monokai
  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.

8
Jul

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.

2
Jul

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

 

15
Jun

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.

7
Jun

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.

16
May

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 https://bugs.launchpad.net/ubuntu/+source/dbus/+bug/811441/comments/24 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.”

28
Apr

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.

31
Mar

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
cd ${JAVA_BIN_DIR}
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}
done

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.

17
Dec

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).

7
Oct

Trusting All Certificates In Jython

I had a little application I was writing to check some information on a VMware vSphere server. I was sending SSL HTTP requests to the server to get data. Everything was working fine under python. I had one function that needs to use Jython (which is fine because I am running everything under Jython most of the time anyway, Python is just faster to start up for testing). However, when I ran it in Jython I was getting socket.sslerror SSL handshake exceptions. This is known behavior in Jython because by default Java will automatically check the validity of certificates while Python just disregards the SSL certificates.

There are a couple of ways to get around this and they are documented here http://wiki.python.org/jython/NewSocketModule#SSLSupport. However, I didn’t like any of those approaches.

The first option requires messing with your certificate store in the JVM which means all Java processes doing anything will have your certificate added. This may or may not be what you want, but if you go to another machine or use a different JVM you will lose the ability to connect to your SSL host again.

Option 2, creating your own Security Provider looked a little more appealing because I don’t have to worry about importing each certificate and could enable this at runtime. However, it has the drawback of having to be compiled outside of Jython, and has to be put on the class path. Again, this makes it a little less portable (but not too bad). It also has the affect of trusting all certificates for every single SSL connection made, which is good because it matches up to what Python does but what if you want to only trust invalid certificates in certain parts of your code?

I started digging and came up with a way that would let me trust all certificates, be written completely in Jython, and have the ability to dynamically switch between trusting all certificates or not.

# Check if running in Jython
if 'java' in sys.platform:
    from javax.net.ssl import TrustManager, X509TrustManager
    from jarray import array
    from javax.net.ssl import SSLContext
    class TrustAllX509TrustManager(X509TrustManager):
        '''Define a custom TrustManager which will blindly accept all certificates'''
 
            def checkClientTrusted(self, chain, auth):
                pass
 
            def checkServerTrusted(self, chain, auth):
                pass
 
            def getAcceptedIssuers(self):
                return None
    # Create a static reference to an SSLContext which will use
    # our custom TrustManager
    trust_managers = array([TrustAllX509TrustManager()], TrustManager)
    TRUST_ALL_CONTEXT = SSLContext.getInstance("SSL")
    TRUST_ALL_CONTEXT.init(None, trust_managers, None)
    # Keep a static reference to the JVM's default SSLContext for restoring
    # at a later time
    DEFAULT_CONTEXT = SSLContext.getDefault()
 
def trust_all_certificates(f):
    '''Decorator function that will make it so the context of the decorated method
    will run with our TrustManager that accepts all certificates'''
    def wrapped(*args, **kwargs):
        # Only do this if running under Jython
        if 'java' in sys.platform:
            from javax.net.ssl import SSLContext
            SSLContext.setDefault(TRUST_ALL_CONTEXT)
            try:
                res = f(*args, **kwargs)
                return res
            finally:
                SSLContext.setDefault(DEFAULT_CONTEXT)
        else:
            return f(*args, **kwargs)
    return wrapped

Thats it. Now I can do things like:

@trust_all_certificates
def connect_to_untrusted_host(host):
        conn = httplib.HTTPSConnection(host)
        conn.request('GET', '/index.html')
        response = conn.getresponse()

And the connection will succeed. If I have another method that is not decorated then it will automatically verify the certificates validity.

Note that this decorator is not thread safe. Setting the SSLContext default is a global operation, so if another thread is running it could reset the SSLContext to the default before another method tries to make an SSL connection.

You can also use this without the decorator function. Just use the code prior to the decorator and set the SSLContext default wherever you need to.

If you happen to also need to verify the hostname of a certificate, which is the case if you use an HttpsURLConnection, then you will also need to create a HostnameVerifier. You can do this as follows:

 

from javax.net.ssl import HostnameVerifier, HttpsURLConnection
class AllHostsVerifier(HostnameVerifier):
    def verify(self, urlHostname, session):
        return True
HttpsURLConnection.setDefaultHostnameVerifier(AllHostsVerifier())

 

Hope that helps. It’s nice to have a pure Jython implementation of this and have it be transportable.