Git

Started using git.. this page would get more info as I learn more.

1. A very good presentation\video - here
2. Git documentation guide\book - here
3. Understanding Git, another tutorial - here

Tweet from the command line

Do this from the command line

curl -u username:password -d status="the message" http://twitter.com/statuses/update.xml

Add the following function in your .bashrc file.

# function to tweet
tweet() {
  flag=0
  if [[ -z "$1" && -z "$2" ]]; then
    echo "Usage: tweet password \"message\""
    echo "Make sure the message is within quotes"
    flag=1;
  fi
  if [ ${flag} == "0" ]; then
    echo "Sending message...."
    curl -u username:$1 -d status="$2" http://twitter.com/statuses/update.xml
  fi
}


and then do
$tweet password "The message goes here"

[Source]

more vim

Useful stuff to put inside your ~/.vimrc file

" Set tab width
set tabstop=4
set softtabstop=4
set shiftwidth=4
set smarttab
set smartindent
set expandtab
set cursorline

" Show line numbers and cursor position
set ruler
set number

" Disable default splash screen
set shortmess+=I
set guioptions-=T

" Show tabs and trailing white spaces
set list listchars=tab:-»,trail:·,extends:»

" Don't generate backup files
set nobackup

" Set default color scheme to something
colorscheme something


If you don't have it, create a folder ~/.vim/colors and put the color scheme inside.

Color schemes are available here

oprofile

oprofile is very helpful in getting a trace out of the kernel especially to know the %age usage of methods from the kernel and the application. Helps in debugging some weird problems.

First, enable oprofile in the kernel, it is good to build it part of the kernel rather than a kernel module, so make sure in the menuconfig option it is a [*] rather than [m].

You can install the oprofile client once you boot back into your file system.
sudo apt-get install oprofile oprofile-gui

Before starting your application, initialize
$ sudo opcontrol --init

The following two options can be done once in the beginning

Tell oprofile the path to your compiled and unstripped vmlinux file so that it can pick the symbols from there
$ sudo opcontrol --vmlinux=/path/to/kernel/image

Set the call stack depth
# sudo opcontrol --callgraph=#depth

Now check the status,
$ sudo opcontrol --status

Reset the earlier dump,
$ sudo opcontrol --reset

Start the profiler
$ sudo opcontrol --start

Run your application
$ ./mystupidapp

All done, stop the profiler
$ sudo opcontrol --stop

Get the dump
$ sudo opcontrol --dump

Now, get the report
$ sudo opreport -l (and various options if you want)

Clear it,
$ sudo opcontrol --reset

Deinit,
$ sudo opcontrol --deinit

and start again if you want to.

I use alias(es) in the .bashrc file. Really helps!
alias opc='sudo opcontrol'
alias opcdeinit='opc --deinit'
alias opcdump='opc --dump'
alias opcinit='opc --init'
alias opcreset='opc --reset'
alias opcstart='opc --start'
alias opcstatus='opc --status'
alias opcstop='opc --stop'
alias opr='sudo opreport -l'
alias oprcall='opr -c'


Bing !

I am not sure if the search results given by bing are going to be anything to brag about or any different (good\worst) than Google's but there are certain features in bing (the ones that I noticed, there might be a gazillion according to peeps at MS) which might find their way into Google soon, in one way or the other ;)

1. Tiny website preview\summary with the context of the search word\phrase - move to mouse to right of the result, a yellow dot appears which gives a snapshot of the result - handy and avoids opening the page to see if the result makes sense.

2. Video preview - this is the best one, while searching for videos (especially the useful ones :D ), bing plays them right in the search result panel. Isn't that nice!

3. Enhanced pages for Wikipedia results - you can click on the link to "enhanced page" and the wikipedia entry opens right inside the search panel. Do know how useful that is!

emacs - match parenthesis

One good thing I liked about vim is that the parenthesis matching is so damn easy - use %

So, in order to enable the same in emacs, add the following in your .emacs file
(global-set-key "%" 'match-paren)
    (defun match-paren (arg)
    "Go to the matching paren if on a paren; otherwise insert %."
    (interactive "p")
    (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
          ((looking-at "\\s\)") (forward-char 1) (backward-list 1))
          (t (self-insert-command (or arg 1)))))


[source]

emacs lightweight options and vim

I use emacs all of the time. However, the problem with emacs is that it is very heavy duty and usually not available on embedded targets.

Zile and mg and two light-weight options for emacs (sudo apt-get install mg zile )

Also, it is good to know how to use vim

Quick starter

Open file [Esc first] :e
Save & Exit - [Esc first] :wq
Save - [Esc first]:w
Don't save & Exit - [Esc first]:!q

Up - [Esc first] k or Up arrow
down - [Esc first] j or Down arrow
left - [Esc first] h or Left arrow
right - [Esc first] l or right arrow
start of line - [Esc first] ^
end of line - [Esc first] $
page up - cntrl+b
page down - cntrl+f
Goto line x - xG

undo - [Esc first] u
redo - [Esc First] Shift+r
delete char - [Esc First] x
delete word - [Esc First] dw
delete line - [Esc First] dd

search - [Esc first] /
next - n
prev - Shift+n

help - [Esc first]:help
or start from command line
$ vimtutor

Regular expressions and Sed

Bruce Barnett is God!

1. Regular expression tutorial, here
2. Awesome Sed tutorial, here

Weird

I was just checking the post list on this blog and for 2008 and 2009 I have not made any posts in the months of March and April. Strange!

Using gtags (global)

As a follow up to the last post, I tried emacs+gtags and it is really powerful when compared to emacs+etags.

Important things to get started.

First run gtags on the code.
$ gtags

This would create four files GPATH, GRTAGS, GSYMS, GTAGS

Open emacs and enable gtags
M-x gtags-mode RET

To enable auto completion of function names\symbols etc use,
M-x gtags-make-complete-list
NOTE: This is deprecated and not required now.

To locate a function use,
M-x gtags-find-tag function_name.
You can also use M-.

If more than one is found a stack is returned. Select one and hit RET. In order to get the stack use,
M-x gtags-pop-stack.
You can also use M-*

To find a symbol use,
M-x gtags-find-symbol m_myVar

To find anything use,
M-x gtags-find-with-grep "gtags rules"

Once you modify the code, just update the code
global -u -v

To visit the tags folder use,
M-x gtags-visit-rootdir and point it to the folder that has the TAGS!

global and gtags

I have heard a lot about GNU GLOBAL source code tag system, need to try it out.

GNU global

emacs - system wide copy and paste

Using [M]-W and [C]-Y one can copy and paste inside emacs but it only works for the emacs buffers. In order to enable system wide copy\paste (through the clipboard) with other applications set the following in the .emacs file

(setq x-select-enable-clipboard t)

OR use

META-X set-variable RET x-select-enable-clipboard RET t

Lot more here

[src]

initird

Nice (but a little old) article on initrd internals. Click here.

Bash scripting

1. A very good basic BASH scripting tutorial. Click here
2. A very advanced tutorial at TLDP. Click here