Thursday, December 12, 2013

Vim indentation tips


Some Vim indentation tips to collect here mainly as a reminder. Note that the amount of spaces used for indentation is mainly governed by the variable shiftwidth.


  • Moving around (aka, prelude to action): 
    • H to top of screen, L to bottom, M to middle. Then use nG to go to line n, G alone to bottom of file, gg to top of file.
    • Go visual pressing v then move around to selct text. Once happy, you can copy (yy) or delete (dd) the selected text. 
  • Indent text (visual mode):
    • in command mode, press v then move cursor around (text will be highlighted), then press > to indent the highlighted text.
  • Indent text (markers):
    • position yourself then place a marker with ma, then move down to your block end and type >'a (a can be replaced with another valid character)
  • Indent text (fixed):
    • to indent current line type >>
    • to de-indent current line type <<
    • to indent 10 lines from the current one use 10>>
    • ... you get the gist ...
    • to indent lines from 10 to 20 type :10,20>
Some variables you can add to your .vimrc:

set shiftwidth=5    #Indent by 5 spaces when using >>, <<, etc.
set softtabstop=5   #Indent by 5 spaces when pressing
set autoindent      "Keep indentation from previous line

All of this is tested/verified for vim, not sure about vi.



Wednesday, September 11, 2013

D-Bus library appears to be incorrectly set up

Recently I add to install firefox on top of a bare bones SL6 VM (e.g. installed with the minimal package set) and upon launching the browser I got this error:

$ firefox 
process 12606: D-Bus library appears to be incorrectly set up; failed to read machine uuid: Failed to open "/var/lib/dbus/machine-id": No such file or directory
See the manual page for dbus-uuidgen to correct this issue.
  D-Bus not built with -rdynamic so unable to print a backtrace
Aborted

turns out that the culprit is dbus which needs the service messagebus running but it has not been started by default, so issuing this makes the error go away:

# /etc/init.d/messagebus start

now Firefox will start as expectd.

Wednesday, January 2, 2013

Mobile browser user agents

Had a quick go at seeing what user agent is reported from different mobile devices and browser combinations:

Android (Gingerbread) stock browser:


134.171.xxx.xxx - - [02/Jan/2013:17:22:53 +0100] "GET /wdb/html/status_btn.gif HTTP/1.1" 200 1588 "http://archive.eso.org/wdb/wdb/eso/fors2/form" "Mozilla/5.0 (Linux; U; Android 2.3.3; en-us; GT-I9100 Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"

Android Opera Mobile:

134.171.xxx.xxx - - [02/Jan/2013:17:21:38 +0100] "GET /wdb/wdb/eso/fors2/form HTTP/1.1" 200 28130 "-" "Opera/9.80 (X11; Linux zbov) Presto/2.11.355 Version/12.10"

Android Firefox:

134.171.xxx.xxx - - [02/Jan/2013:17:22:17 +0100] "GET /wdb/wdb/eso/fors2/form HTTP/1.1" 200 28130 "http://archive.eso.org/cms/eso-data/instrument-specific-query-forms.html" "Mozilla/5.0 (Android; Mobile; rv:17.0) Gecko/17.0 Firefox/17.0"

and for comparison, this is the stock iPhone4 browser:

134.171.xxx.xxx - - [02/Jan/2013:17:25:15 +0100] "GET /wdb/wdb/eso/fors2/form HTTP/1.1" 200 28130 "http://archive.eso.org/cms/eso-data/instrument-specific-query-forms.html" "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0_1 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Mobile/10A523"