Monday, December 16, 2013

Install Packages via yum using CentOS Media repo

when need to install new packages using yum, you can use either online repo or dvd repo. If there is no internet connection, possible solution is DVD repo. Here is simple way to configure DVD repo on Centos.

1) View Centos media repo file.

Since I use Centos 6.3 it is similar to following.you can use either less or cat command to view the file content. Some  lines are removed due to brevity

less /etc/yum.repos.d/CentOS-Media.repo
[c6-media]
name=CentOS-$releasever - Media
baseurl=file:///media/CentOS/
        file:///media/cdrom/
        file:///media/cdrecorder/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6


give more attention to following parameters
repo name -> c6-media
baseurl -> there is 3 file paths, those are the mount point of Centos DVD. you can customize it.




2) Create mount point if not exist

since this is demo, I create DVD mount location as first base URL. possible use any location which is defined in baseurl.
[root@localhost ~]# mkdir /media/CentOS


3) mount centos cdrom

mount /dev/cdrom /media/CentOS/

4)Install your package using yum

yum --disablerepo=\* --enablerepo=[repo name] install [pakage name]

ex:-
yum --disablerepo=\* --enablerepo=c6-media install cpan

if this is not working, you may need to clean repo using following command
[root@localhost ~]# yum clean all

Wednesday, December 11, 2013

Prevent SSH connection from freezing

Recently I have experinced my ssh connection to remote server is hung after idle time. this is very annoying because ssh connection was established over vpn and take time to reconnect the session again. If your ssh connection hung/freeze time to time following solution may be helpful.


1) Open the ssh_config file.


location may differ,in centos
vim /etc/ssh/ssh_config

2) Add following lines


Host *
    ServerAliveInterval 300
    ServerAliveCountMax 2



Remember, this configuration is done at client side. client send keep alive message to server every 180 seconds and server send ack (acknowledgement) message.If 2 consecutive ack messages are lost from server side. connection will be dropped as server is not available.

Sunday, November 17, 2013

Installing vpnc - Linux VPN Client for Cisco VPN

This tutorial, I will show you how to configure vpnc on Linux and  connect  Cisco devices through vpn using pcf file. The vpnc is an alternative Linux software for Cisco vpn client.
all the things are done on centos 6.3 but steps should be same for any Linux system.


1) Installing EPEL repo

Since centos repo doesn't contain the vpnc, we need to configure additional repo call EPEL.
It is straightforward installation and  document can be found form here.

http://fedoraproject.org/wiki/EPEL/FAQ#How_can_I_install_the_packages_from_the_EPEL_software_repository.3F

Please find "How can I install the packages from the EPEL software repository? " from content and install it. you may need to enable EPEL repo sometime.

2) Installing vpnc

once you enabled the rpmforge repo, type following command to install vpnc  
[root@localhost ~]#yum install vpnc

3)Chang folder permission

I installed the vpnc as root.if you wish to run vpnc as normal user other than root .change file permission of vpnc installaion directory
/etc/vpnc/vpnc-script

4)Download pcf2vpnc

[root@localhost ~]#wget http://svn.unix-ag.uni-kl.de/vpnc/trunk/pcf2vpnc

5)Convert pcf file

[root@localhost ~]#perl pcf2vpnc demopcf.pcf demovpnc.conf
change ownership of *.conf file if you need

6)copy *.conf to /etc/vpnc/ 

[root@localhost ~]#cp demovpnc.conf /etc/vpnc/

7)Start vpnc

[root@localhost ~]#vpnc demovpnc
Enter password for user@A.B.C.D:
(A.B.C.D is public ip address where you need to connect, user is username , you need to enter password )

8)disconnect vpnc

[root@localhost ~]#vpnc-disconnect

Sunday, October 27, 2013

nagios snmptt configuration

Hi folks after long time !. Today I'm going to demonstrate how to configure SNMP trap inside Nagios using SNMPTT. This simulation is done at Virtualbox 4.1.26 using two guest OS ( one guest act as server and running Nagios and snmptt, other is to generate SNMP trap and it is the client)

both guest are running Centos 6.3 32bit.

Server info :- ip 192.168.56.103
Client info :- 1p 192.168.56.104

I hope you have installed and configured the Nagios, If not you can follow installation guide
http://nagios.sourceforge.net/docs/nagioscore/4/en/quickstart-fedora.html

-----

So let's install snmptt. :)
download and extract latest version of SNMPTT. you can find official installation document from here
http://www.snmptt.org/docs/snmptt.shtml#Installation-Overview

For both server and client require net-snmp-lib , net-snmp-util so install them using using yum
yum install net-snmp-lib
yum install net-snmp-util


AT Server


1)Install prerequirement such as net-snmp, perl ,perl modules


[root@nagios ~]# yum install net-snmp
[root@nagios ~]# yum install perl

install perl cpan
[root@nagios ~]# yum install perl-CPAN

launch the CPAN using following command
[root@nagios ~]# perl -MCPAN -e shell

install following perlmodules 
(Getopt::Long,  Text::ParseWords ,SNMP, Config::IniFiles, Time::HiRes , Sys::Hostname , File::Basename, Text::Balanced )
for an instance
cpan[1]> install Text::ParseWords


This demonstration is done with Standard handler – with standlone mode which is straightforward (remember there is daemon mode)


2) Copy snmptt to /usr/sbin/ and ensure it is executable (chmod +x snmptt)

[root@nagios snmptt_1.3]# cp s[root@nagios snmptt_1.3]# chmod +x /usr/sbin/snmptt nmptt /usr/sbin/

3) Copy snmptthandler to /usr/sbin/ and ensure it is executable (chmod +x snmptthandler)

[root@nagios snmptt_1.3]# cp snmptthandler /usr/sbin/
[root@nagios snmptt_1.3]# chmod +x /usr/sbin/snmptthandler

4) Copy snmptt.ini to /etc/snmp/ or /etc/ and edit the options inside the file.

[root@nagios snmptt_1.3]# cp snmptt.ini /etc/snmp/

5) Create the log folder /var/log/snmptt/.

[root@nagios snmptt_1.3]# mkdir -p /var/log/snmptt/


6) For standlone mode:  Modify the Net-SNMP snmptrapd.conf file by adding the following line:

[root@nagios ~]# vim /etc/snmp/snmptrapd.conf
traphandle default /usr/sbin/snmptt
disableAuthorization yes

7) Edit the /etc/logrotate.d/snmptt and update the paths and rotate frequency as needed.

[root@nagios snmptt_1.3]# cp snmptt.logrotate /etc/logrotate.d/snmptt


8) Start snmptrapd using the command line:  snmptrapd -On.

[root@nagios snmptt_1.3]# snmptrapd –On

--

9) Convert MIB file


Copy eventhandler
[root@nagios ~]# cp /home/shehan/Downloads/nagios-4.0.1/contrib/eventhandlers/* /usr/local/nagios/libexec/eventhandlers

copy snmpttconvertmib into /usr/sbin/ folder
[root@nagios ~]# cp /home/shehan/Downloads/snmptt_1.3/snmpttconvertmib /usr/sbin/

then issue below command
[root@nagios ~]#snmpttconvertmib --in=/usr/share/snmp/mibs/SNMPv2-MIB.txt --out=/etc/snmp/snmptt.conf.SNMPv2-MIB \
--exec='/usr/local/nagios/libexec/eventhandlers/submit_check_result $r TRAP 1'


10) Edit /etc/snmp/snmptt.ini, and change below settings

[General]
mode = standalone
net_snmp_perl_enable = 1
unknown_trap_log_enable = 1

At end of file you can find line similar to this Add /etc/snmp/snmptt.conf.NET-SNMP-EXAMPLES-MIB like below

snmptt_conf_files = <<END
/etc/snmp/snmptt.conf
/etc/snmp/snmptt.conf.NET-SNMP-EXAMPLES-MIB
END


11) create host cfg file

[root@nagios ~]# vim /usr/local/nagios/etc/objects/remote-host.cfg
And add below (you may need to change ip host_name)


define host {
        use     linux-server
        host_name       remote-host
        alias           remote-host-alias
        address         192.168.56.104
        }

define service{
        use                        generic-service
        name                       trap-service
        register                   0
        service_description        TRAP
        is_volatile                1
        check_command              check-host-alive
        max_check_attempts         1
        normal_check_interval      1
        retry_check_interval       1
        notification_interval      31536000
        active_checks_enabled      0
        passive_checks_enabled     1
    check_period           24x7
        }

define service{
        use                        trap-service
        host_name                  remote-host
        }



12) Add blow command to nagios.cfg

[root@nagios ~]# vim /usr/local/nagios/etc/nagios.cfg
cfg_file=/usr/local/nagios/etc/objects/remote-host.cfg


13)allow snmp trap from firewall

[root@nagios ~]# iptables -I INPUT 1 -p udp --dport snmptrap -j ACCEPT

confirm the changes and then save using below command
[root@nagios ~]# iptabless –list
[root@nagios ~]# service iptables save

14) start service at server

[root@nagios ~]# service snmptrapd start
[root@nagios ~]# service snmpd start

configure to start at boot
[root@nagios ~]#chkconfig snmptrapd on
[root@nagios ~]#chkconfig snmpd on


AT Client,

generate SNMP trap message, this is SNMP v2 message

[root@localhost ~]# snmptrap -v 2c -c public 192.168.56.101 "" SNMPv2-MIB::coldStart coldStart  s "start"


AT Server


check below log messages
/var/log/messages
/var/log/snmptt/snmptt.log
And check nagios web interface.If everything works fine you can have similar output like below


nagios and  snmptt








----


Reference URLS

http://xavier.dusart.free.fr/nagios/en/snmptraps.html
http://hummy.wikidot.com/how-to-send-and-receive-snmp-traps
http://socketubs.org/docs/sysadmin/snmp_traps_nagios.html


Wednesday, May 22, 2013

sync log timestamp with system clock on cisco devices

By default most of Cisco devices, log time stamp is not sync with system clock.
I have experienced similar situation. refer to the below output, show clock  and log time stamp is totally different


show clock and log timestamp











To solve this problem, need to set log timestamps to local time (system time).
issue the below command


SW-2(config)#conf t
SW-2(config)#service timestamps log datetime localtime

SW-2(config)#exit
SW-2#wr

after that, the problem should be solved, below output prove that



service timestamps log datetime localtime












Thursday, April 18, 2013

Virtualbox file sharing between guest and host OS

Have you ever try to transfer files between VirtualBox guest OS and host OS ?
unfortunately drag and drop file transferring/sharing is not yet implemented on virtaulbox.so we have to look for alternative method.This is what I have done.my both host and guest OS are windows , remember this is possible on Linux environment with different commands.


[1] Run the guest OS


open Virtualbox then select and run guest OS that you need to transfer file.Here I used Windows XP as my guest OS


[2] Install Guest Additions


On the VirtualBox menu click " Devices " --> " Install Guest Additions... " and follow the instruction, If you get warning similar to below Click " continue anyway" to continue the installation and finally reboot guest OS.









virtualbox guestadditions Hardware installation


























[3] Create shared folder


go Machine --> Settings... you will have Virtual machine setting windows
then select  " shared Folders " ,as below



create Shared folder virtualbox



then click folder with "+" sign (right-hand corner ) to create shared folder on host OS as above screenshot.
Then you will have window called "Add share" like below, Choose the Folder Path and give a Folder Name.


virtualbox shared folder






















[4]Transfer file to guest OS


Start the guest OS (I used windows XP as my guest OS) open " Run " and type the below command
please note I used "sharedfiles" as folder Name. look at above screen shoot

\\vboxsvr\sharedfiles



vboxsvr





















once you type click "OK" , then you can open shared folder of the host machine.
If you reboot the guest OS this shared folder may not available therefore change shared folder setting as required

Happy file sharing !

Sunday, March 31, 2013

emulate CISCO ASA 8.4 on GNS3


This tutorial is outdated. New tutorial can be found at http://www.tectut.com/2015/12/how-to-setup-cisco-asa-in-gns3/  . It is our new blog :-)

Today, I would like to share how to setup ASA 8.4 Firewall on GNS3.

[1] Download asa image for GNS3

here is the link :- http://www.mediafire.com/download/c228c2sjdyrkwf3/ASA_842.7z
This file contain with initrd, vmlinuz and asdm 6.4

In any case above link is not working use below alternative link to download the file :-
link 1 :-  http://ge.tt/9RjhgNs/v/0?c
link 2 :- https://www.box.com/s/3fybjit5jsudhwyvqwz8



[2] Download & Install GNS3


You can download latest version from
http://www.gns3.net/download/
or
http://sourceforge.net/projects/gns-3/files/GNS3/


[3] Configure GNS3 for ASA


go to "Edit" --> "Preferences..."
On "Preferences" window, select "Qemu" and then choose "ASA" from the tabs

Fill the ASA setting & ASA Specific Settings as below . Screen capture is attached for your reference.




GNS3 Preferences













Qemu Options  & Kernel cmd line is important


Identifier name :     ( you can give any name )
RAM :     1024MB  ( at least 1024MB)
Qemu Options :     -vnc none -vga none -m 1024 -icount auto -hdachs 980,16,32
Kernel cmd line :     -append ide_generic.probe_mask=0x01 ide_core.chs=0.0:980,16,32 auto nousb console=ttyS0,9600 bigphysarea=65536

Click " save " and then "OK" and exit form that window.
drag and drop ASA firewall into work enviroment and run, It may take some time to boot please be patient !


[4] Configure activation keys


you can use one of below activation key
0x4a3ec071 0x0d86fbf6 0x7cb1bc48 0x8b48b8b0 0xf317c0b5
0xb23bcf4a 0x1c713b4f 0x7d53bcbc 0xc4f8d09c 0x0e24c6b6

for example :-

ciscoasa#conf t
ciscoasa(config)#activation-key 0x4a3ec071 0x0d86fbf6 0x7cb1bc48 0x8b48b8b0 0xf317c0b5
ciscoasa(config)#wr
ciscoasa(config)#exit

now it is done.

Friday, March 8, 2013

sharing folders using nfs on rhel

This tutorial guide you how to configure nfs share on rhel system.
Below is the details of nfs Server and client, both running Redhat enterprise Linux 6.2 64-bit

NFS Server :- host-name is server and ip address is 192.168.5.5/24
NFS Client :-  host-name is client and ip address is  192.168.5.3/24

NFS Server Configuration

[1]  Edit /etc/sysconfig/nfs

 To allow nfs traffic , should need to uncomment following variable LOCKD_TCPPORT ,LOCKD_UDPPORT, MOUNTD_PORT,  STATD_PORT on /etc/sysconfig/nfs as following


# TCP port rpc.lockd should listen on.

LOCKD_TCPPORT=32803



# UDP port rpc.lockd should listen on.

LOCKD_UDPPORT=32769



# Port rpc.mountd should listen on.

MOUNTD_PORT=892



# Port rpc.statd should listen on.

STATD_PORT=662



[2] Configure Firewall to allow nfs traffic .


TCP port 2049 for NFS.
TCP and UDP port 111 (rpcbind/sunrpc).

So let's edit the iptables file
[root@server ~]# vim /etc/sysconfig/iptables

By default this file contain few rules . Find following rule 
-A INPUT -j REJECT --reject-with icmp-host-prohibited
and insert bellow rules before that line

-A INPUT -m state --state NEW -m tcp -p tcp --dport 2049 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 111 -j ACCEPT

-A INPUT -m state --state NEW -m udp -p udp --dport 111 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 32803 -j ACCEPT

-A INPUT -m state --state NEW -m udp -p udp --dport 32769 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 892 -j ACCEPT

-A INPUT -m state --state NEW -m udp -p udp --dport 892 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 662 -j ACCEPT

-A INPUT -m state --state NEW -m udp -p udp --dport 662 -j ACCEPT


save and quit the iptabales file, then issue follwing command apply the new rules to system
[root@server ~]# service iptables restart

you can verify it by using following command
[root@server ~]#iptables -L


[3] Create a direcory to share with client


my share folder is /svrfile and i have assigned 
rwx (read write execute) permission for ugo (user group others).
[root@server ~]# mkdir /svrfile
[root@server ~]# chmod 777 /svrfile

[4] Edit exports file

[root@server ~]# vim  /etc/exports
and insert following line

/svrfile 192.168.5.3(rw,sync,no_root_squash)


192.168.5.3 is nfs client where i'm going share /svrfile . you can specify client host as  192.168.5.3/24
however /24 is default for class C network. If you wish to share with any host you can use '*' (without qutoes) instead of ipaddress.
Several parameters are available.I used rw,sync and no_root_squash . here is brief explanation.

rw :- enable read write
sync :-  Syncs write operations on request. Active by default
no_root_squash :- Treat remote root user as local root; remote root users get root privileges
on the shared directory

[5] restart rpcbind and nfs 

By default RHEL system is installed this services , If it is not you should have
to install .

[root@server ~]# service rpcbind restart

Stopping rpcbind:                                          [  OK  ]

Starting rpcbind:                                          [  OK  ]

[root@server ~]# 



[root@server ~]# service nfs restart

Shutting down NFS mountd:                                  [  OK  ]

Shutting down NFS daemon:                                  [  OK  ]

Shutting down NFS quotas:                                  [  OK  ]

Shutting down NFS services:                                [  OK  ]

Starting NFS services:                                     [  OK  ]

Starting NFS quotas:                                       [  OK  ]

Starting NFS daemon:                                       [  OK  ]

Starting NFS mountd:                                       [  OK  ]

[root@server ~]#



[6] refresh the export file


[root@server ~]# exportfs -r
if it is successful , no message will be displayed
please remember to refresh export file by issuing above command, If you are done any modification to export file.

further you can verify export file using following commands

[root@server ~]# exportfs -rv
exporting 192.168.5.3:/svrfile
[root@server ~]# 


[root@server ~]# showmount -e
Export list for server:
/svrfile 192.168.5.3
[root@server ~]#




NFS Client configuration


[7] enable services and create folder on client

we are done with NFS server configuration , so lets configure client, first of all create directory to share with server and then restart rpcbind and nfs services.

[root@client ~]# mkdir /clientfile

[root@client ~]# service rpcbind restart
[root@client ~]# service nfs restart


[8] Finally let's mount the nfs

[root@client ~]#mount -t nfs 192.168.5.3:/svrfile /clientfile



That's all , Don't hesitate to comment if you have question . have a nice day  !

Sunday, March 3, 2013

How to fix Google webmaster duplicate meta descriptions in blogspot


Google web master tool provides collection of tools for analyze the web/blog. Among those tools, HTML Improvements reports HTML errors on web/blog and provides suggestions to overcome those errors.
If you are new to Google webmaster, please look at Optimization --> HTML Improvements.
Most common error web masters are facing is duplicate meta description.




google webmaster tools duplicate meta descriptions









Most probably reason for that is, you have inserted same description meta tag on each and every page of the web/blog.Solution for blogspot blogs are really simple, you can find solution from here including blogger meta description best practices .  

If you are non-blogspot web master, please check your individual web page meta description ,
and make sure to remove duplicate  meta description tag  if it is there and create page specific
description that reflect your page content as description meta tag.


---

After 1 and 1/2 month time







Thursday, February 21, 2013

blogger meta description best practices

When creating a brand new blog, it's really important to insert meta tags on the bloggspot site such as title, keywords, description, robots ... etc.The major search engine such as google is intelligent enough to create relevant keywords for the blog/site by crawling the page. so what is the point of adding keyword meta tag to site ?? It is not really important perspective to Google. however other search engine may be use keyword meta tag, so do not forget to add keyword meta tag.  

The description meta tag plays major role on Google page ranking. don't forget Google own more than 60% percent of search engine traffic.Traditionally we are used to adding meta tag to blogger site similar to below by editing the html code of the blog.

 <meta content='your site Title is here' name='title'/>
 <meta content='your site keyword is here' name='keyword'/>

But what happen if you do the same for description tag ?? If you do that, every page of your blog has same description and search engine refuse to index those page by considering they have same content.so I'm going to discuss best practices of creating meta description to your blog.


* Adding Global meta description



1) Write a blog/web description

Take your time and create best description that is suitable to your site. it should be clear and concise with characters of 80 - 100.

2) Login to blogger site

so let's take advantage of blogger inbuilt tool of putting meta description.
 go to Setting --> Search preference --> edit Description and save. Use blow screen capture for your reference




Adding global meta Description to Blogger






















* Adding meta description for each post



3) So now you have successfully added global  description to your blog. next thing is, put a description to each blog post.It's so simple. go to Post --> click "edit" which post you want to add description
find "Search Description" field from left hand side panel, insert you page description, now you are done.




individual description to each blog post





Tip:- your page description should be the summary of the post. Remeber to add as much as keyword when you writing that summary ( to find relevant keywords use Google Adwords tool)
you can verify each meta tags including description meta tag using below tool.
http://www.submitexpress.com/analyzer/


4) happy blogging :)

Wednesday, February 6, 2013

Fixed Missing eth0 after creating a clone vm on linux kvm

Recently I have created a cloned virtual machine using redhat linux kvm, once the system is booted up
virtual machine  was unable to connect to system eth0 instead it's connected to Auto eth0 interface as below,
after doing some google search and reading some forums I have found a reason for this error.
this is due to cloned VM is using original VM mac address. in this tutorial I'm going to
show you how i solved that problem



Auto eth0 on kvm cloned virtual machine



















1) Edit ifcfg-eth0

go to /etc/sysconfig/network-scropts/ifcfg-eth0
and remove or comment the HWADDR line as following



ifcfg-eth0



if you want check newly cloned vm NIC mac address pls follow this steps
select guest os click edit  -->  virtual machine details --> show virtual hardware detils -->
select NIC --> view the mac adds.


2) Remove 70-persistent-net.rules

 command is  #rm /etc/udev/rules.d/70-persistent-net.rules
you may have different name for persistent-net file

persistent-net.rules







3)Reboot the system

 now system eth0 should be available also there should be new persistent-net.rules file with actual NIC mac address of cloned vm.


Saturday, February 2, 2013

How to fix audio video out of sync after conversion

Sometimes when you are converting video from one format to another, you may be experienced audio video out of syn after conversion.In this tutorial I'm going to show you how to fix it.




1) Download the Any video convertor. http://www.any-video-converter.com/products/for_video_free/  
.It is totally free. There is ultimate version of that software, but free version is enough for this.


2)After installing Any video convertor and select the video file you need to be converted.
please not that, I was tested with flv into mp4 conversion and output mp4 video has similar audio/video syn quality like the original one. I didn't have oppurtunity to test with other video formats but I'm pretty sure,
this method should work for any video format if it is supported by this converting software.


3)Now go to edit --> options.. --> select video tab --> increase Audio/Video Sync factor ( Default sync factor: ) to about 40 as the following image



solution for Audio video outof Sync issue from any video convertor







































4) by increasing Audio/Video Sync factor to higher value you can have better quality output but remember that takes time to complete the conversion.


5) hmm.. that's all , don't forget to put your comment/feedback here :)  .



Friday, January 25, 2013

virtualbox seamless mouse pointer integration and install guest additions

While running the Redhat linux on Virtual box, every time when I want to leave from
guest OS to host system I need to press "Ctrl" key (my Host key is Ctrl) .This is because seamless mouse pointer integration is not enable. This is painful and takes time to jump between guest OS and host system. After reading some forums post and web articles I have come across with a solution.In this method there will be one mouse pointer and pressing the Host key is no longer required to "free" the mouse from being captured by the guest OS and vice-versa. Following steps guide how to enable seamless mouse support on linux based guest system.


[1] install gcc and kernel-devel

install the GNU C compiler and the kernel development packages using

#yum install gcc

followed by

#yum install kernel-devel


[2] Reboot guest system

Reboot your guest system in order to activate the updates.

[3]Install Guest Additions

Click "Devices" --> "Install Guest Additions"




install guest additions

















[4] Follow the installation wizard
you will get window similar to below and click "OK" , you may need provide authentication




VBOXADDITIONS





















[5] It will be prompted with terminal window similar to following, Press Return and close that window... that's all , Now seamless mouse integration should be enabled . have a nice day!




virtualbox guest additions installation














Tuesday, January 22, 2013

Adding categories and sub categories to blogspot

 At the moment of writing this tutorial,  there is no way to add sub categories to blogspot, may be in future blogger will add this feature . To implement this feature needs to edit  HTML code of your template

[1] Take backup of your blog. 


Click " Settings  --->  Other --> Export blog " , and download the backup of your blog post , you can even can take template backup also.


[2] Edit HTML code of  your blog


Click " Template" --> "Edit HTML" , and you will get HTML code of template .
find a line similar to the following, it should be within first 10 -15 lines of code.
<b:skin><![CDATA[/* 

then add the following code before to above line.
<script src='http://blogcat.site40.net/dtree.js' type='text/javascript'/> 

final output should be similar to following
<script src='http://blogcat.site40.net/dtree.js' type='text/javascript'/> 
<b:skin><![CDATA[/*



[3] Adding JavaScript for Subcategories

go to "Layout" click " add a Gadget "  then choose " HTML/JavaScript " gadget and paste the following code and save the template.

//start


<style type="text/css">

.dtree {
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size: 15px;
width:480px;
color: #000;
white-space: nowrap;
}
.dtree img {
border: 0px;
vertical-align: middle;
}
.dtree a {
color: #333;
text-decoration: none;
}
.dtree a.node, .dtree a.nodeSel {
white-space: nowrap;
padding: 1px 2px 1px 2px;
}
.dtree a.node:hover, .dtree a.nodeSel:hover {
color: #333;
text-decoration: underline;
}
.dtree a.nodeSel {
background-color: #c0d2ec;
}
.dtree .clip {
overflow: hidden;
}

</style>
<div class="dtree">


<script type="text/javascript">
<!--

d = new dTree('d');

d.add(0,-1,'Blog Categories'); //
d.add(1,0,' '); //
d.add(100,1,' ','','');  //
document.write(d);
//-->
</script>
</div>

//end


Now, it is done !

d.add(0,-1,'Blog Categories');
d.add(1,0,' ');
d.add(100,1,' ','','');  

please make sure to edit(fill the parameters) above highlighted lines of code according to your blog, otherwise this will not work. Please refer following code explanation.

JavaScript Code explanation


bellow is example code I'm using on my blog. now I'm going to explain the code. all my explanation are bold italic

all the categories are staring from 1 and topics are staring from 100
/*category index 0-99
0 - Blog categories
1 - OpenCV
2 - Linux
3 - Networking stuff

topics start 100..
*/

explanation for d.add() functions and it's parameters
d.add( index , parent index , topic , topic URL  , brief description of the topic ) .this is very simple explanation. you can learn more about from this link http://www.destroydrop.com/javascripts/tree/api/


d.add(0,-1,'Blog Categories');
d.add(1,0,'OpenCV'); //OpenCV category
d.add(100,1,'OpenCV installation','http://techtute.blogspot.com/2011/01/opencv-22-installation-on-visual-studio.html','opencv 2.2 installation on visual studio 2008');

d.add(101,1,'Negative Images','http://techtute.blogspot.com/2011/06/negative-background-images.html','negative background images');

d.add(102,1,'Positive Images','http://techtute.blogspot.com/2011/06/haartraining-positive-samples.html','haartraining positive samples');

d.add(103,1,'opencv haartraining','http://techtute.blogspot.com/2011/06/opencv-haartraining.html','opencv haartraining steps');




If you have followed above steps correctly, you will get an output similar to the following :) .
You can find live demonstration top right hand under name as " categories " 


Adding sub categories to blogspot




















Monday, January 21, 2013

set post title before blog title in blogger for better SEO

Default blogspot template title structure is  " Blog Title | Post Title ". Appearing blog title before the post title will cause to get low clicks to your content through search engine, because post title provide summary of post/article content not the blog title. So let's change this default behavior .

click on the " Template "  --> " Edit HTML "  --> " Proceed " .
find following line of code

<title><data:blog.pageTitle/></title>

and replace the above line with following code

<b:if cond='data:blog.pageType == &quot;item&quot;'>
<title><data:blog.pageName/> |
<data:blog.title/></title>
<b:else/>
<title><data:blog.pageTitle/></title>
</b:if>

save the template, Now blogspot template title structure should be changed into " Post Title | Blog Title "  . please note this takes some times to change on search engine, later you can verify it, from  following Google query.
site: yourblog.blogspot.com 
below is example output of ,  site:techtute.blogspot.com




post title before blog title in blogger


















Sunday, January 6, 2013

[SOLVED] the action can't be completed because the file is open in windows explorer mkv file

There was  movie on my hard disk which has mkv format and When I'm going to delete that mkv file, it is prompted with following error message.
" the action can't be completed because the file is open in windows explorer "


the action can't be completed because the file is open in windows explorer


 

 and it doesn't allow me to delete it at all. I restarted my computer and try to delete it but same error no luck. Finally I have found a solution , it was very simple than I thought . This is what I have done

[1] open command promt

for windows 7 , click start and type cmd

[2] Change the directory where delete file is located

in my case, file is at Desktop and I used following command to change the directory
cd c:\Users\Admin\Desktop

Now try to delete file using command line , issue following command
del "file name"

but you will get an error message similar to following for sure :) don't worry !!
" The process cannot access the file because it is being used by another process. "



The process cannot access the file because it is being used by another process
























[3] Disable "explorer.exe"

open the task manager , select "Process" tab and select "explorer.exe" from the process list and click "End Process" button
Now every thing should be vanished except command promt and Task manager , don't be confused we will get back them all later :D

[4] Delete the mkv file

Now again issue del command , this time it should be executed and you will get no error messages.
ok , big step is done , now time to get back desktop and task bar

[5] bring back desktop and task bar

type explorer.exe on command prompt . how simple it is :))


Related Posts