Wednesday, 26 February 2014

Rmagick failing to build on Arch due to HDRI Imagemagick

One of my personal Rails projects uses uses the rmagick gem.  On Arch Linux the imagemagick package from the Extra repository is built with the --enable-hdri option.  This will cause the gem to fail when installing.



Not to worry.  I found this bug and this patch.  But it was AUR to the rescue with the package imagemagick-no-hdri.

So remove the initial package with:

    pacman -Rs imagemagick

Next install the other package with your favourite method - I use aurget (you may need --deps).

    aurget-S imagemagick-no-hdri

Now install your rmagick gem.



Success!

Monday, 17 February 2014

Loading 'loop' Device in OpenSUSE

Okay, I'm still a noob with OpenSUSE 13.1 - I've kept my eye on it for years but never took the plunge until recently.  One of the applications I have on every machine I own is Truecrypt.  Installed it direct from the site then tried to mount a volume when I got this error.


Problem is explained right there in the error message.  And its an easy one to fix.  In fact, the loop device is used for a lot of common things I expect to be doing, so I will just ensure its enabled in the kernel.

A quick check for how OpenSUSE does it (told you I was a noob), then loaded the loop kernel module with:

    sudo /sbin/modprobe loop

You can test if this loaded by:

    sudo /sbin/lsmod | grep loop

The status of the loop module is shown, if loaded - and if its not loaded, then nothing will be returned.

Lastely, I wanted to ensure loop gets loaded every time I boot the machine, so I added this:

    sudo echo loop > /etc/modules-load.d/loop.conf

Back to Truecrypt, voila!

Saturday, 15 February 2014

Updating Arch - My Way

I like to script a lot of the repetitive jobs I do (and what geek doesn't?).  One of those jobs is the updating of Arch Linux packages.  Check out this simplistic bash script.



I use aurget, as it has similar syntax with pacman.  And I'm using Reflector to grab the fastest mirrors.  Script will run without these packages installed.

Tuesday, 11 February 2014

My Favourite Git Alias

I use this git alias every day, a number a times a day.  Unfortunately I don't know where I originally found it, as I did not create it, I did update it a little to my needs.

In your projects .gitconfig or your home folders ~/.gitconfig add this (just add the lg line to the [alias] section to an existing file) :


I don't have a project, that includes a lot of branching, that I am able to show you - I do have a flat project of my own that gives you an idea of what the output looks like.


If you have some great git command line tricks, please toss them my way - I live in a version control world!

Doesn't that look better than git log:

Saturday, 8 February 2014

Changing How sudo Works in openSUSE

The default way a user in openSUSE 13.1 executes sudo to run a restricted file is that they need the root user password rather, as many other Linux distributions, than their own.  By design, this is a better way to manage root access - but  if you want sudo to require your password rather than root's then keep reading.

Personally, I like a mixture of both on my personal machines.  I sometimes su, using root's password and at other times I use sudo with my own password.

To do this, the first thing I do when I install openSUSE is to give root a different password than my own.  Do this by deselecting the "Use this password for system administrator".


If you already have openSUSE installed, then simply su to root and then passwd to set a new password.

Now the fun stuff.

As the root user execute visudo, you need to comment out the last two lines of the below:



In the same file, you need to enable the wheel group by uncommenting the last row from below:


Make sure you save when you quit visudo.

One last step, as root still, add the privileged user to the wheel group ala:
    useradd -G wheel jeff
All done. You need log out and back in as the user, sudo will now act as described above.

Friday, 7 February 2014

Updated Your Bash Shell in OSX

Are you a Bash shell user on OSX? (by default you are!)  Well, did you realize that Bash is at version 3.2.51 on Mavericks, 10.9.1?   I hit a wall when I realized some of my dotfiles were not going to run as expected with this older version.

No worries - since I use the fantastic Homebrew package manager for OSX, installing Bash 4.2.45 was a simple:
    brew install bash
Thats not the end of the story though.  Now you have to change your login shell on OSX.

First step after installing is to edit /etc/shells, and add /usr/local/bin/bash to the top of the list:
    sudo vi /etc/shells
Being a nerd, you know you can just to change your shell:
    chsh -s /usr/local/bin/bash
Or you can go to System Preferences, then Ctrl-Click on your Users & Groups user profile (ensuring screen is unlocked):


And finally, after selecting Advanced Options, just change the shell to /usr/local/bin/bash:


If you want to be sure it worked, just do this in a new terminal:

    echo $SHELL



Wednesday, 5 February 2014

OS Detection in Your Vim Configuration

If you use your vim configuration across multiple machines, and even multiple operating systems (OS), then you may need to have separate configuration based on that OS.

Using has(), do something like this in your ~/.gvimrc:



In fact, there is a lot more you can set up conditionals for.  To discover all the options use the following in vim:

    :help feature-list

Monday, 3 February 2014

Easy Bash Colorization

I like things simple - if they are hard, I like to make them simple.  Take my bash prompt (PS1) I want it to have colour, be easy to change (and mess around with), and well as show me if I'm on a remote machine (as I will tend to do a few dozen times a day).  I also put it into its own file, which I call .bash_prompt and to be called from .bashrc or .bash_profile.

So here is my .bash_prompt file:



Edit to your personal preference then run:

    source ~/.bash_prompt

Sunday, 2 February 2014

Installing Rmagick Gem on Arch Linux using ABS

Installing my Rails project to a newly installed Arch Linux laptop - I ran bundle install and got the following error:



I sync'd ABS and then copied the /var/abs/extra/imagemagick/ folder to a working folder.

Now edit PKGBULD, removing the --enable-hdri option so the .configure section looks like this:



Run makepkg  in the working folder and then install the resultant package with pacman -U.

Finally, back in my Rails project folder, I ran bundle install (or I could have run gem install rmagick) once again and the Rmagick gem installs!