November 16, 2008

Apache configuration journal - I

Redirect all requests for any resource to single file

Steps 1: Requires mod_rewrite

Steps 2: Add following line to <APACHE_HOME>/conf/httpd.conf if it doesn't exist.

LoadModule rewrite_module modules/mod_rewrite.so

Steps 3: Add following lines to .htaccess file in the root directory of your WEBROOT

We are asking apache to redirect all requests which don't have an existing source code to "index.php". This could have been any other existing file in the WEBROOT. This will also prohibit browsing of files in different folders. If you want to enable browsing for folders in your WEBROOT, modify the above .htaccess configuration to

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php [L]
</IfModule>

PS: This will however expose all the existing directories for browsing by others

However if you want to restrict access to particular type of files, use regex and following kind of configuration in .htaccess

<Files ~ "^\.ht">
Order allow,deny
Deny from all
Satisfy All
</Files>

The configuration above says don't serve any file starting in name with ".ht"

To enable php's default compression while delivering any content (Saves bandwidth)

<IfModule mod_php4.c>
php_value zlib.output_compression 16386
</IfModule>

November 15, 2008

Sunscreen by Baz Luhrman



Probably one of the best videos on Youtube i've seen.

Here are the lyrics http://www.icdc.com/~dnice/sunscreen.html

October 22, 2008

Something i wrote on my birthday eve

Sometimes ago,
I was at 26th floor.
It was all shinning,
even though i saw few people whining
I gave them no care,
coz i had my cookies and change to spare

I had this guide
always by my side
he showed me the floor
we visited most of the stores

it was all so good
i'd a lot of good food
made couple of good friends
always ready with their helping hands

there was music and then there was drama
lots of fun and lots of karma
but hell!! the clock was ticking
and the escalator was moving
it reached the next floor
without even my knowing
the machine greeted me
in a human voice
I'd reached 27th floor
it suddenly was different, I didn't feel nice

hey where is the guide?
where are those cookies?
I find myself lost here
without clear skies

There are few stars
but no moonlight
I see dark clouds
giving a very bad fight

stores are there
and i've the money
but the cookies are different
that i don't like
new people new ways
i'm waiting for this floor to pass away...

October 15, 2008

updated vimrc

In my last post, i explored couple of basic features about VIM. Here is an updated version of my .vimrc. It had some issues with the "hiding tabs" settings as well which is cured in this version (well it wasn't working on my office PC where i had vim 6 instead of 7)

""""""""""""""""""starts here
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Vim As Editor Settings
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" To enable syntax highlighting
syntax on

" come out of vim compatability mode, why go to old vi when we have vim
set nocompatible

" Detect type of the file
filetype on
" Load filetype plugins
filetype plugin on

" How many lines of history to remember
set history=1000

" To enable a color scheme that is pleasant to eyes
:colorscheme delek

" To convert tabs to spaces; use :retab to convert all tabs to current
" settings
set tabstop=4
set shiftwidth=4
set expandtab

" To catch hiding tabs
set list listchars=tab:>-,trail:-

" makes the backspace key treat the four spaces like a tab (so one backspace
" goes back a full 4 spaces)
set softtabstop=4

" enable line number
set number

" have mouse on vim all the time
set mouse=a

" load .vimrc whenever it is edited
autocmd! bufwritepost vimrc source ~/vim_local/vimrc

" Don't indent while pasting
set pastetoggle=<f3>

" Remove indenting on empty lines
map <f2> :%s/\s*$//g<cr>:noh<cr>''

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Vim UI
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" set title of the xterm to the name of the file
set title

" set the height of command bar to 2
set cmdheight=2

" Enable folding
set foldenable
" fold lines with similar indent (collapse feature) or manually in insert mode
" using CTRL-T (indent) CTRL-D (dedent)
set foldmethod=indent
" Don't autofold anything (but can be done manually)
set foldlevel=100
" Don't open folds when you search into them or undo
set foldopen-=search,undo

" show matching brackets
set showmatch
" how many tenths of a second to blink matching brackets for
set mat=5

" do not highlight searched for phrases
"set nohlsearch
" BUT do highlight as you type you search phrase
set incsearch

" show filename and other details about the buffer
set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v][%p%%]\ [LEN=%L]
" keep showing the status
set laststatus=2

"allow backspace (b), space(s) and arrows to move the cursor to
"previous/next line
set whichwrap=b,s,<,>

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Auto-complete
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"set complete-=i

" Turn on wild menu which shows auto-complete options in the command mode
set wildmenu

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" PHP
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let php_sql_query=1
let php_htmlInStrings=1
let php_noShortTags=1

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" HTML
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" HTML entities - used by xml edit plugin
let xml_use_xhtml = 1
"let xml_no_auto_nesting = 1

"To HTML
let html_use_css = 1
let html_number_lines = 0
let use_xhtml = 1

""""""""""""""""""ends here

September 28, 2008

Orkut showing vulgar ADs and cutting them off using Firefox

So this morning i login to my orkut a/c and guess what... i'm greeted with annoying vulgar ads [see below].

Well i appreciate free services provided by these companies (including Google) and do allow ads from online sites at times but that doesn't mean you will show any bulls**t to me.

And then i added orkut as well to my ads filter. Here is how you can avoid these ads using Firefox.

1. Install latest firefox release from http://www.mozilla.com/en-US/firefox/
2. Open firefox and install latest release of AdBlock Plus Plugin from http://adblockplus.org/en/installation
3. Select one of the Filter subscription (this is a default blacklist contributed by the community and helps you combat with many generic Ads) [I'm subscribed to EasyList]

Now you are ready to block any unwanted Ads whenever you encounter them while surfing. Just right click on the area where AD is appearing; a menu like below will appear


Select "Adblock IFrame" or "Adblock Frame" (whichever is the case). You will see something like below appear.


We will edit that to further block any ADs like this.


Thats it. Say "OK" and you are done. You won't see any further ADs on orkut. Say cheese.... :-)

September 22, 2008

And i will remember.. (perhaps forever)

[PS: i was going through bunch of yahoo services i'm subscribed to, and bumped onto my good old briefcase folder. I'd not visited briefcase since last 2-3 years until now, but found couple of good old memories in it. This is the farewell poem i wrote for my classmates at KGP. Well i did forget to include couple of guys in the poem, i still feel sorry for it. Sorry to all of them for this was written in one night, that too post midnight when i just woke up and thought to write something with all the senti wenti stuff]


Here comes the end of one life
and all those fantastic years five

will miss those lemmas corrollaries and theorem
but thanks GOD, i wont have to prove any more of them

those classes and lectures, where sometimes we slept
and those horrible assignments which gave us no rest
those examination nights that we never slept
and those "help each other" promises that we always kept

those mischiefs of aaloo, those shoutings of BK
that crying Tiwari and cracku Pinaki
and let me recall fundoo mustu,
the guy with microsoft and DR 2

Yup giri is tough and mansi too sweet
sheetal is smart and banarsi broken heart
remember mr psycho and his unworldly thoughts,
and those teasings on Anjan and some small small fights

Nath, thanks for those treats back at your home
i'm still looking forward for few more of them

Had a great time with all you guys,
its now time to say you all good byes.

I wish i could speak more and more
but the time is limited and my heart getting sore
not because i've nothing more to add
but because i'll be leaving KGP and i'm a little bit sad

Love you kgp, dont forget me sweatheart,
coz you will remain alive forever in my heart

September 01, 2008

My .vimrc

Well, promised myself long back that i will post technical articles here as well but have been really lazy for quite sometime now. It hits me again and again because i had to look for similar things multiple times. So here i make yet another promise to myself to post those stuffs which i can re-use again and again. Hope some of this would be helpful to others as well.. ahh someday!

This one is my .vimrc settings i configured couple of days ago. Comments inlined for better reading :-)

"---------begins here----------
" To enable syntax highlighting
:syntax enable

" To enable a color scheme that is pleasant to eyes
:colorscheme delek

" To convert tabs to spaces; use :retab to convert all tabs to current
" settings
set tabstop=4
set shiftwidth=4
set expandtab

" To catch hiding tabs
set list listchars=tab:»·,trail:··

" makes the backspace key treat the four spaces like a tab (so one backspace
" goes back a full 4 spaces)
set softtabstop=4

set title

" fold lines with similar indent (collapse feature) or manually in insert mode
" using CTRL-T (indent) CTRL-D (dedent)
"set foldmethod=indent
"---------ends here----------

PS: I will keep updating this post as and while i explore cooler stuffs on VIM. As of now i'm loving it.. :)