January 2008 Archives
Developmental Milestones of Children as per AAP:
I was at WalMart a week back to change my Car battery. While they were having at it, I had nothing else to do except checking out the aisles...
...and of course, getting hit by the folks of Quixtar and its variants. "Sir, are you from Chennai?", "I have met you somewhere", "Do you know where I can find flash memory", "Is this thing
The only thing that I can think of is, do these guys have a life? Think about it... on a nice weekend, instead of spending time with family, or watching a good movie, or changing your car battery (;-)), you are hitting on strangers in Walmart/Sears trying to scam them up!! I can understand if you are homeless or broke, but most of these guys are with a decent job, earning a decent salary. Think guys think!! Will you ever stop making a fool of yourselves?
A nice article on what is Multi Level Marketing wand why it's doomed is HERE. Please read this, and get a life!!
This is a vim recipe for creating a function header automatically on a keystroke. For example, if you have a c function:
int foo (char *bar1, int bar2, struct uber bar3)
{
...
}
Running this with the cursor at or above the function will generate this header for you:
/*******************************************************************************
* FUNCTION: foo
*
* ARGUMENTS: char *bar1, int bar2, struct uber bar3
*
* DESCRIPTION:
*
*******************************************************************************/
Actual recipe:
function! FuncHdr()
"Save current position
let line_no = line(".")
"Find the function
normal ^
"execute "norm! /^\\(\\w\\+[ :&*]\\{1,2}\\)\\+\\w\\+\\s*(\<CR>"
execute "norm! /^[^(]*(.*\<CR>"
execute "norm! /(\<CR>b"
"echo getline(".")let fun_name = expand("<cword>")
"echo fun_name
let line_buff = ""
while match(line_buff,")") == -1
let line_buff = line_buff . getline(".")
normal! j
endwhile
"echo line_buff
"remove before bracket
let args_list = substitute(line_buff, ".*(","","")
"remove after bracket
let args_list = substitute(args_list, ").*","","")
"remove whitespaces
let args_list = substitute(args_list, '\s\+'," ","g")
"remove comments
let args_list = substitute(args_list, '\/\*.*\*\/',"","g")
"echo args_list
execute "normal! :".line_no."\<CR>"
execute "normal! A\<CR>\/\<Esc>"
execute "normal! 79A*\<Esc>"
execute "normal! A\<CR> FUNCTION: ".fun_name."\<Esc>"
execute "normal! A\<CR>\<CR>ARGUMENTS: ".args_list."\<Esc>"
execute "normal! A\<CR>\<CR>DESCRIPTION: \<Esc>"
execute "normal! A\<CR>\<CR>\/\<Esc>h78i\*\<Esc>kkA"endfunction
Lately, I was working on a new project, and had to create many .c and .h files. All the header files needed the #ifndef/#define/#endif boilerplating.
Being a lazy typist, following vim macro helped in generating the boiler-plating lines in the header files in a keystroke.
function! CHeader()
"save the line location. This is for already existing files.
let line_no = line(".")
"Get the name of the file
let fname = bufname(bufnr("%"))
"get the name portion out
let fname_root = toupper(fnamemodify(fname, ':r'))
"get the extension
let fname_extn = toupper(fnamemodify(fname, ':e'))
if fname_extn != 'H'
echo "Only applicable to header files"
else
"Create the macro name. This is what you need to change if you
"want a different format.
let define = "__".fname_root."_H"
" Go to first line 0th column"
execute "norm! :1\<CR>0"
" Insert the #ifndef and #define
execute "norm! i#ifndef ".define."\<CR>#define ".define."\<CR>\<Esc>"
"Go to the last line column 0
execute "norm! :$\<CR>0"
"Insert the #endif statement
execute "norm! i\<CR>#endif \/\*".define."\*\/\<Esc>"
"Since we added two lines at the top, go to save line_no + 2
let line_no = line_no + 2
execute "normal! :".line_no."\<CR>"
endif
endfunction