Create a bootable USB on Linux (Mint, Ububtu) pendrive to upgrade Lenovo ThinkPad W530 BIOS

Recently I had to update the bios of my laptop from a USB pendrive, because I had no CD/DVD drive around.

Cameron Seader’s post http://blog.seader.us/2013/10/lenovo-bios-update-method-for-linux-and.html came very handy, but used an obsolete tool so I updated his instructions a bit to make them work.

1. Get the machine type and model of your laptop
In order to grab this information you can either go to the BIOS or use dmidecode or hwinfo.
In my case it was ThinkPad W530 2438-2KU.

2. Download appropriate bios update iso from Lenovo’s site
I got mine: “g5uj22us.iso” from http://support.lenovo.com/en_US/downloads/detail.page?DocID=DS029170

3. Extract the boot image from the iso
To do it you can use genisoimage, which can be installed using regular:

$ sudo apt-get install genisoimage

or can be downloaded from: http://manpages.ubuntu.com/manpages/lucid/man1/genisoimage.1.html
Once you have this tool, run:

$ geteltorito g5uj22us.iso > biosupdate.img

4. Copy the boot image to the USB pendrive

$ sudo dd if=biosupdate.img of=/dev/usbthumdrive bs=512K

Reboot and boot from USB to run the Flash Utility

Cheers,
SeΓ±or QA

Configure your Logitech Performance MX Mouse buttons to work with Linux Mint

To make your extra mouse buttons work on Linux Mint (I’ve tested it with v15) follow all the steps listed in this tutorial except the step 4 πŸ™‚

Once you get to step 4, use this key mappings to make the ‘zoom’ and ‘switch between windows’ buttons work as on windows.

vi $HOME/.xbindkeysrc
...

# show all windows: Scale
"xte 'keydown Control_L' 'keydown Alt_L' 'key Down' 'keyup Control_L' 'keyup Alt_L'"
  b:10 + release

# Zooming with Logitech Performance MX mouse
# thx to: http://www.ralf-oechsner.de/opensource/page/logitech_performance_mx
# Press 'zoom' button and scroll up/down to zoom in/out
# then press the 'zoom' button again to exit from the 'zoom' mode
"xte 'keydown Control_L' &"
   b:13
"xte 'keyup Control_L' &"
   Control + b:13

I hope that you’ll like Mint even more from now on πŸ™‚

Vim – tips and tricks

Record a macro that will delete everything after matching character and repeat it N-times.
In this example we’re going to use ‘=’ as the matching character.

qaf=D⏎q

Where:
‘qa’ – to start recording and save it under ‘a’ buffer
‘f=’ – find ‘=’ character
‘D’ – Delete everything to the EOL
‘⏎’ – press ‘enter’ to go to the beginning of next line
‘q’ – to stop recording the macro

then to repeat the macro N-times, i.e. repeat it 5 times:

5@a

‘5’ – the number of times you’d like to repeat the macro
‘@a’ – play macro recorded under ‘a’ buffer

VIM macro delete everything after matching character and repeat N-times

VIM macro delete everything after matching character and repeat N-times

How to compile and install latest version of Vim with support for: X11 clipboard, ruby, python 2 or python 3

This was tested with vim 7.4.(1-398)
(Update: 2013-12-03 apparently you can’t build vim with support for both python 2 and python 3, so I had to update this tutorial a bit πŸ™‚ )
(Update: 2014-08-09 Added three commands: “hg pull”, “hg update” and “hg status” to pull the latest version of the repo)

First of all install all the dependencies required when compiling Vim with additional options:

@:~> sudo apt-get install mercurial python python-dev python3 python3-dev ruby ruby-dev libx11-dev libxt-dev libgtk2.0-dev  libncurses5  ncurses-dev

Then clone official vim repo, configure it with support for: X11 clipboard, ruby, python 2 or 3 and few other cool options πŸ™‚

@:~> hg clone https://vim.googlecode.com/hg/ vim
## if you already had this repo cloned, then update it:
@:~> hg pull
@:~> hg update
## and then check if you definitely have the latest version:
@:~> hg summary
parent: 6121:913d16b4904c
 Added tag v7-4-398 for changeset f62b2e76dd80
branch: default
commit: (clean)
update: 52 new changesets (update)
@:~> cd vim/src
##
## this will configure it with python 2
##
@:~> ./configure \
    --enable-perlinterp \
    --enable-pythoninterp \
    --enable-rubyinterp \
    --enable-cscope \
    --enable-gui=auto \
    --enable-gtk2-check \
    --enable-gnome-check \
    --with-features=huge \
    --enable-multibyte \
    --with-x \
    --with-compiledby="Senor QA <senor@qa>" \
    --with-python-config-dir=/usr/lib/python2.7/config-x86_64-linux-gnu
##
## and with python 3
##
@:~> ./configure \
    --enable-perlinterp \
    --enable-python3interp \
    --enable-rubyinterp \
    --enable-cscope \
    --enable-gui=auto \
    --enable-gtk2-check \
    --enable-gnome-check \
    --with-features=huge \
    --enable-multibyte \
    --with-x \
    --with-compiledby="Senor QA <senor@qa>" \
    --with-python3-config-dir=/usr/lib/python3.3/config-3.3m-x86_64-linux-gnu

Next step is to compile our setup:

@:~> make

Then if you want you can check if all the features were compiled properly:

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug  9 2014 15:37:52)
Included patches: 1-398
Compiled by Me <senor@qa>
Huge version with GTK2 GUI.  Features included (+) or not (-):
+acl             +farsi           +mouse_netterm   +syntax
+arabic          +file_in_path    +mouse_sgr       +tag_binary
+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static
+balloon_eval    +float           +mouse_urxvt     -tag_any_white
+browse          +folding         +mouse_xterm     -tcl
++builtin_terms  -footer          +multi_byte      +terminfo
+byte_offset     +fork()          +multi_lang      +termresponse
+cindent         +gettext         -mzscheme        +textobjects
+clientserver    -hangul_input    +netbeans_intg   +title
+clipboard       +iconv           +path_extra      +toolbar
+cmdline_compl   +insert_expand   -perl            +user_commands
+cmdline_hist    +jumplist        +persistent_undo +vertsplit
+cmdline_info    +keymap          +postscript      +virtualedit
+comments        +langmap         +printer         +visual
+conceal         +libcall         +profile         +visualextra
+cryptv          +linebreak       +python          +viminfo
+cscope          +lispindent      -python3         +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con_gui  -lua             +rightleft       +windows
+diff            +menu            +ruby            +writebackup
+digraphs        +mksession       +scrollbind      +X11
+dnd             +modify_fname    +signs           -xfontset
-ebcdic          +mouse           +smartindent     +xim
+emacs_tags      +mouseshape      -sniff           +xsmp_interact
+eval            +mouse_dec       +startuptime     +xterm_clipboard
+ex_extra        -mouse_gpm       +statusline      -xterm_save
+extra_search    -mouse_jsbterm   -sun_workshop    -xpm
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/freetype2 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/libpng12 -I/usr/include/harfbuzz     -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      
Linking: gcc   -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -L/build/buildd/ruby1.9.1-1.9.3.484/debian/lib -rdynamic -Wl,-export-dynamic  -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfontconfig -lgobject-2.0 -lglib-2.0 -lfreetype   -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl   -ldl    -L/usr/lib/python2.7/config-x86_64-linux-gnu -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions   -lruby-1.9.1 -lpthread -lrt -ldl -lcrypt -lm  -L/usr/lib

Just to make sure it works as it should, launch newly compiled ./vim, and type:

:echo has("python")

It should return 1 if it was compiled properly πŸ™‚

If you’re happy then install it πŸ™‚

@:~> sudo make install

Then locate the vim command

@:~> which vim
vim is /usr/local/bin/vim
vim is /usr/bin/vim

As you can see, there are two installed on my system.
To make newly installed version “/usr/local/bin/vim” the default one, we’ll use “update-alternatives”.

@:~> sudo update-alternatives --install "/usr/bin/vim" "vim" "/usr/local/bin/vim" 1
@:~> sudo update-alternatives --install "/usr/bin/vi" "vi" "/usr/local/bin/vim" 1

Then use “update-alternatives” to switch between installed versions πŸ™‚

@:~> sudo update-alternatives --config vim
There are 2 choices for the alternative vim (providing /usr/bin/vim).

  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /usr/bin/vim.basic   30        auto mode
  1            /usr/bin/vim.basic   30        manual mode
  2            /usr/local/bin/vim   1         manual mode

Press enter to keep the current choice[*], or type selection number: 2
@:~> 
@:~> # now let's change symbolic link for vi
@:~> 
@:~> sudo update-alternatives --config vi
There are 3 choices for the alternative vi (providing /usr/bin/vi).

  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /usr/bin/vim.basic   30        auto mode
  1            /usr/bin/vim.basic   30        manual mode
  2            /usr/bin/vim.tiny    10        manual mode
  3            /usr/local/bin/vim   1         manual mode

Press enter to keep the current choice[*], or type selection number: 3
update-alternatives: using /usr/local/bin/vim to provide /usr/bin/vi (vi) in manual mode

Last thing to do is to check where the /usr/bin/vim points at:

@:~> ll /usr/bin/vim
lrwxrwxrwx 1 root root 21 Jun  7 11:29 /usr/bin/vim -> /etc/alternatives/vim*

Then check where the /etc/alternatives/vim points at.
If everything went fine, it should be pointing at: /usr/local/bin/vim

@:~> ll /etc/alternatives/vim
lrwxrwxrwx 1 root root 18 Nov 19 12:17 /etc/alternatives/vim -> /usr/local/bin/vim*

Happy Vimming πŸ™‚
J

How to add official Chromium-browser PPA repository to Linux Mint 15 and install the latest stable build

Here’s the official Chromium-browser PPA repo: https://launchpad.net/~chromium-daily/+archive/stable

To install latest stable build follow 3 simple steps:

Step 1:
add “deb http://ppa.launchpad.net/chromium-daily/stable/ubuntu raring main” to /etc/apt/sources.list

Step 2:
add repo’s pub key so that we can avoid problems like the one below:

W: GPG error: http://ppa.launchpad.net raring Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 5A9BF3BB4E5E17B5
sudo gpg --keyserver hkp://keys.gnupg.net:80 --recv 5A9BF3BB4E5E17B5
sudo gpg --export FBEF0D696DE1C72BA5A835FE5A9BF3BB4E5E17B5 | sudo apt-key add -

btw. using hkp://keys.gnupg.net:80 will work even if you’re behind a firewall or proxy πŸ™‚

Step 3:
Update package list and install Chromium

sudo apt-get update
sudo apt-get install chromium-browser

Step 4:
Happy browsing πŸ™‚

How to build pidgin-sipe plugin with audio and video support on ubuntu/linux mint

Tested with pidgin-sipe-1.17.0

First of all install all the dependencies:

sudo apt-get install libxml2-dev libnspr4-dev libnss3-dev libgstreamer0.10-dev libnice-dev libpurple-dev libnss3-dev libglib2.0-dev 

then check where libnspr4 was installed

sudo dpkg -L libnspr4

Then finally configure nspr paths accordingly, compile and install it:

./configure --prefix=/usr  --with-vv --with-nss-includes=/usr/include/nss --with-nss-libs=/usr/lib/x86_64-linux-gnu --with-nspr-includes=/usr/include/nspr --with-nspr-libs=/usr/lib/x86_64-linux-gnu
make
sudo make install

Hope it helps πŸ™‚
If everything works fine then your Lync contact list should look like this:

pidgin with sipe-1.17.0

pidgin with sipe-1.17.0

how to change the default keyserver used by the command: “sudo add-apt-repository …”

Tested on linux mint 15.

If you encountered problems with connecting to keyserver.ubuntu.com when adding a new ppa to your list of repositories using add-apt-repository, i.e.: “sudo add-apt-repository ppa:jon-severinsson/ffmpeg”
Here’s an example failure:

....
Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --secret-keyring /tmp/tmp.UsuIhHAgLO --trustdb-name /etc/apt//trustdb.gpg --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyserver keyserver.ubuntu.com --recv-keys CFCA9579
gpg: requesting key CFCA9579 from hkp server keyserver.ubuntu.com
gpg: keyserver timed out
gpg: keyserver receive failed: keyserver error

Then what you have to do is to change the default port used for obtaining pgp keys from 11371 to 80.
To do this edit:

sudo vi /usr/lib/linuxmint/mintSources/mintSources.py

and replace all the occurrences of “keyserver.ubuntu.com” with

hkp://keyserver.ubuntu.com:80

after that,……
simply enjoy the rest of your life!

A quick way to get a MD5 hash of a string in Linux CLI

the simples way to get a MD5 hash of a string that I found is:

md5sum<<<putYourWordHere

this should print:

074d876a127bc3344f9c3c72cefac56d  -

Unfortunately this will print the hash followed by trailing two spaces and a dash.
To get rid of them, simply pipe the output to the cut command:

md5sum<<<putYourWordHere | cut -f1 -d' '

this will print the hash without that trailing garbage

074d876a127bc3344f9c3c72cefac56d

Finally, if you'd like to convert it into a bash command, the add this function to you .bashrc file

# will calculate md5sum from a input string
# example 1: md5 "this is a long string test_string"
# example 2: md5 singleWordExample
function md5() { md5sum<<<$1 | cut -f1 -d' '; }

How to install Groovy on Ubuntu, Linux Mint and other similar distros

A short tutorial how to install Groovy on Ubuntu, Linux Mint and other similar distros.

Download lastest Groovy build @ http://groovy.codehaus.org/Download and upack it

First create a groovy folder in /usr/lib

sudo mkdir /usr/lib/groovy

Then move the unpacked groovy folder to it

sudo mv groovy-1.8.6/ /usr/lib/groovy/

Our next step is to use update-alternatives to add a group of alternatives to the system

sudo update-alternatives --install "/usr/bin/groovy" "groovy" "/usr/lib/groovy/groovy-1.8.6/bin/groovy" 1
sudo update-alternatives --install "/usr/bin/groovyc" "groovyc" "/usr/lib/groovy/groovy-1.8.6/bin/groovyc" 1
sudo update-alternatives --install "/usr/bin/groovyConsole" "groovyConsole" "/usr/lib/groovy/groovy-1.8.6/bin/groovyConsole" 1
sudo update-alternatives --install "/usr/bin/groovysh" "groovysh" "/usr/lib/groovy/groovy-1.8.6/bin/groovysh" 1
sudo update-alternatives --install "/usr/bin/java2groovy" "java2groovy" "/usr/lib/groovy/groovy-1.8.6/bin/java2groovy" 1

Then to check if everything is fine:

sudo update-alternatives --config groovy

and finally

groovy -v

should give you:

Groovy Version: 1.8.6 JVM: 1.6.0_27 Vendor: Sun Microsystems Inc. OS: Linux

Lastly try groovyConsole for evaluating your Groovy script:

groovyConsole

ps. I used this tutorial how to install oracle java 7 as a basis for this one πŸ™‚

Ta-dah! you’re done πŸ™‚