Skip to main content

Posts

Showing posts from August, 2012

IPTABLES

Under linux OS, we use iptables to secure the machine from any other external attack. In current scenario I am forwarding the packages from local interface to external interface and i have squid configured which will be acting as transparent proxy. Only selective port numbers are open for the network. 1. Save the script to a file. 2. Give permission to execute. chmod +x filename . 3. Execute the file as follows ./filename 4. save the output of the script to system iptables file, by running the command service iptables save 5. You are done, start/restart the iptables service. service iptables restart Script: #!/bin/sh # chmod +x file name to execute # eth0 LAN # eth1 WAN # Local IP range 192.168.0.0/25 # NATing # Transparent proxy iptables -F iptables -X iptables -t nat -F iptables -t nat -X iptables -t mangle -F iptables -t mangle -X iptables -P INPUT ACCEPT iptables -P FORWARD ACCEPT iptables -P OUTPUT ACCEPT iptables -A INPUT -i lo -j ACCEPT iptables -A

Install LibreOffice on Fedora

Download the package from LibreOffice.org 1. Unpack the downloaded package. tar -xvf Libxxxx 2. Installing LibreOffice rpm -Uvh RPMS/*.rpm If you get error here saying libgnomevfs2 is missing. Install the package as follows. yum install ruby-gnomevfs 3. Desktop Integration setup for LibreOffice rpm -Uvh RPMS/desktop-integration/libreofficeX.X-freedesktop-menu-XXXXXXXX

Install MRTG and SNMP

The Multi Router Traffic Grapher (MRTG) is a tool to monitor the network traffic load. With this tool you can even monitor router traffic. Before we configure MRTG, we need a working Simple Network Management Protocol (SNMP) server. 1. Install snmp packages yum install snmp net-snmp net-snmp-utils -y 2. Configure SNMP vi /etc/snmp/snmpd.conf Locate line that contains: com2sec notConfigUser default public Add or change to as follows, in case of 192.168.0.0/24, enter your own internal network range: com2sec local localhost public com2sec mynetwork 192.168.0.0/24 public Locate line that contains: group notConfigGroup v1 notConfigUser group notConfigGroup v2c notConfigUser Add or change to as follows: group MyRWGroup v1 local group MyRWGroup v2c local group MyRWGroup usm local group MyROGroup v1 mynetwork group MyROGroup v2c mynetwork group MyROGroup usm mynetwork

List all tables details of a database

To get all the table details of a specific database in MS SQL Server, use the following query. USE [DATABASE-NAME] SELECT * FROM INFORMATION_SCHEMA.COLUMNS After you run the query use can select individual fields as per your requirement. As of me my requirement is as follows. USE [DATABASE-NAME] SELECT TABLE_NAME, COLUMN_NAME,DATA_TYPE,IS_NULLABLE, ISNULL(COLUMN_DEFAULT,'') AS COLUMN_DEFAULT FROM INFORMATION_SCHEMA.COLUMNS ORDER BY TABLE_NAME To include the length of the column run the following script. USE [DATABSE-NAME] SELECT OBJECT_NAME(c.OBJECT_ID) TableName ,c.name AS ColumnName ,SCHEMA_NAME(t.schema_id) AS SchemaName ,t.name AS TypeName ,t.is_user_defined ,t.is_assembly_type ,c.max_length ,c.PRECISION ,c.scale FROM sys.columns AS c JOIN sys.types AS t ON c.user_type_id=t.user_type_id ORDER BY TableName;

Display uncommented lines of a file

As you must be aware that in any configuration file under Linux OS, there is hundreds of lines, most of them are commented with explanations. Therefore going though such files takes time to locate the line we are looking for. I use the command below to remove all the commented lines and blank lines by combining two commands using pipe '|'. In my case the comments are marked with #. grep -v "^#" main.cf | grep -v "^$" The grep -v "^#" filename will remove the commented line. The grep -v "^$" will remove the blank lines.

Installing VNC in CentOS 5/6

When you are installing make sure the Desktop Environment is already installed. Installing VNC Server in CentOS 6 yum install tigervnc-server vncpasswd #to configure vnc to user To Start vncserver vncserver:2 To Stop vncserver –kill :2 vim /home/root/.vnc/xstartup #twm & exec gnome-session & Display setting vncserver :2 –geometry 800x600 –depth 24 Installing VNC Server in CentOS 5.x yum install vnc-server vim /etc/sysconfig/vncserver #locate and make change as follows. Where 2 is Display Number and root is the user VNCSERVERS="2:root" #uncomment and remove –localhost VNCSERVERARGS[1]="-geometry 1024x768 –nolisten tcp –nohttpd" Now let's assign VNC password to the user root. As I am already logged in as root I will not be switching user. vncpasswd service vncserver start vim /home/root/.vnc/xstartup #comment twm & #twm & #Add to run in gnome exec gnome-session & service vncserver restart chkconfig vncserv

install JSON in centos

JSON (JavaScript Object Notation) is a light weight data-interchange format. yum install gcc make php-devel php-pear pecl install json vi /etc/php.ini Look for work Dynamic Extensions and add a new line extension=json.so Make sure JSON is also enable in this file cat /etc/php.d/json.ini like this. ; Enable json extension module extension=json.so service httpd restart

No Power Off/Shutdown Menu in Fedora

I have installed Fedora 16 in my Laptop and found out that there is no Turn Off/Power Off/Shutdown button in the GNOME menu. So I had to select Log Out... and then Power Off. If you are also wonder how to make Power Off menu available, here is what you can do. Open the menu and keep pressing ALT key, you should see the Suspend menu getting changed to Power Off...

SQL Server Database Mail setup

Firstly we need to enable Database Mail feature in the server that has MS SQL Server installed. This can be done using GUI or TSQL. In this tutorial I will be demonstrating using TSQL, as I prefer it. Step 01 : Enable Database Mail feature in MS SQL. USE master go sp_configure 'show advanced options',1 go reconfigure with override go sp_configure 'Database Mail XPs',1 go reconfigure go Step 02 : Create database account. EXECUTE msdb.dbo.sysmail_add_account_sp @account_name = 'Admin', @description = 'Mail account for Database Mail', @email_address = 'me@example.com', @display_name = 'Younten Jamtsho', @username='me@example.com', @password='meeeeeeeeeeee', @mailserver_name = 'mail.example.com' Step 03 : Create a mail profile. EXECUTE msdb.dbo.sysmail_add_profile_sp @profile_name = 'AdminProfile', @description = 'Profile used for da

Download music from Soundcloud.com

You must be interested to download some music that is available in soundcloud.com . Here is a simple solution to download it. Search for the song and then copy the song link. Go to http://offliberty.com/ and paste the link of the song that you have copied from soundcloud.com to the textbox and click Off. Then you will be directed to another screen and after that just follow the instruction to save the song in your PC/Laptop.

Installing Yii Framework in XAMPP

Yii is a component-based high-performance PHP framework. Yii provides nearly every feature needed by today's Web 2.0 application development like MVC, web services, theming, widgets and so on. 1. Download the framework from www.yiiframework.com 2. Extract the file and place it into your xampps htdocs. For this tutorial, I have extracted D:\XAMPP\htdocs\yiiframework 3. Make sure that Apache and MySQL services are running in XAMPP. 4. There is some requirement checking to be done, so browse to http://localhost/yiiframework/requirements/ 5. Make sure that you pass all the requirements and there is no Failed status. 6. Lets set system variable. Go to My Computer>Properties>Advance System Settings>Environment Variables . Under System Variables select Path variable and Edit. In Variable Value, append ;D:\xampp\php at the end of line. The reason we do this is because, if we don't set the value we get error "php.exe is not recognized as an internal or external com

Installing Latest version of PHP on CentOS

Recently I have been trying to install the latest version of PHP in my CentOS. But before I do that, I need to install EPEL yum repository on my CentOS. EPEL for i386 http://ftp.riken.jp/Linux/fedora/epel/5/i386/epel-release-5-4.noarch.rpm EPEL for x86_64 http://ftp.riken.jp/Linux/fedora/epel/5/x86_64/epel-release-5-4.noarch.rpm If you have any version of PHP installed then you need to remove it using yum remove php php-* Now lets install Latest PHP yum install php53 php53-* After completing the installation, lets check the version of PHP installed: php -v

Index Rebuild and Index Reorganize

Index Rebuild This process drops the existing Index and Recreates the index Rebuild all indexes for the respective table ALTER INDEX ALL ON < table name > REBUILD; Rebuild specific indexes for the specific table ALTER INDEX < Index Name > ON < Table Name > REBUILD; Index Reorganize This process physically reorganizes the leaf nodes of the index. Reorganize all indexes for the specified table ALTER INDEX ALL ON < table name > REORGANIZE; Reorganize a specific index ALTER INDEX < Index Name > ON < Table Name > REORGANIZE; Recommendation : Index should be rebuild when index fragmentation is great than 40%. Index should be reorganized when index fragmentation is between 10% to 40%. Index rebuilding process uses more CPU and it locks the database resources. SQL Server development version and Enterprise version has option ONLINE, which can be turned on when Index is rebuilt. ONLINE option will keep index available during the rebuilding.

Folder is hidden & hidden check mark is disabled

Due to virus attack or something, the folders in a pen drive might become hidden. The folders are still hidden even after cleaning the virus. Even if you right click the folder and check its properties to unhide the folders but the hidden option is disabled and unable to unhide the folders by this method. Use the following option in your CMD. attrib -s -h folder name (for a single folder) attrib -s -h /s /d (for all the directories including the sub directories)

Windows Communication Foundation (WCF)

What is WCF? Windows Communication Foundation (Code named Indigo) is a programming platform and runtime system for building, configuring and deploying network-distributed services. It is the latest service oriented technology; Interoperability is the fundamental characteristics of WCF. It is unified programming model provided in .Net Framework 3.0. WCF is a combined feature of Web Service, Remoting, MSMQ and COM+. WCF provides a common platform for all .NET communication. Advantages of WCF WCF is interoperable with other services when compared to .Net Remoting where the client and service have to be .Net. WCF services provide better reliability and security in compared to ASMX web services. In WCF, there is no need to make much change in code for implementing the security model and changing the binding. Small changes in the configuration will make your requirements. WCF has integrated logging mechanism, changing the configuration file settings will provide this functionality

Web Services

What is Web Service? Web Service is an application that is designed to interact directly with other applications over the internet. In simple sense, Web Services are means for interacting with objects over the Internet. Web Service is Language Independent Protocol Independent Platform Independent It assumes stateless service architecture. History of Web Service or How Web Service comes into existence? As i have mention before that Web Service is nothing but means for interacting with objects over the Internet. Initially Object - Oriented Language comes which allow us to interact with two object within same application. Component Object Model (COM) which allows to interact two objects on the same computer, but in different applications. Distributed Component Object Model (DCOM) which allows to interact two objects on different computers, but within same local network. which allows two object to interact internet. That is it allows to interact between two object on

IELTS test in Bhutan

In Bhutan, International English Language Testing System (IELTS) exam is conducted only four times in a year. Royal Institute of Management (RIM), Thimphu is the only IELTS Exam Center in Bhutan. You can apply online by going to https://ielts.britishcouncil.org/india . For more detail on IELTS exam procedure log on to http://www.britishcouncil.org/india-exams-ielts-how-to-register.htm

Using IIS and XAMPP together

I am ASP.NET developer as well as a PHP developer. I have my visual studio installed in my laptop to work on asp.net/.NET and now I need to install XAMPP to work on PHP, MySQL, Apache and Perl. By default IIS uses port 80 and 443 for HTTP and HTTPS, and Apache also uses the same ports as IIS. Now to solve the conflict of ports there is only two way: Change IIS config – the hardest way Change Apache config – the easiest way I choose to go with second option, and which is lot more easier. I installed XAMPP in my drive D: I need to configure Apache to listen to port 8080. Edit file D:/xampp/apache/conf/httpd.config Find "Listen 80" and change it to "Listen 8080" Find "ServerName localhost:80" and change it to "ServerName localhost:8080" Now I need to configure for SSL/HTTPS. Edit file D:/xampp/apache/conf/extra/httpd-ssl.conf Find "Listen 443" and change it to "Listen 4499" Find "VirtualHost _default_:443

Know your Lha Zha, Sog Zha, Shi Zha

There is believe in Buddhism, that an individual person have got their own lucky day and bad luck day in a week. They are derived from the twelve animals similar to chiness horscope. Your birth year tells you which Buddhism zodiac sign you below to. Lha Zha and Sog Zha are belived to be good day while Shi zha is consider bad day.

Tshe Lung Nye

Tshe Lung Nye lies in the west of the capital city of Bhutan, Thimphu. Thirty three kilometers drive from Thimphu, across the valleys of Khasadrupchu and Jemina, and about 15 minutes walk lies a historical sacred land of Tshe Lung Nye blessed by Guru Padmasambhava in 8th century. Amongst many secret places blessed by Guru Padmasambhava in the country Bhutan, Tshe Lung Nye is one of the most auspicious pilgrim sites. It is the place where Guru Padhmasambhava mediated for four months, entrusting his hidden treasures to local guardians and dharma protectors. The mountain and the large boulders in which the treasures were concealed is identified by their unique shapes, colour and merely by the inexplicable power of the place. The place also includes long life holy water blessed by angels and Guru Padmasambhava Accordingly in the 18th century, as per Guru Padmasambhava’s prophecy, Terton Drugdra Dorji visited Tshe Lung Nye. Where he was reminded by the treasure guardians and hence he r

Create User With Full Name in Linux

If you want to add a user along with his/her full name. Here is how to do it. useradd -s /sbin/nologin -c "Younten Jamtsho" younten With the above command, I am creating a user younten, who's full name is Younten Jamtsho. Addition to that, I am assigning nologin shell to the user younten so that he cannot log in to ssh. Now that you have created the user, use finger command to see the details of the user. finger younten Lets change the default directory for the user youten from /home/younten to /var/www usermod -d /var/www/ younten Now lets change the existing username younten to webmaster usermod -l younten webmaster

Configuring ASP.NET website to use SQL Server for Session state

Today i was working on an application. So thought of storing the session in sql server. I will be installing on my notebook, my notebook name is yj-NB. I have set sa user password as sa123 on database. Here are the steps to follow: Step 1: Here is the code to add in web.config ; <sessionState mode="SQLServer" sqlConnectionString="data source=yj-NB;UID=sa;PWD=sa123;" cookieless="false" timeout="20"/> You don’t have to mention database name. Step 2: Installing the Session State Database Using the Aspnet_regsql.exe Tool Go to command prompt Systemdrive\WINDOWS\Microsoft.NET\Framework\version\ aspnet_regsql.exe -S yj-NB -U sa -P sa123 -d ASPstate -ssadd -sstype c yj-NB: computer name sa123: sa password ASPstate: Database name that will be storing session

SQL DML & DDL

SQL Data Manipulation Language (DML) : DML is a syntax for executing queries and DML component of SQL comprises have four basic statements: SELECT - Retrieve rows from tables UPDATE - Modify the rows of tables DELETE - Remove rows from tables INSERT - Add new rows to tables. SQL Data Definition Language (DDL) : DDL is used to create and destroy databases, database table and database objects. These commands will primarily be used by database administrators during the setup and removal phases of a database project. DML component of SQL comprises have four basic statements: CREATE - Creates a new database table ALTER - Alters / changes a database table DROP - delete a database table

SQL @@ROWCOUNT

Returns the number of rows affected by the last statement. It will let you to do a checking on the record you updated. If the number of rows is more than 2 billion, use ROWCOUNT_BIG. Example USE DB2008; GO UPDATE User SET JobTitle = 'Manager' WHERE UserID = 'u10021' IF @@ROWCOUNT = 0 PRINT 'Warning: No rows were updated'; GO Source: sqltutorials.blogspot.com

SQL Split Function for string

This SQL Split Function is use to SPLIT a sentences based on the Delimeter. Delimeter is a string character used to identify substring limits. --Below is Split Function in SQL DECLARE @NextString NVARCHAR(40) DECLARE @Pos INT DECLARE @NextPos INT DECLARE @String NVARCHAR(40) DECLARE @Delimiter NVARCHAR(40) SET @String ='Paro|Haa|Thimphu' SET @Delimiter = '|' SET @String = @String + @Delimiter SET @Pos = charindex(@Delimiter,@String) WHILE (@pos <> 0) BEGIN SET @NextString = substring(@String,1,@Pos - 1) SELECT @NextString -- Show Results SET @String = substring(@String,@pos+1,len(@String)) SET @pos = charindex(@Delimiter,@String) END Output : Paro Haa Thimphu Source: sqltutorials.blogspot.com

Regular Expression to Validate a Decimal Number

I had always used to ajaxToolkit MaskedEditExtender for entering decimal value. But I was interested to do the other way round without using ajaxToolkit MaskedEditExtender. Finally I found the solution using Regular Expression. I wanted 4 digit before decimal point and 3 digits after decimal point. Below is how I did it: <asp:TextBox ID="txtAmount" runat="server"></asp:TextBox> <asp:RegularExpressionValidator id="RegExVal" runat="server" ControlToValidate="txtAmount" ValidationExpression="^[0-9]{1,4}(\.[0-9]{0,3})?$" ErrorMessage="Enter Exact decimal value" /> Happy coding... :)

Install Clamav Antivirus

Before you start installing Clamav Antivirus in your Linux box, please add the extra repository for yum. Install Dag repository, and how to install, go to my post Add Repository for yum . yum - -enablerepo=dag install clamav -y After installing there is few changed needed in configuration file. vim /etc/freshclam.conf #locate the line below and comment it #NotifyClamd /etc/clamd.conf Now update the clamd and its virus defination #freshclam To scan for Virus #clamscan - -infected - -remove - -recursive eg. #clamscan - -infected - -remove - -recursive /home

chown

chown stands for Change Ownership. To change the ownership and group of files and directories Change ownership of a single file chown : eg. chown root:root message.txt Change ownership of a directory and all sub files and directories chown -R : eg. chown -R root:root photo

Warning/Deprecated Error in bbPress

After installing bbPress, if you get a Deprecated/Warning error message then please check your php Version. bbPress don't seem to support latest version of php. bbPress is doing this, has been "deprecated" (made obsolete) in the new version of PHP. Everything will still work, but in the future PHP may change and these functions will error out. Steps: 1. locate bb-load.php , go to line 25: 2. Change From error_reporting( E_ALL ^ E_NOTICE ); to error_reporting( E_ALL ^ E_DEPRECATED ^ E_NOTICE);

Changing The Site URL in bbpress

Like wordpress you can also change the Site URL of bbpress. Steps: 1. Login to phpMyAdmin. 2. Click the link to your Databases. A list of your databases will appear. Choose the one that is your bbPress database. All the tables in your database will appear on the screen. 3. From the list, look for bb_meta . Note: The table prefix of bb_ may be different if you changed it when installing. Click on the small icon indicated as Browse. A screen will open with a list of the fields within the bb_meta table. 4. Under the field meta_key , scroll down and look for uri . Click the Edit Field icon which usually is found at the far left at the beginning of the row. The Edit Field window will appear. In the input box for option_value, carefully change the URL information to the new address. Verify this is correct and click Go to save the information.

Changing the Site URL in wordpress

On the Settings > General screen in a single site installation of WordPress, there are two fields named "WordPress address (URL)" and "Site address (URL)". These are also known as the "Home" and "Site URL" settings. They are important settings, since they controls where WordPress thinks your site is located. They control the display of the URL in the admin section of your page as well as the front end, and are used throughout the WordPress code. Steps: 1. Login to phpMyAdmin. 2. Click the link to your Databases. A list of your databases will appear. Choose the one that is your WordPress database. All the tables in your database will appear on the screen. 3. From the list, look for wp_options . Note: The table prefix of wp_ may be different if you changed it when installing. Click on the small icon indicated as Browse. A screen will open with a list of the fields within the wp_options table. 4. Under the field option_name , scroll do

Fail2ban - Block attacks

Your server is venerable to attacks, and you have to time and again monitor. After monitoring you have to block the attackers IP’s. Use Fail2ban package, which would ease you a bit. To install Fail2ban you need to add extra 3rd party repositories - Extra Package for Enterprise Linux (EPEL). After that you can use yum to install the package. How to install addition repositories for your linux box ( Add Repository ) yum install fail2ban

DHCP Server

Set DHCP ( Dynamic Host Configuration Protocol ) Server in Linux Box. Lets first install DHCP package in 1. yum -y install dhcp Now that you have installed the dhcp package in your linux box, lets start configuring it. 2. cp /usr/share/doc/dhcp*/dhcpd.conf.sample /etc/dhcpd.conf 3. vim /etc/dhcpd.conf #line 4: specify your network and subnet subnet 192.168.0.0 netmask 255.255.255.0 { # line 7 : specify default gateway option routers192.168.0.1; # line 8: specify subnetmask option subnet-mask255.255.255.0; # line 10: specify NIS domain name if you are using. # make it comment if you don not use. option nis-domain "bhutanhorizon.com"; # line 11: specify domain name option domain-name "bhutanhorizon.com"; # line 12: specify IP address of DNS option domain-name-servers 192.168.0.10; # line 14: make it comment # option time-offset-18000; # line 21: specify the range of IP addresses for clients range dynamic-bootp 192.168.0.128 192.168.0

Add repositories for yum

Add Dag RPM Repository for yum because that has many useful packages. wget http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt rpm - -import RPM-GPG-KEY.dag.txt rm -f RPM-GPG-KEY.dag.txt vim /etc/yum.repos.d/dag.repo # create new file like below [dag] name=Dag RPM Repository for Red Hat Enterprise Linux baseurl=http://apt.sw.be/redhat/el5/en/$basearch/dag/ gpgcheck=1 enabled=0 When you use DAG repository, Input yum command like below. yum - -enablerepo=dag install [package] Add repository Extra Package for Enterprise Linux (EPEL) that is provided from Fedora project. wget http://download.fedora.redhat.com/pub/epel/RPM-GPG-KEY-EPEL rpm - -import RPM-GPG-KEY-EPEL rm -f RPM-GPG-KEY-EPEL vim /etc/yum.repos.d/epel.repo # create new file like below [epel] name=EPEL RPM Repository for Red Hat Enterprise Linux baseurl=http://download.fedora.redhat.com/pub/epel/$releasever/$basearch/ gpgcheck=1 enabled=0 When you use EPEL repository, Input yum command like bel

Online System's in Bhutan

Audit Clearance System - Royal Audit Authority Security Clearance Service - Royal Bhutan Police Planning and Monitoring System - Gross National Happiness Commission Asset Declaration System - Anti-Corruption Commission Forestry Information Database System - Department of Forest and Services Forestry e-Services - Department of Forest and Services Civil Service Information System - Royal Civil Service Commission Tashel Online System - Tourism Council of Bhutan Labour Market Information System - Department of Employment Labour Net System - Department of Labour Technical Vocational Education & Training Management Information System - Ministry of Labour and Human Resources e-Job Portal - Ministry of Labour and Human Resources Office Procedure Automation - Ministry of Information & Communication e-Sakor - National Land Commission G2C - Citizen Service MYRB & PEMS - Ministry of Finance G2B - Business Service Portal HHC - Health Help Center Biosaf

Find Duplicate Records in a Table

In some cases you need to locate if there are duplicate record in a table and you are stuck how to go about, then here's how you can find it. SELECT cellno, COUNT(cellno) AS NumOccurrences FROM tblClientCellNumber GROUP BY cellno HAVING (COUNT(cellno) > 1)

Install bbPress and new theme

Download latest version of bbPress from bbpress.org . Unzip it rename it and upload in the root directory of the HTTP Directory, normally it is the directory where you put your website files and so on. After that follow the step, and it will ask you the database name, so make sure that you create one before. When you install custom theme for the bbpress, upload it in the my-templates folder, if there is no such folder then create one. The folder should be create where the file bb-config.php is located and the folder permission should be 755. Now go to the admin and activate the New Theme for freshly installed bbpress. Happy forum...

Difference Between include, include_once, require, and require_once

Every time I worked on PHP, I always used include, then later on I wanted to know the difference between include, include_once, require, and require_once. After googling I came to know the difference. include: Includes and evaluates the specified file, throwing a warning if the file can’t be found. include_once: Same as include, but if the file has already been included it will not be included again. require: Includes and evaluates the specified file (same as include), but instead of a warning, throws a fatal error if the file can’t be found. require_once: Same as require, but if the file has already been included it will not be included again.

ASP.NET AJAX toolkit calendar control with readonly textbox

I used the calendar control from the AJAX toolkit to set a date in its associated asp:textbox control. I wanted the user to only be able to set the date through the calendar control so I made the textbox to read only by setting the ReadOnly property to true. The problem this produces is that readonly controls don’t post back their values in the viewstate thus you lose the value when the user submits the form. The Solution: Leave the textbox control property as ReadOnly = False In the Page Load event set the client side attribute of the textbox with the following: txtDate.Attributes.Add("ReadOnly", "true"); This way the control is included in the postback and the value is preserved but client side the user won’t be able to manually edit it.

Share files in Remote Desktop Connection

In my case I access hell lot of time using Remote Desktop Connection to connect to my deployment server. In some cases I need to get the data from the Remote Desktop Server. Glad to know later that Remote Desktop Connection, a default application found in Windows OS does support such feature of sharing file between remote desktop and your Laptop. 1. Open the Remote Desktop Connection or type mstsc in Run commend 2. Click on Options when Remote Desktop Connection is opened. 3. Select Local Resources tab menu. 4. In Local devices and resources group box, select more... 5. Then check, Drives That's it folks, now open the My Computer in the remote Desktop that you have just logged in. There you will see your Drives added automatically as Map Network drives. now you can make a file transfer between your laptop and the Remote Desktop Server.

Yum to access through Proxy Server

In some network where you have to enter the IP Address of the proxy server to access the internet and you are not able to use the yum command to update your system. You normally put the Proxy Server IP and Ports in your browser setting, but in Linux box that doesnot solve the problem. You need to edit the file /etc/yum.conf , and make a new entry in the bottom of the file as below: proxy=http://<Proxy Address>:<proxy port> Now run the yum command and you will see its now working.

Broadband Connection setup in Fedora

I just installed Fedora 14 in my Laptop, after that I wanted to setup a Druknet broadband connection to access internet. After so much of trying i finally did it. My Current Situation of broadband connection was: Connecting to druknet Broadband through my home wireless network. 1. I connected to my wireless network 2. I went to System > Administration > Network 3. Clicked New 4. Select xDSL Connection from the Device Type 5. Provider Name: broadband Account Type: Normal Login Name: dnetXXXXXXXX Password: XXXXXXXXXXXXXXX 6. Apply 7. I edited /etc/sysconfig/network-scripts/ifcfg-broadband, the line that had ETH to below ETH:wlan0 8. System > Administration > Network. Then Select the current xDSL broadband connection and Activate it. Yahoooo, now you are connected to internet!

Problem accessing through FTP Client

There are times when you come across an error message when you use FTP Client, the error message with be something like Failed to list directory or something like that. During such error make sure your Linux server has port 20 and 21 opened in IPTABLES. If those ports are allowed in your IPTABLES than make sure "ip_conntrack_ftp" module is loaded. Check in /etc/sysconfig/iptables-config if the following line exist: IPTABLES_MODULES="ip_conntrack_ftp" If it doesn't contain then add it or load it in module of kernal. Loading module for Kernal using rc.local file. # File: /etc/rc.local # Module to track the state of connections modprobe ip_conntrack # Load the iptables active FTP module, requires ip_conntrack modprobe ip_conntrack_ftp # Load iptables NAT module when required modprobe iptable_nat # Module required for active an FTP server using NAT modprobe ip_nat_ftp

Subnetting CIDR

I always had rough time trying to get the subnet address from the CIDR. SO to make myself simplify i collected the following information: Or visit this site: http://www.subnet-calculator.com/ Allowed Class A Subnet and Host IP addresses # bits Subnet Mask CIDR # Subnets # Hosts Nets * Hosts 2 255.192.0.0 /10 2 4194302 8388604 3 255.224.0.0 /11 6 2097150 12582900 4 255.240.0.0 /12 14 1048574 14680036 5 255.248.0.0 /13 30 524286 15728580 6 255.252.0.0 /14 62 262142 16252804 7 255.254.0.0 /15 126 131070 16514820 8 255.255.0.0 /16 254 65534 16645636 9 255.255.128.0 /17 510 32766 16710660 10 255.255.192.0 /18 1022 16382 16742404

Windows 7 File Association Remove

In windows 7 the file associated with the respective application has been changed. In previous Windows XP file association was simple. Where as this feature doesn't include in Windows 7. Thanks to ExtMan is a free program for Windows users who want to create, edit or delete file extensions in the operating system. It adds the functionality to Vista and Windows 7, but runs fine under Windows XP as well. With little bit of complication as the program's language is in German and there is a option to select to English, but in confirmation windows pop it is still in German. ExtMan is an ultimate solution for me to add or remove file extension in Windows 7

Gmail or Google Apps Mail setting in Thunderbird

I wanted to configure my Gmail/Google/Google Apps Mail of my Domain account in my email client Thunderbird. I want to do pop settings for the account instead of imap. Here is what i did to make a setting in my Thunderbird: 1. Enter Your Name, Email Address and Password. Click Continue. 2. As soon as I clicked on Continue, I click on manual Config. Then I make a necessary setting as for POP account. a. Google App Mail/Google Mail Account Incoming: POP3 ; pop.googlemail.com ; 995 ;  SSL/TLS ; Normal Password Outgoing: SMTP ; smtp.googlemail.com ; 587 ; STARTTLS ; Normal Password Username: user@domain.com b. GMail Account Incoming: POP3 ; pop.gmail.com ; 995 ;  SSL/TLS ; Normal Password Outgoing: SMTP ; smtp.gmail.com ; 587 ; STARTTLS ; Normal Password Username: user@gmail.com

Insert Record in a Table with primary key value

I came across a problem where i deleted on record accidentally and that record id was in use. So I had to Enter that ID in Identity Column and rest of the data in respective fields of that record line. I could add values in other fields but could not enter in Identity Column. So I browsed for the information and this is what I got: SET IDENTITY_INSERT YourTableName ON INSERT INTO YourTableName(ID, FirstName, LastName) VALUES (18, 'Paul', 'Adams') GO SET IDENTITY_INSERT YourTableName OFF

Wordpress Hack to Hide its version

There had been issue and talk going around about wordpress sites being hacked. One main thing that most of the hackers look for is the Version of the wordpress that is being used for the site. Well if you are worried about it, here is a sweet short code that will remove the wordpress version from your source code without having to use any wordpress plugins. Open your functions.php and add the following line: remove_action('wp_head', 'wp_generator'); Open header.php and remove the following lines: <meta name="generator" content="WordPress <?php bloginfo('version'); ?>" /> <!-- leave this for stats -->

Get Database Size

Database size keeps on growing daily, and I wanted to know the size of my database. Finally i got a query that fulfills my requirement: SELECT sysDa.Name,sysDa.create_date,sysDa.recovery_model_desc, temp.DBSize8KBPage FROM ( SELECT sysMas.database_ID, sysMas.size, SUM(size) as DBSize8KBPage FROM sys.master_Files sysMas GROUP BY sysMas.DataBase_ID, sysMas.size ) temp INNER JOIN Sys.Databases sysDa on temp.Database_ID = sysDa.DataBase_ID

Execute Stored Procedure when SQL Server starts

For a Stored Procedure to be eligible to be executed when SQL Server starts, the stored procedure must be in the "master" database and cannot contain INPUT or OUTPUT parameters. The sp_procoption system stored procedure is useful in setting the Stored Procedure for autoexecution - i.e it runs every time SQL Server service is started. Here's how to execute a Stored Procedure when SQL Server starts EXEC sp_procoption 'usp_SomeProcForStart', 'startup', 'true' To disable the stored procedure again EXEC sp_procoption 'usp_SomeProcForStart', 'startup', 'false' For a Stored Procedure to be eligible to be executed when SQL Server starts, the stored procedure must be in the ‘master’ database and cannot contain INPUT or OUTPUT parameters.

Check how many users are logged into SQL Server

Have you ever wondered how to check how many users are logged in to the SQL Server? You must have right' so here is the solution to find it out. Execute any one of the below query in your SQL Server. select * from sys.sysprocesses or EXEC sp_who or EXEC sp_who2 To know more about eh sysprocesses go to this link: http://msdn2.microsoft.com/en-us/library/ms179881.aspx You can also check the active connections for each Database in your SQL Server. To do so execute the following query. SELECT db_name(dbid) as DatabaseName, count(dbid) as NoOfConnections, loginame as LoginName FROM sys.sysprocesses WHERE dbid > 0 GROUP BY dbid, loginame

Internet Explorer issue in Compatibility Mode

Web Sites/Web Page should be rendered in Standard Mode or in Compatibility Mode. For few web page developed in .NET Platform, we face problem in rendering the Pages. In such case we need to enable Compatibility mode in Internet Explorer. However the following meta tag produces some good result in such problem. The following meta tag will render the web site/web page in Compatibility View in IE8: <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> The following meta tag will render the web site/web page in Standard Mode in IE8 <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />

Windows 7 God Mode

Although you might have heard of God Mode in games, but in Windows 7 there is also such mode which contains hundreds of settings that the operating system contain, places all in just one place. To enable such feature in your windows 7, follow the below steps: 1. Create a New Folder Any where you like it in your computer 2. Rename the Folder into GodMode. {ED7BA470-8E54-465E-825C-99712043E01C}

SQL Server 2005 Remote Connectivity

In some cases, I have seen people trying to create a database server using an ordinary desktop computer. Doing so people have come across problem where application was unable to connect to the desktop where database is hosted. Now the simple solution to such problem is: 1. All Programs > Microsoft SQL Server 2005 > Configuration Tools > SQL Server Surface Area Configuration 2. Surface Area Configuration for Services and Connections 3. Under Database Engine select Remote Connections. Enable Local and remote connections and under that enable Using both TCP/IP and named pipes 4. Now restart all SQL Services

Mail Server Configuration in CentOS using Postfix

First thing to do is check if postfix and dovecot is installed in your Linux Machine rpm -qa postfix rpm -qa dovecot If postfix and dovecot is not installed, then install it using yum command yum install postfix dovecot -y Now lets start configuring Mail Server: 1. Look for the below line and make necessary changes in vi /etc/postfix/main.cf myhostname = mail.yj.bt mydomain = yj.bt myorigin = $mydomain inet_interfaces = all mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain mynetworks = 127.0.0.0/8, 10.0.0.0/24 home_mailbox = Maildir/ smtpd_banner = $myhostname ESMTP # Add at bottom for # for SMTP-Auth setting smtpd_sasl_type = dovecot smtpd_sasl_path = private/auth-client smtpd_sasl_auth_enable = yes smtpd_sasl_security_options = noanonymous smtpd_sasl_local_domain = $myhostname smtpd_client_restrictions = permit_mynetworks,reject_unknown_client,permit smtpd_recipient_restrictions = permit_mynetworks,permit_auth_destination,permit_sasl_auth

Use grep to search file

Search /etc/passwd for boo user: grep boo /etc/passwd You can force grep to ignore word case i.e match boo, Boo, BOO and all other combination with -i option: grep -i "boo" /etc/passwd Use grep recursively You can search recursively i.e. read all files under each directory for a string "boo": grep -r "boo" /etc/ You can search for a string boo irrespective of word case and recursive: grep -ir "boo" /etc/ When you search for boo, grep will match fooboo, boo123, etc. You can force grep to select only those lines containing matches that form whole words i.e. match only boo word: grep -w "boo" /etc/ Grep invert match You can use -v option to print inverts the match; that is, it matches only those lines that do not contain the given word. For example print all line that do not contain the word bar: grep -v boo /etc/

ASP.NET Menu and IE8 rendering white issue

In IE8 the zindex by default return "auto", but when zindex value has been set, the ASP.NET Menu control assumes a different value. To over come the white issue, just edit your stylesheet and enter z-index: 100 ; or for the sub menu or any class or ID that you are using to specify the dropdown menu.

asp:Menu Server Control - Cross Browser Compatibility

Cross browser compatibility struggle is getting upsetting while working with asp:Menu Server Control. Anyhow, It was not rendering/working well with Safari and Chrome. A bit of googling... and I have a solution for this. I have added below small piece of code snippet in my MasterPage's Page_Load event if (Request.UserAgent.IndexOf("AppleWebKit") > 0) { Request.Browser.Adapters.Clear(); } This will tell asp.net not to use an adapter when rendering the menu control. This will work for both Safari and chrome as well because they both use webkit which is how asp.net identifies Safari1Plus. courtesy: http://dotnetslackers.com/Community/blogs/kaushalparik/default.aspx

Clear Recent Opened Project List in Visual Studio .NET

Here is an nice tip on how to clear the "Recent Project" list in your Visual Studio .NET : Close Visual Studio (if its open) GOTO > Start > Run > RegEdit GOTO > HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\ \ProjectMRUList remove unnecessary items from list. Similarly repeat the steps for FileMRuList GOTO > HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\ \FileMRUList remove unnecessary items from list. To Clear the Find and Replace List GOTO > HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\ \Find remove unnecessary items from list. Another Simple way is, Create one Text file "Clear.txt" and add below contents in it Windows Registry Editor Version 5.00 [-HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\ProjectMRUList] [HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\ProjectMRUList] Save and Close the file and rename is as "Clear.reg"; tha

Remove Mail Queue in Postfix

To see mail queue, enter : # mailq To remove all mail from the queue, enter : # postsuper -d ALL mail.pl [script removed the mail queue as entered after the script] #!/usr/bin/perl $REGEXP = shift || die "no email-adress given (regexp-style, e.g. bl.*\@yahoo.com)!"; @data = qx ; for (@data) { if (/^(\w+)(\*|\!)?\s/) { $queue_id = $1; } if($queue_id) { if (/$REGEXP/i) { $Q{$queue_id} = 1; $queue_id = ""; } } } #open(POSTSUPER,"|cat") || die "couldn't open postsuper" ; open(POSTSUPER,"|postsuper -d -") || die "couldn't open postsuper" ; foreach (keys %Q) { print POSTSUPER "$_\n"; }; close(POSTSUPER); To run the script ./mail.pl xxx.com 'or' ./mail.pl info@xx.com

Install IIS7 to work with MS SQL Server 2005 on Vista/Win7

You need to enable the following features to make your MS SQL Server 2005 work with Vista/Windows 7 before installing MS SQl Server 2005. Here is the list of IIS 7 role services that need to be installed: Start 1. Control Panel 2. Programs and Features 3. Turn Windows features on or off 4. Enable Enable various features of IIS 1. Web management tools 1.1. IIS 6 Management Compatibility 1.1.1. IIS 6 WMI Compatibility 1.1.2. IIS Metabase and IIS 6 configuration compatibility 2. World Wide Web Services 2.1. Application Development Features 2.1.1. .NET Extensibility 2.1.2. ASP.NET 2.1.3. ISAPI Extensions 2.1.4. ISAPI Filters 2.2 Common Http Features 2.2.1. Default Document 2.2.2. Directory Browsing 2.2. 3. HTTP Redirection

SQL Server Maintenance Plan

After changing your sa password, your maintenance plan might stop working and you might face a problem where you cannot delete the maintenance plan or edit. If you are facing such problem with your MS SQL server Maintenance Plan when you change your sa account password. Follow the following steps: 1. Select msdb database 2. Start a new query 3. select * from sysmaintplan_plans 4. Copy the id record and use it in the below query 5. delete from sysmaintplan_log where plan_id = '' 6. delete from sysmaintplan_subplans where plan_id = '' 7. delete from sysmaintplan_plans where id = '' 8. After you have run all the above delete sql query, check if the respective maintenance plan is available. normally, it wont be there, and even if there is delete it.