How to add a new user to MySQL and set privileges

First you need to connect to MySQL server with a user who has administrative priveleges.

[root@techpulp ~]# mysql -u root -p

Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.67 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

Let us assume you are creating an user named “neo” with password “neopass“and you would like to grant all privileges on the database “articles“.

mysql> GRANT ALL ON articles.* to 'neo'@'localhost' identified by 'neopass' WITH GRANT OPTION;

After adding a new user, you need More >

How to disable directory listing by Apache web server

There are two ways to disable directory browsing feature of Apache web server. However the first method is most practical way as server’s configuration file is typically not modifiable by the user as part of his hosting plan. Most of the hosting provides allow modification of .htaccess file and enable ModRewrite module in the Apache.

The ModRewrite Way

Add the following line towards the end of .htaccess file present in a directory for which you would like to disable directory listing.

Options All -Indexes

However if you have lots of such directories, it may become difficult for you to do this.

The httpd.conf way

If you More >

How to create rounded border for DIV, PRE like HTML elements

The following CSS code enables rounded borders for elements like DIV, PRE etc. However it may not work in Internet Explorer (IE) as it is specific to certain browsers like Firefox.

pre {

-moz-border-radius: 3px;
-khtml-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;

}

The above CSS defines 3px radius for the rounded element. You can change it to a value of your choice.

How to define scrollable and fixed width DIV or PRE tag in HTML using CSS

With fixed width websites, it is often desired to fix the maximum width of certain elements like <DIV>, <PRE> etc. However by fixing the maximum width of these elements, the content inside them may either disappear or may interfere with the content of element that appear near to them.

CSS supports an attribute “overflow” which can be used to define the way how browser should behave if the contents of such element tend to go beyond width or height of the element. The following are the possible values for “overflow” attribute.

Value Meaning auto Display horizontal or vertical scroll bar automatically when More >

How to change bullet style for unordered list UL in HTML or CSS

The unordered list “<ul>” supports an attribute named “type” that specifies type of display for bullets. The “type” attribute takes values: disc,circle,square.

The following displays a square instead of default disc style for bullets.

<ul type="square">
<li>One</li>
<li>Two</li>
<li>Three</li>
</ul>

display looks like following

  • One
  • Two
  • Three

Similarly, a disc style appears as follows:

  • One
  • Two
  • Three

Similarly, a circle style appears as follows:

  • One
  • Two
  • Three

Otherwise, you can use “list-style-type” attribute in CSS as shown below:

ul {
  list-style-type: square;
}

You can customize the bullets further by specifying an image url in CSS as follows:

ul {
  list-style-type: url("/images/arrow.jpg");
}
More >

How to display special characters in HTML

HTML is a mark up language that uses characters like “<”, “>” as part of its syntax. So it provides a special escapes to display the special characters as is in HTML. The following table provides list of special characters and their HTML syntax.



Name Symbol HTML syntax Ampersand & &amp; Cent ¢ &cent; Copyright © &copy; Degree ° &deg; Greater Than > &gt; Less Than < &lt; Non-breaking Space &nbsp; Registered Trademark ® &#174 Trademark ™ ™

How to disable left indentation of LI tags in HTML

The <li> tag can be used under an unordered list tag <ul> or ordered list tag <ol>.

The following shows how <li> tag can be used in an unordered list. Under unordered list, each <li> shows a bullet by default.

<ul>
<li>One</li>
<li>Two</li>
<li>Three</li>
</ul>

The above code appears in the browser as follows:

  • One
  • Two
  • Three

You can use following CSS to disable left indentation:

ul {margin: 0;}

If you don’t want to display bullets, you can do the following.

ul {
 list-style-type: none;
 margin: 0;
}

You can use similar trick for ordered list

    as well.

How to disable display of bullets for LI tags in HTML

The <li> tag can be used under an unordered list tag <ul> or ordered list tag <ol>.

Unordered List The following shows how <li> tag can be used in an unordered list. Under unordered list, each <li> shows a bullet by default.

<ul>
<li>One</li>
<li>Two</li>
<li>Three</li>
</ul>

The above code appears in the browser as follows:

  • One
  • Two
  • Three

If you don’t want each <li> item not to display its position as number  under <ul>, you can add “list-style-type: none;” style to the <ul> tag.

<ul style="list-style-type: none;">
<li>One</li>
<li>Two</li>
<li>Three</li>
</ul>

Ordered List The following shows how <li> tag can be used in an ordered list. Under ordered list, each More >

How to convert a PDF file to an image in command line of Linux

The command “convert” is used to do the job. You need to install ImageMagick suite of tools that are used to manipulate images.

The following command converts a PDF file myfile.pdf  to a JPG image.

[neo@techpulp ~]# convert myfile.pdf myfile.jpg

You can convert it to other image formats as well. For example, the following command converts the PDF to a PNG image file.

[neo@techpulp ~]# convert myfile.pdf myfile.png

The following command converts the PDF to a GIF image file.

[neo@techpulp ~]# convert myfile.pdf myfile.gif