Fix [RubyODBC]Cannot allocate SQLHENV when connecting to MSSQL 2005 with Ruby 1.8.7. on Ubuntu 10.10

I followed this nice guide Connecting to MSSQL with Ruby on Ubuntu - lambie.org until I ran in the following errors:

irb(main):001:0> require "dbi"; dbh = DBI.connect('dbi:ODBC:MyLegacyServer', 'my_name', 'my_password')

DBI::DatabaseError: INTERN (0) [RubyODBC]Cannot allocate SQLHENV
  from /usr/lib/ruby/1.8/dbd/odbc/driver.rb:36:in `connect'
  from /usr/lib/ruby/1.8/dbi/handles/driver.rb:33:in `connect'
  from /usr/lib/ruby...

How to (possibly) fix Google Calendar in Thunderbird (Lightning) on Ubuntu

Google Calendar integration into Thunderbird suddenly did not work any more for me. Thunderbird kept asking me for my password to access calendars, but did not show them when given the correct credentials. Instead, calendars in the list got the famous "yellow triangle".

I got it working again doing the following.

  1. Remove the Ubuntu packages the "Lightning" and "Google Calendar Provider" Thunderbird addons:
    ^
    sudo apt-get remove xul-ext-gdata-provider xul-ext-lightning

  2. Restart Thunderbird

  3. Install the addons using Thu...

Where to find .desktop files on Ubuntu

.desktop files define launchers for applications installed on your machine. They specify the command that will be executed when launched, icons, titles, etc. There are two directories in which these files are stored:

# basic installation
/usr/share/applications

# installed via snap
/var/lib/snapd/desktop/applications/

New Firefox and gem versions for our Selenium testing environment (Ubuntu 14.04+)

Firefox 5.0.1, which we were using for most Rails 2.3 projects, does not run on Ubuntu 14.04 any more. Here is how to update affected projects.

  1. Update (or create) .firefox-version with the content: 24.0
    If you haven't installed Firefox 24 yet, the next time you run tests with Geordi, it will tell you how to install it.

  2. On a Rails 2 project:

Setting up Ubuntu Server as Virtual Machine in VMware

Install Ubuntu Server

  • Download an image from this site
  • Select File > New… to and follow the instructions, choose the .iso file you downloaded as image file
  • Deselect "Simple installation" – you want to configure your system yourself
  • Start the new virtual machine and follow the instructions

Install VMware Tools

  • Choose Virtual Machine > Install VMware Tools from the VMware menu, then:

^
# install required packages
sudo apt-get install build-essential psmisc

# m...

Ubuntu: Fix missing sound after a version upgrade

If you can now longer hear or record sounds after upgrading Ubuntu, you probably need to re-tell Ubuntu which devices to use for playback/recording.

Fix sound output

  • Open the PulseAudio Volume Control (pavucontrol). If you don't have that application, install it with sudo apt-get install pavucontrol.
  • Start playback of an MP3 so you can see when changes take effect.
  • Under "Output devices" use the "Mute" buttons to figure our which output device is the correct one. When you found it, also set it as the fallback dev...

Browse Amazon S3 buckets with Ubuntu Linux

There are some frontends available, but they all suck, are no longer maintained or are hard to install.

As a surprisingly comfortable alternative I have found a command line tool s3cmd:

sudo apt-get install s3cmd

When you run s3cmd the first time it will ask you for your access key ID and secret access key. This information is cached somewhere so you only need to write them once. To reconfigure later, call s3cmd --configure.

Once you're done setting up, s3cmd gives you shell-like commands like s3cmd ls or `s3cmd del som...

Ubuntu: Restart sound services

Sometimes sound breaks for me and speaker output is completely broken. This helped:

pulseaudio -k && sudo alsa force-reload

Upgrade to LibreOffice 5.x on Ubuntu

Getting rid of your old LibreOffice

Remove your old LibreOffice:

sudo apt-get remove libreoffice*

You probably also want to get rid of the dead PPAs you might have installed for LibreOffice 4.x:

  • Open *Ubuntu Software Center
  • Go to Edit / Software Source ... / Other Software
  • Find and uncheck lines like http://ppa.launchpad.net/libreoffice/libreoffice-4-3/ubuntu. Note that you will probably have at least two lines pertaining to libreoffice.

Installing a new LibreOffice
-------------...

Sudo a gem executable does not work on Ubuntu

Today I needed to execute a ruby gem executable with sudo. But, surprisingly, bash would tell me command not found for the gem that ran lovely without sudo.

Gem bins are installed to /var/lib/gems/1.8/bin, which is not in sudo’s PATH. Unfortunately, you can’t change the path, since sudo for Ubuntu is compiled with the --with-secure-path option.

#Solution A: symlink the gems (if you need only some few gems)

  • for each gem you need for sudo, run `ln -s /var/lib/gems/1.8/bin/gem_for_sudo /usr/local/bin/gem_for_sudo

#Soluti...

Ubuntu: Share internet connections with other computers

You can configure a Ubuntu system as a gateway in order to share it's internet connection (maybe via WLAN or tethering) with other computers on the network.

On the gateway

  • Enable ip traffic forwarding:
    • Open /etc/sysctl.conf

    • Uncomment the line

      net.ipv4.ip_forward=1
      
    • Reload using sudo sysctl -p /etc/sysctl.conf

  • Reconfigure ip_tables to allow NAT:
    • Download the attached file
    • Replace online_device with the name of the network device that provides the internet connection
      ...

Installing Adobe Reader on Ubuntu

Adobe no longer supports their PDF reader on Linux and the official page does not offer it for download. \
However, some files may not display properly on Ubuntu's default PDF reader Evince or PDF forms may not work as expected. Hence, you may still need to use it.

Here is how to install the Adobe Reader (acroread) if you need to:

  1. Download the .deb archive from the Adobe servers (yes, it's still there):

    cd /tmp && wget http://ardownload.adobe.com/pub/adobe/reader/unix/9.x/9.5.5/enu/AdbeRdr9.5.5-1_i386linux_enu.deb
    
  2. I...

Ubuntu MATE: Shortcut launcher for a web application

For some years Google Chrome has allowed you to add desktop icon for any web page by going to Tools / Add to desktop. Unfortunately this doesn't work reliably on Ubuntu MATE with recent Chromes: The icons could not be moved away from the desktop, or they would open the application as a new tab (instead of as a new window).

I found it to be easier to add a custom application launcher to the MATE panel.

In the Command field, enter this:

google-chrome --app="https://www.google.com/calendar"

This will open Google Calendar in a...

How to install older versions of REE with rbenv on Ubuntu 12.04

Rbenv won't compile REE 2011.03 properly on Ubuntu 12.04, failing with an error in tcmalloc.cc.

If you want to keep tcmalloc functionality, you can do it like this:

  1. Open ~/.rbenv/plugins/ruby-build/share/ruby-build/ree-1.8.7-2011.03
  2. Replace the file's contents with those from fgrehm's gist
  3. rbenv install again

You could also try CONFIGURE_OPTS="--no-tcmalloc" rbenv install, but that would disable tcmalloc. Doing that, you might still encounter issues with ossl_ssl.c -- which is ...

Bower complains about missing NodeJS on Ubuntu

If bower complains about a missing node binary, do not install Ubuntu's node package.

Instead, you need to create a symlink that points to the binary one of the nodejs package:

sudo ln -s /usr/bin/nodejs /usr/bin/node

You probably already installed NodeJS. In case you did not:

sudo apt-get install nodejs

If you already installed the node Ubuntu package, bower will just do nothing (i.e. not show any input, or respond to any switches) and you need to uninstall that package first.

Ubuntu: Open a new terminal window with a keyboard shortcut

To open a terminal quickly navigate to System → Preferences → Keyboard Shortcuts. There, click the "Run a terminal" row (It should be in the "Desktop" section) and press the keyboard shortcut you like.

If you cannot find such an entry you may need to add it yourself -- the command for Ubuntu's default terminal is gnome-terminal.

Be aware that many programs use shortcuts of their own and you would not want to clash with those (like Ctrl+T). Something like Meta+T is something usually not ta...

One cause for "iptables: No chain/target/match by that name" on Ubuntu

I couldn't successfully execute a simple iptables command and got this error on an Ubuntu server:

# /sbin/iptables -I INPUT ....
iptables: No chain/target/match by that name

The cause was that two modules weren't loaded: xt_multiport and xt_comment. Normally Ubuntu loads them automatically, but not this time due to another problem.

Setup (and secure) an SSH server on Ubuntu

Install OpenSSH Server:

sudo apt-get install openssh-server

To check if the server is running you should get no error when you restart it:

sudo /etc/init.d/ssh restart

Now your ssh server is ready to use.

To add additional security edit your sshd_config (gksudo gedit /etc/ssh/sshd_config):

# Deny root login:
PermitRootLogin no

# To whitelist users:
AllowUsers USERNAME1 USERNAME2

# To disable interactive authentication (without SSH key)
PasswordAuthentication no

Don't forget to restart after editin...

How to find out your Ubuntu's release codename or version

So you want to know if you are on natty, precise, quantal, or something else? Check /etc/lsb-release.

$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04.2 LTS"

Or, use the lsb_release command:

$ lsb_release -cd
Description:	Ubuntu 14.04.1 LTS
Codename:	trusty

Downgrade Firefox 6 to Firefox 5 on Ubuntu

Note that if you plan to downgrade Firefox because your Selenium tests broke after a Firefox upgrade, there is a better way that doesn't involve downgrading. Mozilla has stated that they will no longer provide security patches for any but the most recent versions of Firefox. So running an old Firefox should not be a long-term solution for anything.

If you still want to downgrade your Firefox for other reasons, here is how I downgra...

How to look at hidden X screens

When you have a program running in a hidden X screen (like with Xvfb for Selenium tests) you may want to look at that hidden screen occasionally.

First, find out what X displays are currently active:

netstat -nlp | grep X11

This should give you some results like these:

unix  2      [ ACC ]     STREAM     LISTENING     8029600  4086/Xvfb           /tmp/.X11-unix/X99
unix  2      [ ACC ]     STREAM     LISTENING     8616     -     ...

Ubuntu: Reload Gnome panel while keeping user session

Sometimes you need to restart the Gnome panel, e.g. when you installed a new Gnome panel widget but the widget list was cached before.

You often don't want to do sign out and back in for this.
Instead, just run:

killall gnome-panel

This will terminate all gnome-panel processes. On my machine (Ubuntu 11.04) the panel then restarted itself after a moment.

If the panel does not automatically come back, press Alt+F2 to bring up the Gnome "run" box and start gnome-panel from there.

Ubuntu: Make Ctrl-Space work in RubyMine, Emacs, or other tools

I was annoyed that RubyMine's autocompletion did not work via Ctrl+Space for me. In fact, it did not work in any application.

Turns out that keyboard combination was hijacked by Ubuntu as it's the default for switching input languages (i.e. keyboard layouts). If you use only 1 language/layout, you will not notice except for the key not working.

To fix it, do the following:

  1. Run ibus-setup (e.g. from a terminal). This will open a GUI dialog.
  2. In the 1st tab you should see "Next Input Method" followed by "<Control>space".
  3. Click t...

How to fix: Microphone recording levels are too quiet (or get lowered automatically)

If others on a call (Skype, SIP, ...) can not hear you loud enough, your volume levels are probably too low. Also, Skype may be changing your mixer levels.

Set a proper recording volume

  1. Open your mixer software (run pavucontrol).
  2. Switch to input devices.
  3. If you have more than one recording device, find the correct one.
  4. Make a test call to a colleague that can tell you if it's too loud or too quiet.
  5. Drag the volume slider for your input device to an adequate level -- for me, 75% (-7.46dB) work fine. 100% is usually way to...