Friday, 5 December 2014

Installing Erlang on Ubuntu & Emacs

This was quite simple.

sudo dpkg -i erlang-solutions_1.0_all.deb

sudo apt-get update
sudo apt-get install erlang erlang-doc erlang-manpages

The page says erlang-mode also needs to be installed separately but it seemed to be installed already (or it was included in the erlang package).

After this all I needed to do in Emacs was to add this to .emacs:
(setq load-path (cons "/usr/lib/erlang/lib/tools-2.7/emacs"      load-path)) 
(setq erlang-root-dir "/usr/lib/erlang") 
(setq exec-path (cons "/usr/lib/erlang/" exec-path)) 
(require 'erlang-start)
Now I need to figure out how to tell flycheck of all the directories it needs & set up TAGS.

Friday, 7 November 2014

Git prompt

A very cool and useful way to avoid issues with working on the wrong git branch is to use the script. I sometimes manage to do this mistake. I need to check something which means changing the branch, I'm distracted and when I get back to work I forget to change the branch back. This can get messy. But with current branch is always shown in the prompt! I read about this from the Git book at which also mentions git-completion.bash. I incorporated that into my .bashrc, too, but I feel that's a lot less useful than the prompt.

I changed the instructions a bit and made the prompt like this:
 export PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(__git_ps1 " (%s)")\$ '
This will add my username and machine name in the prompt as well (I always use to have them).

Saturday, 27 September 2014

Ubuntu stops at Grub menu

I had this annoying issue with my Ubuntu server. Every time it rebooted, quite often because of a power failure, it wouldn't boot properly. I needed to go the storage room where I have it and connect a laptop with a serial cable. Well, I got an UPS to at least stop this from happening inadvertently but I decided to fix the issue once and for all when I need to reboot it for other reasons. And it turns out that since 12.04 LTS there has been a very simple solution. Just adding the following to /etc/default/grub fixes this issue:

The problem is that if the system goes down without proper shutdown, default behaviour is to stop in the Grub menu. This is pretty ridiculous for servers.

As it happens I managed to buy the only UPS (from APC) without remote access, so I can't set the system to shutdown in case of power failure. But the UPS should be able to keep the system running for at least 30 minutes, easily, and our power failures are not that long. Think there has been one that long once and that was because our mains was cut by some workers.

Thursday, 18 September 2014

Emacs evil mode

I decided to have a look at Emacs evil mode (the Vi mode for Emacs). Vim is not really suitable as an IDE. It's an editor and anything else tends to be a bit of a hack. Debugger is one such issue, it's not very convenient to use gdb inside Vim. As an added bonus I can use Lisp instead of Vimscript to write scripts.

But I like Vim's editing better than Emacs's endless control-meta-this-and-that approach. It's faster and more convenient. I might try Emacs without Evil mode at some point, I'm a pragmatist after all but at least this way I don't have to learn the entire Emacs editing thingy just to get started. I'm familiar with M-x, C-x C-f, C-x C-f and the like which should suffice for now.

Installing was almost like a breeze. Had I figured out Ubuntu 12.04 uses emacs23 instead of emacs24 which all the help I can google points to I would have had an easier time. But here's how I got started:

sudo add-apt-repository ppa:cassou/emacssudo apt-get updatesudo apt-get install emacs24git clone ~/.emacs.d/undo-treegit clone git:// ~/.emacs.d/evil

Then I added the following to .emacs:
(add-to-list 'load-path "~/.emacs.d/evil")  (require 'evil)  (evil-mode 1)
(load-theme 'wombat)

Last line loads the wombat colour scheme. I use wombat256 in Vim.

Now I just need to figure out how to get the same functionality as my favourite Vim plugins have. For instance, CtrlP. Someone suggested ido mode, but I can't seem to get it to do recursive search. In CtrlP you don't have to know where a file is to find it.

Thursday, 3 July 2014

Headphones in Ubuntu

I bought a set of Beyerdynamic DT660's (got them cheap) to use at work. But when I plugged them into the work machine (runs Ubuntu 12.02) sound quality was horrible. Bass was non-existent ans high frequencies intolerable. In other words it was impossible to listen to music. I first tried an equalizer (qpaq) and while it did improve the sound a bit it was still not good enough.

I just got a Behringer U-Control UCA202 USB-DAC with headphone amp and boy is this a big improvment! At 29€ a no-brainer. Installation was also totally painless. This would suggest the issue is with the Intel HDA driver. So if you hate the sound that you get from analog output from your Linux box, get one of these (or any other USB-DAC with headphone amp). You won't regret it.

Monday, 9 June 2014

Unsupported AMD hardware watermark in Ubuntu

Got this when I installed binary drivers in my new work computer. Then I upgraded packages and it reappeared. The way to fix this is to give the command:
sudo apt-get install fglrx-updates
After this the issue should be sorted.

Tuesday, 13 May 2014

Ubuntu: setting up a new box

I need to swap my work computer and being a lazyass programmer I decided to check out how to do this with as little hassle as possible. Here's what I came up with. This assumes basic Ubuntu installation is done on the new comp (and commands are run as sudo).
1. Get installed packages from both computers:
dpkg --get-selections > /safe/location/installed-old
dpkg --get-selection > /safe/location/installed-new
2. Save metadata from old computer:
apt-mark showauto > /safe/location/pkgs_auto.lst
apt-mark showmanual > /safe/location/pkgs_manual.lst
3. Get list of packages to install:
grep -vFf installed-new installed-old > missing 
You can go through that list manually to remove any that you don't want installed anymore.

4.  On the new box, install packages:
cat missing | cut -f 1 | tr '\n' ' ' | sudo xargs apt-get -y --force-yes install
5. Restore metadata: 
sudo apt-mark auto $(cat /safe/location/pkgs_auto.lst) 
sudo apt-mark manual $(cat /safe/location/pkgs_manual.lst)
This way system can still keep track of which packages were manually and which were automatically installed. This means that system can automatically remove packages no longer needed.

You have to add the missing apt repositories before step 4.